From: Kwanghoon Son Date: Thu, 22 Sep 2022 06:33:27 +0000 (-0400) Subject: Add ITC compatible tests X-Git-Tag: accepted/tizen/unified/20230113.091231~33 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b82387a7f296369fe93df97cc4ccf8461ce2eb6c;p=platform%2Fcore%2Fapi%2Fmediavision.git Add ITC compatible tests [Issue type] New test Change-Id: I5830f009c889453127562b5f411e8db98eb6c41c Signed-off-by: Kwanghoon Son --- diff --git a/mv_machine_learning/inference/src/OutputMetadata.cpp b/mv_machine_learning/inference/src/OutputMetadata.cpp index bdcbce4..3040fa9 100644 --- a/mv_machine_learning/inference/src/OutputMetadata.cpp +++ b/mv_machine_learning/inference/src/OutputMetadata.cpp @@ -44,7 +44,7 @@ int OutputMetadata::ParseScore(JsonObject *root) int OutputMetadata::ParseBox(JsonObject *root) { if (!json_object_has_member(root, "box")) { - LOGE("No box outputmetadata"); + LOGI("No box outputmetadata"); return MEDIA_VISION_ERROR_NONE; } diff --git a/test/testsuites/machine_learning/inference/test_face_landmark_detection.cpp b/test/testsuites/machine_learning/inference/test_face_landmark_detection.cpp index 0127482..321456a 100644 --- a/test/testsuites/machine_learning/inference/test_face_landmark_detection.cpp +++ b/test/testsuites/machine_learning/inference/test_face_landmark_detection.cpp @@ -28,6 +28,13 @@ MV_CONFIG_PATH \ "/res/inference/images/faceLandmark.jpg" +#define FLD_TFLITE_WIEGHT_TWEAKCNN_128_PATH \ + MV_CONFIG_PATH \ + "models/FLD/tflite/fld_tweakcnn_128x128.tflite" +#define FLD_TFLITE_META_TWEAKCNN_128_PATH \ + MV_CONFIG_PATH \ + "models/FLD/tflite/fld_tweakcnn_128x128.json" + void _facial_landmark_detected_cb(mv_source_h source, const int number_of_landmarks, const mv_point_s *locations, void *user_data) { @@ -85,4 +92,30 @@ TEST_P(TestFaceLandmarkDetectionOpenCV, CAFFE_CNNCASCADE) INSTANTIATE_TEST_CASE_P(Prefix, TestFaceLandmarkDetectionOpenCV, ::testing::Values(ParamTypes(false, MV_INFERENCE_TARGET_DEVICE_CPU), - ParamTypes(true, MV_INFERENCE_TARGET_DEVICE_CPU))); \ No newline at end of file + ParamTypes(true, MV_INFERENCE_TARGET_DEVICE_CPU))); + +class TestFaceLandmarkDetectionTflite : public TestInference +{ +public: + void inferenceFaceLandmark() + { + TestInference::ConfigureInference(); + + ASSERT_EQ(MediaVision::Common::ImageHelper::loadImageToSource(IMG_FACE_LANDMARK, mv_source), + MEDIA_VISION_ERROR_NONE); + ASSERT_EQ(mv_inference_facial_landmark_detect(mv_source, infer, NULL, _facial_landmark_detected_cb, NULL), + MEDIA_VISION_ERROR_NONE); + } +}; + +TEST_P(TestFaceLandmarkDetectionTflite, TweakCNN) +{ + engine_config_hosted_tflite_model(engine_cfg, FLD_TFLITE_WIEGHT_TWEAKCNN_128_PATH, + FLD_TFLITE_META_TWEAKCNN_128_PATH, _use_json_parser, _target_device_type); + if (_use_json_parser) { + inferenceFaceLandmark(); + } +} + +INSTANTIATE_TEST_CASE_P(Prefix, TestFaceLandmarkDetectionTflite, + ::testing::Values(ParamTypes(true, MV_INFERENCE_TARGET_DEVICE_CPU))); \ No newline at end of file diff --git a/test/testsuites/machine_learning/inference/test_image_classification.cpp b/test/testsuites/machine_learning/inference/test_image_classification.cpp index 8f35827..e952608 100644 --- a/test/testsuites/machine_learning/inference/test_image_classification.cpp +++ b/test/testsuites/machine_learning/inference/test_image_classification.cpp @@ -53,14 +53,21 @@ #define IC_SNPE_WEIGHT_QUANT_INCEPTION_V3_299_PATH \ MV_CONFIG_PATH \ "/models/IC_Q/snpe/inception_v3_quantized.dlc" +#define IC_LABEL_MOBILENET_V1_224_FOR_ITC_PATH \ + MV_CONFIG_PATH \ + "/models/IC/tflite/image-classification-label.txt" +#define IC_TFLITE_WEIGHT_MOBILENET_V1_224_FOR_ITC_PATH \ + MV_CONFIG_PATH \ + "/models/IC/tflite/image-classification-001.tflite" void _image_classified_cb(mv_source_h source, const int number_of_classes, const int *indices, const char **names, const float *confidences, void *user_data) { const std::string answer = "banana"; + const std::string answerWithCapital = "Banana"; auto answer_found = false; for (int i = 0; i < number_of_classes; i++) { - if (answer == names[i]) { + if (answer == names[i] || answerWithCapital == names[i]) { answer_found = true; break; } @@ -125,6 +132,16 @@ TEST_P(TestImageClassificationTflite, MobilenetV1) inferenceBanana(); } +TEST_P(TestImageClassificationTflite, MobilenetV1ForITC) +{ + engine_config_hosted_tflite_model(engine_cfg, IC_TFLITE_WEIGHT_MOBILENET_V1_224_FOR_ITC_PATH, + IC_LABEL_MOBILENET_V1_224_FOR_ITC_PATH, _use_json_parser, _target_device_type); + + if (_use_json_parser) { + inferenceBanana(); + } +} + TEST_P(TestImageClassificationTflite, MobilenetV2) { engine_config_hosted_tflite_model(engine_cfg, IC_TFLITE_WEIGHT_MOBILENET_V2_224_PATH, diff --git a/test/testsuites/machine_learning/inference/test_pose_landmark_detection.cpp b/test/testsuites/machine_learning/inference/test_pose_landmark_detection.cpp index 8c5a5c1..945c44c 100644 --- a/test/testsuites/machine_learning/inference/test_pose_landmark_detection.cpp +++ b/test/testsuites/machine_learning/inference/test_pose_landmark_detection.cpp @@ -25,6 +25,13 @@ MV_CONFIG_PATH \ "/res/inference/images/poseLandmark.jpg" +#define PLD_TFLITE_WEIGHT_CPM_192_PATH \ + MV_CONFIG_PATH \ + "/models/PLD/tflite/pld_cpm_192x192.tflite" +#define PLD_TFLITE_META_CPM_192_PATH \ + MV_CONFIG_PATH \ + "/models/PLD/tflite/pld_cpm_192x192.json" + void _pose_landmark_detected_cb(mv_source_h source, mv_inference_pose_result_h pose, void *user_data) { int cb_number_of_poses = 0; @@ -80,6 +87,16 @@ TEST_P(TestPoseLandmarkDetectionTflite, MobilenetV1) inferencePoseLandmark(); } +TEST_P(TestPoseLandmarkDetectionTflite, CPM) +{ + engine_config_hosted_tflite_model(engine_cfg, PLD_TFLITE_WEIGHT_CPM_192_PATH, NULL, _use_json_parser, + _target_device_type); + + if (_use_json_parser) { + inferencePoseLandmark(); + } +} + INSTANTIATE_TEST_CASE_P(Prefix, TestPoseLandmarkDetectionTflite, ::testing::Values(ParamTypes(false, MV_INFERENCE_TARGET_DEVICE_CPU), ParamTypes(true, MV_INFERENCE_TARGET_DEVICE_CPU))); \ No newline at end of file