test: Add movenet for pose detection 98/261698/1
authorKwang Son <k.son@samsung.com>
Fri, 23 Jul 2021 02:19:11 +0000 (22:19 -0400)
committerKwang Son <k.son@samsung.com>
Fri, 23 Jul 2021 02:20:01 +0000 (22:20 -0400)
Change-Id: Iba6c9fe101b0d3f0976aac41fc94ebd332d218e6
Signed-off-by: Kwang Son <k.son@samsung.com>
test/testsuites/machine_learning/inference/inference_test_suite.c

index 24e1f03..50b19eb 100644 (file)
 #define PLD_LABEL_MOBILENET_V1_POSENET_257_PATH \
        "/usr/share/capi-media-vision/models/PLD/tflite/pld_mobilenet_v1_posenet_multi_label.txt"
 
+// https://tfhub.dev/google/lite-model/movenet/singlepose/lightning/tflite/int8/4
+#define PLD_TFLITE_WEIGHT_INT8_MOVENET_PATH \
+       "/usr/share/capi-media-vision/models/PLD/tflite/pld_int8_movenet.tflite"
+
 /******
  * Public model:
  *  IC: mobilenet caffe, tf?
@@ -3302,6 +3306,39 @@ int perform_hosted_tflite_mobilenet_v1_posenet_257_config(mv_engine_config_h *en
        return err;
 }
 
+int perform_hosted_tflite_int8_movenet(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,
+                                       PLD_TFLITE_WEIGHT_INT8_MOVENET_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_pose_landmark_detection()
 {
        int err = MEDIA_VISION_ERROR_NONE;
@@ -3311,6 +3348,7 @@ int perform_pose_landmark_detection()
                                                "TFLITE(CPU) + CPM",
                                                "Hosted: TFLITE(CPU) + CPM",
                                                "Hosted: TFLITE(CPU) + MOBILENET_V1_POSENET",
+                                               "Hosted: TFLITE(CPU) + INT8_MOVENET",
                                                "Prepare",
                                                "Run",
                                                "Back" };
@@ -3364,6 +3402,16 @@ int perform_pose_landmark_detection()
                        err = perform_hosted_tflite_mobilenet_v1_posenet_257_config(&engine_cfg);
                } break;
                case 5: {
+                       //perform int8 movenet
+                       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_mobilenet_v1_posenet_257_config(&engine_cfg);
+               } break;
+               case 6: {
                        // create - configure - prepare
                        if (infer) {
                                int err2 = mv_inference_destroy(infer);
@@ -3394,7 +3442,7 @@ int perform_pose_landmark_detection()
                                break;
                        }
                } break;
-               case 6: {
+               case 7: {
                        if (mvSource) {
                                int err2 = mv_destroy_source(mvSource);
                                if (err2 != MEDIA_VISION_ERROR_NONE)
@@ -3441,7 +3489,7 @@ int perform_pose_landmark_detection()
                        unsigned long timeDiff = gettotalmillisec(diffspec);
                        printf("elapsed time : %lu(ms)\n", timeDiff);
                } break;
-               case 7: {
+               case 8: {
                        //perform destroy
                        if (engine_cfg) {
                                err = mv_destroy_engine_config(engine_cfg);