From fe02f05b54290d93405eda7403675a335d162d05 Mon Sep 17 00:00:00 2001 From: Kwanghoon Son Date: Fri, 2 Sep 2022 01:29:40 -0400 Subject: Add SNPE efficient net test [Issue type] new test Change-Id: Ia141001c1957709075da62416e6d4c0c6dc89916 Signed-off-by: Kwanghoon Son --- .../inference/test_object_detection.cpp | 45 ++++++++++++++++++++-- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/test/testsuites/machine_learning/inference/test_object_detection.cpp b/test/testsuites/machine_learning/inference/test_object_detection.cpp index 7e685d61..42c0c482 100644 --- a/test/testsuites/machine_learning/inference/test_object_detection.cpp +++ b/test/testsuites/machine_learning/inference/test_object_detection.cpp @@ -12,16 +12,22 @@ #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(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 -- cgit v1.2.3