Add SNPE efficient net test
authorKwanghoon Son <k.son@samsung.com>
Fri, 2 Sep 2022 05:29:40 +0000 (01:29 -0400)
committerInki Dae <inki.dae@samsung.com>
Fri, 2 Sep 2022 08:09:25 +0000 (17:09 +0900)
[Issue type] new test

Change-Id: Ia141001c1957709075da62416e6d4c0c6dc89916
Signed-off-by: Kwanghoon Son <k.son@samsung.com>
test/testsuites/machine_learning/inference/test_object_detection.cpp

index 7e685d6177727f807abb600f515f081c5d965089..42c0c4823cb23863bed1447f31f86e2624116f3c 100644 (file)
 #define IMG_DOG    \
        MV_CONFIG_PATH \
        "/res/inference/images/dog2.jpg"
+#define OD_LABEL_EFFICIENTDET_LITE2_448_PATH \
+       MV_CONFIG_PATH                           \
+       "models/OD/snpe/label_coco_90.txt"
+#define OD_SNPE_WEIGHT_QC_EFFCIENTDET_LITE2_448_PATH \
+       MV_CONFIG_PATH                                   \
+       "/models/OD/snpe/lite2_fp32.dlc"
 
 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)
 {
-       const std::string answer = "Dog";
+       auto answer = static_cast<std::string *>(user_data);
        auto answer_found = false;
        for (int i = 0; i < number_of_objects; i++) {
-               if (answer == names[i]) {
+               if (*answer == names[i]) {
                        answer_found = true;
                        break;
                }
@@ -34,13 +40,14 @@ class TestObjectDetectionTflite : public TestInference
 public:
        void inferenceDog()
        {
+               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, NULL),
+                                                                                        _object_detected_cb, &result),
                                  MEDIA_VISION_ERROR_NONE);
        }
 };
@@ -95,3 +102,35 @@ INSTANTIATE_TEST_CASE_P(
                Prefix, TestObjectDetectionTflite,
                ::testing::Values(ParamTypes(false, MV_INFERENCE_TARGET_DEVICE_CPU),
                                                  ParamTypes(true, MV_INFERENCE_TARGET_DEVICE_CPU)));
+
+class TestObjectDetectionSnpe : public TestInference
+{
+public:
+       void inferenceDog()
+       {
+               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);
+       }
+};
+
+TEST_P(TestObjectDetectionSnpe, DISABLED_EFDLite2QC)
+{
+       ASSERT_TRUE(_use_json_parser);
+       engine_config_hosted_snpe_model(
+                       engine_cfg, OD_SNPE_WEIGHT_QC_EFFCIENTDET_LITE2_448_PATH,
+                       OD_LABEL_EFFICIENTDET_LITE2_448_PATH, _use_json_parser,
+                       _target_device_type);
+
+       inferenceDog();
+}
+
+INSTANTIATE_TEST_CASE_P(
+               Prefix, TestObjectDetectionSnpe,
+               ::testing::Values(ParamTypes(true, MV_INFERENCE_TARGET_DEVICE_CUSTOM)));
\ No newline at end of file