Update testsuite to run google face detection models with meta files 97/257597/5
authorTae-Young Chung <ty83.chung@samsung.com>
Wed, 28 Apr 2021 04:49:51 +0000 (13:49 +0900)
committerTae-Young Chung <ty83.chung@samsung.com>
Wed, 9 Jun 2021 01:54:43 +0000 (01:54 +0000)
Change-Id: I95ac44eaed2d69bf11af8ad063ff06f1dcddf6df
Signed-off-by: Tae-Young Chung <ty83.chung@samsung.com>
test/testsuites/machine_learning/inference/inference_test_suite.c

index bfeabd4e7128ca55c9aafea6a9544379d8e505ff..c8a1badcceae93886e6438510f7a1efbc8aa8a89 100644 (file)
 #define FD_OPENCV_CONFIG_CAFFE_PATH \
        "/usr/share/capi-media-vision/models/FD/caffe/fd_caffe_model_resnet10ssd.prototxt"
 
+/*
+ * Hosted models
+ */
+#define FD_LABEL_MOBILENET_V1_SSD_300_PATH \
+       "/usr/share/capi-media-vision/models/FD/tflite/fd_mobilenet_v1_ssd_postop_label.txt"
+#define FD_TFLITE_WEIGHT_MOBILENET_V1_SSD_300_PATH \
+       "/usr/share/capi-media-vision/models/FD/tflite/fd_mobilenet_v1_ssd_postop_300x300.tflite"
+#define FD_LABEL_BLAZEFACE_128_PATH \
+       "/usr/share/capi-media-vision/models/FD/tflite/fd_blazeface_front_label.txt"
+#define FD_TFLITE_WEIGHT_BLAZEFACE_128_PATH \
+       "/usr/share/capi-media-vision/models/FD/tflite/fd_blazeface_front_128x128.tflite"
+
 //Facial LandmarkDetection
 #define FLD_TFLITE_WEIGHT_PATH \
        "/usr/share/capi-media-vision/models/FLD/tflite/fld_tflite_model1.tflite"
@@ -2409,16 +2421,84 @@ int perform_armnn_mobilenetv1ssd_face(mv_engine_config_h *engine_cfg)
        return err;
 }
 
+int perform_hosted_tflite_mobilenetv1ssd_300_config_face(mv_engine_config_h *engine_cfg)
+{
+       int err = MEDIA_VISION_ERROR_NONE;
+
+       mv_engine_config_h handle = NULL;
+       err = mv_create_engine_config(&handle);
+       if (err != MEDIA_VISION_ERROR_NONE) {
+               printf("Fail to create engine configuration handle.\n");
+               if (handle) {
+                       int err2 = mv_destroy_engine_config(handle);
+                       if (err2 != MEDIA_VISION_ERROR_NONE) {
+                               printf("Fail to destroy engine configuration.\n");
+                       }
+               }
+               return err;
+       }
+
+       mv_engine_config_set_string_attribute(
+                                       handle, MV_INFERENCE_MODEL_WEIGHT_FILE_PATH,
+                                       FD_TFLITE_WEIGHT_MOBILENET_V1_SSD_300_PATH);
+
+       mv_engine_config_set_int_attribute(
+                                       handle, MV_INFERENCE_BACKEND_TYPE,
+                                       MV_INFERENCE_BACKEND_TFLITE);
+
+       mv_engine_config_set_int_attribute(
+                                       handle, MV_INFERENCE_TARGET_TYPE,
+                                        MV_INFERENCE_TARGET_CPU);
+
+       *engine_cfg = handle;
+       return err;
+}
+
+int perform_hosted_tflite_blazeface_128_config_face(mv_engine_config_h *engine_cfg)
+{
+       int err = MEDIA_VISION_ERROR_NONE;
+
+       mv_engine_config_h handle = NULL;
+       err = mv_create_engine_config(&handle);
+       if (err != MEDIA_VISION_ERROR_NONE) {
+               printf("Fail to create engine configuration handle.\n");
+               if (handle) {
+                       int err2 = mv_destroy_engine_config(handle);
+                       if (err2 != MEDIA_VISION_ERROR_NONE) {
+                               printf("Fail to destroy engine configuration.\n");
+                       }
+               }
+               return err;
+       }
+
+       mv_engine_config_set_string_attribute(
+                                       handle, MV_INFERENCE_MODEL_WEIGHT_FILE_PATH,
+                                       FD_TFLITE_WEIGHT_BLAZEFACE_128_PATH);
+
+       mv_engine_config_set_int_attribute(
+                                       handle, MV_INFERENCE_BACKEND_TYPE,
+                                       MV_INFERENCE_BACKEND_TFLITE);
+
+       mv_engine_config_set_int_attribute(
+                                       handle, MV_INFERENCE_TARGET_TYPE,
+                                        MV_INFERENCE_TARGET_CPU);
+
+       *engine_cfg = handle;
+       return err;
+}
+
 int perform_face_detection()
 {
        int err = MEDIA_VISION_ERROR_NONE;
 
        int sel_opt = 0;
-       const int options[] = { 1, 2, 3, 4, 5, 6, 7 };
+       const int options[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
        const char *names[] = { "Configuration",
                                                         "TFLite(CPU) + MobileNetV1 + SSD",
                                                         "OPENCV(CPU) + Resnet10 + SSD",
                                                         "ARMNN(CPU) + MobileNetV1 + SSD",
+                                                        "Hosted: TFLite(cpu + MobilenetV1+SSD)",
+                                                        "Hosted: TFLite(cpu + BlazeFace)",
                                                         "Prepare",
                                                         "Run",
                                                         "Back" };
@@ -2443,7 +2523,7 @@ int perform_face_detection()
                        err = perform_configuration(&engine_cfg);
                } break;
                case 2: {
-                       //perform TF Mobilenetssd config
+                       //perform TFlit Mobilenetv1ssd config
                        if (engine_cfg) {
                                int err2 = mv_destroy_engine_config(engine_cfg);
                                if (err2 != MEDIA_VISION_ERROR_NONE)
@@ -2454,7 +2534,7 @@ int perform_face_detection()
                        err = perform_tflite_mobilenetv1ssd_face(&engine_cfg);
                } break;
                case 3: {
-                       //perform TF Lite Mobilenetssd config
+                       //perform Opencv resenet10ssd config
                        if (engine_cfg) {
                                int err2 = mv_destroy_engine_config(engine_cfg);
                                if (err2 != MEDIA_VISION_ERROR_NONE)
@@ -2464,7 +2544,7 @@ int perform_face_detection()
                        err = perform_opencv_resnet10ssd_face(&engine_cfg);
                } break;
                case 4: {
-                       //perform TF Lite Mobilenetssd config
+                       //perform Armnn Mobilenetv1ssd config
                        if (engine_cfg) {
                                int err2 = mv_destroy_engine_config(engine_cfg);
                                if (err2 != MEDIA_VISION_ERROR_NONE)
@@ -2474,6 +2554,28 @@ int perform_face_detection()
                        err = perform_armnn_mobilenetv1ssd_face(&engine_cfg);
                } break;
                case 5: {
+                       //perform hosted TFlite Mobilenetv1ssd config
+                       if (engine_cfg) {
+                               int err2 = mv_destroy_engine_config(engine_cfg);
+                               if (err2 != MEDIA_VISION_ERROR_NONE)
+                                       printf("Fail to destroy engine_cfg [err:%i]\n", err2);
+                               engine_cfg = NULL;
+                       }
+
+                       err = perform_hosted_tflite_mobilenetv1ssd_300_config_face(&engine_cfg);
+               } break;
+               case 6: {
+                       //perform hosted TFlite blazeface config
+                       if (engine_cfg) {
+                               int err2 = mv_destroy_engine_config(engine_cfg);
+                               if (err2 != MEDIA_VISION_ERROR_NONE)
+                                       printf("Fail to destroy engine_cfg [err:%i]\n", err2);
+                               engine_cfg = NULL;
+                       }
+
+                       err = perform_hosted_tflite_blazeface_128_config_face(&engine_cfg);
+               } break;
+               case 7: {
                        // create - configure - prepare
                        if (infer) {
                                int err2 = mv_inference_destroy(infer);
@@ -2504,7 +2606,7 @@ int perform_face_detection()
                                break;
                        }
                } break;
-               case 6: {
+               case 8: {
                        if (mvSource) {
                                int err2 = mv_destroy_source(mvSource);
                                if (err2 != MEDIA_VISION_ERROR_NONE)
@@ -2551,7 +2653,7 @@ int perform_face_detection()
                        unsigned long timeDiff = gettotalmillisec(diffspec);
                        printf("elapsed time : %lu(ms)\n", timeDiff);
                } break;
-               case 7: {
+               case 9: {
                        //perform destroy
                        if (engine_cfg) {
                                err = mv_destroy_engine_config(engine_cfg);