From: Bhuvan Reddy Gangula Date: Tue, 18 Mar 2025 10:56:24 +0000 (+0900) Subject: Add testcase for YoloV5 DLC model X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1cff93c383da5f54bd25be02ccda2f31fba85cf9;p=platform%2Fcore%2Fapi%2Fmediavision.git Add testcase for YoloV5 DLC model 1) DLC models need SNPE backend library to be installed in the target 2) Need nnstreamer snpe tensor filter to run The SNPE library version and DLC model convertor(qnn sdk) version need to match since SNPE version 1 and 2 are not compatible Change-Id: I18ac70eff752022e09b36700e5445b4c083db49a Signed-off-by: Bhuvan Reddy Gangula --- diff --git a/test/testsuites/machine_learning/object_detection/test_object_detection.cpp b/test/testsuites/machine_learning/object_detection/test_object_detection.cpp index 5f045f6e..bc54db45 100644 --- a/test/testsuites/machine_learning/object_detection/test_object_detection.cpp +++ b/test/testsuites/machine_learning/object_detection/test_object_detection.cpp @@ -277,3 +277,74 @@ TEST(FaceDetectionTest, InferenceShouldBeOk) ret = mv_destroy_source(mv_source); ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); } + +TEST(ObjectDetectionTest, DISABLED_InferenceDLCShouldBeOk) +{ + mv_object_detection_h handle; + vector test_models { + { "yolo_v5", "yolov5m.dlc", "yolov5m.json", "label_coco_80.txt", "DOG" } + // TODO. + }; + + mv_source_h mv_source = NULL; + int ret = mv_create_source(&mv_source); + ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); + + ret = ImageHelper::loadImageToSource(IMG_DOG, mv_source); + ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); + + for (const auto &model : test_models) { + cout << "model name : " << model.model_file << endl; + + ret = mv_object_detection_create(&handle); + ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); + + mv_object_detection_set_model(handle, model.model_name.c_str(), model.model_file.c_str(), + model.meta_file.c_str(), model.label_file.c_str()); + mv_object_detection_set_model_path(handle, "/opt/usr/globalapps/mediavision.object.detection/models/dlc/"); + mv_object_detection_set_engine(handle, "snpe", "npu"); + + ret = mv_object_detection_configure(handle); + ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); + + ret = mv_object_detection_prepare(handle); + ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); + + ret = mv_object_detection_inference(handle, mv_source); + ASSERT_EQ(ret, 0); + + unsigned int number_of_objects; + const int *left, *top, *right, *bottom; + unsigned long frame_number; + const float *confidences; + + ret = mv_object_detection_get_result(handle, &number_of_objects, &frame_number, &confidences, &left, &top, + &right, &bottom); + ASSERT_EQ(ret, 0); + + for (unsigned int idx = 0; idx < number_of_objects; ++idx) { + cout << "Frame number = " << frame_number << " probability = " << confidences[idx] << " " << left[idx] + << " x " << top[idx] << " ~ " << right[idx] << " x " << bottom[idx] << endl; + } + + for (unsigned int idx = 0; idx < number_of_objects; ++idx) { + const char *label; + + ret = mv_object_detection_get_label(handle, idx, &label); + ASSERT_EQ(ret, 0); + cout << "index = " << idx << " label = " << label << endl; + + string label_str(label); + + transform(label_str.begin(), label_str.end(), label_str.begin(), ::toupper); + + ASSERT_TRUE(label_str == model.anster); + } + + ret = mv_object_detection_destroy(handle); + ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); + } + + ret = mv_destroy_source(mv_source); + ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); +} \ No newline at end of file