Add Object detection test(Mobilenet V2) 93/280793/2
authorKwanghoon Son <k.son@samsung.com>
Mon, 5 Sep 2022 07:31:17 +0000 (03:31 -0400)
committerKwanghoon Son <k.son@samsung.com>
Tue, 6 Sep 2022 01:26:53 +0000 (21:26 -0400)
Change-Id: Idaec609087f0ec8767f0daf135edaae1eca06f30
Signed-off-by: Kwanghoon Son <k.son@samsung.com>
test/testsuites/machine_learning/inference/test_object_detection.cpp

index b658a5b..3eb039b 100644 (file)
 #define OD_SNPE_WEIGHT_QC_EFFCIENTDET_LITE2_448_PATH \
        MV_CONFIG_PATH                                   \
        "/models/OD/snpe/lite2_fp32.dlc"
+#define OD_LABEL_MOBILENET_V2_SSD_320_PATH \
+       MV_CONFIG_PATH                         \
+       "/models/OD/tflite/od_mobilenet_v2_ssd_label.txt"
+#define OD_TFLITE_WEIGHT_MOBILENET_V2_SSD_320_PATH \
+       MV_CONFIG_PATH                                 \
+       "/models/OD/tflite/od_mobilenet_v2_ssd_320x320.tflite"
 
 void _object_detected_cb(mv_source_h source, const int number_of_objects, const int *indices, const char **names,
                                                 const float *confidences, const mv_rectangle_s *locations, void *user_data)
@@ -36,13 +42,12 @@ void _object_detected_cb(mv_source_h source, const int number_of_objects, const
 class TestObjectDetectionTflite : public TestInference
 {
 public:
-       void inferenceDog()
+       void inferenceDog(std::string &answer)
        {
-               std::string result("Dog");
                TestInference::ConfigureInference();
 
                ASSERT_EQ(MediaVision::Common::ImageHelper::loadImageToSource(IMG_DOG, mv_source), MEDIA_VISION_ERROR_NONE);
-               ASSERT_EQ(mv_inference_object_detect(mv_source, infer, _object_detected_cb, &result), MEDIA_VISION_ERROR_NONE);
+               ASSERT_EQ(mv_inference_object_detect(mv_source, infer, _object_detected_cb, &answer), MEDIA_VISION_ERROR_NONE);
        }
 };
 
@@ -76,7 +81,19 @@ TEST_P(TestObjectDetectionTflite, MobilenetV1_SSD)
                                  MEDIA_VISION_ERROR_NONE);
        }
 
-       inferenceDog();
+       std::string answer("Dog");
+       inferenceDog(answer);
+}
+
+TEST_P(TestObjectDetectionTflite, MobilenetV2_SSD)
+{
+       engine_config_hosted_tflite_model(engine_cfg, OD_TFLITE_WEIGHT_MOBILENET_V2_SSD_320_PATH,
+                                                                         OD_LABEL_MOBILENET_V2_SSD_320_PATH, _use_json_parser, _target_device_type);
+
+       if (_use_json_parser) {
+               std::string answer("dog");
+               inferenceDog(answer);
+       }
 }
 
 INSTANTIATE_TEST_CASE_P(Prefix, TestObjectDetectionTflite,
@@ -88,11 +105,11 @@ class TestObjectDetectionSnpe : public TestInference
 public:
        void inferenceDog()
        {
-               std::string result("dog");
+               std::string answer("dog");
                TestInference::ConfigureInference();
 
                ASSERT_EQ(MediaVision::Common::ImageHelper::loadImageToSource(IMG_DOG, mv_source), MEDIA_VISION_ERROR_NONE);
-               ASSERT_EQ(mv_inference_object_detect(mv_source, infer, _object_detected_cb, &result), MEDIA_VISION_ERROR_NONE);
+               ASSERT_EQ(mv_inference_object_detect(mv_source, infer, _object_detected_cb, &answer), MEDIA_VISION_ERROR_NONE);
        }
 };