Update testsuite to run pose landmark models with meta files 27/258527/2
authorTae-Young Chung <ty83.chung@samsung.com>
Thu, 20 May 2021 01:30:02 +0000 (10:30 +0900)
committerTae-Young Chung <ty83.chung@samsung.com>
Thu, 1 Jul 2021 02:08:02 +0000 (11:08 +0900)
Change-Id: I62307b534309ecbbf0c4e97ff2029e62fbdaea44
Signed-off-by: Tae-Young Chung <ty83.chung@samsung.com>
meta-template/pld_cpm_192x192.json [new file with mode: 0644]
meta-template/pld_mobilenet_v1_posenet_multi_257x257.json [new file with mode: 0644]
test/testsuites/machine_learning/inference/inference_test_suite.c

diff --git a/meta-template/pld_cpm_192x192.json b/meta-template/pld_cpm_192x192.json
new file mode 100644 (file)
index 0000000..6a81e50
--- /dev/null
@@ -0,0 +1,51 @@
+{
+    "inputmetadata" :
+    {
+        "tensor_info" : [
+            {
+                "name" : "image",
+                "shape_type" : 1,
+                "shape_dims" : [ 1, 192, 192, 3],
+                "data_type" : 0,
+                "color_space" : "RGB888"
+            }
+        ],
+        "preprocess" : [
+            {
+                "normalization" : [
+                    {
+                        "mean" : [0.0, 0.0, 0.0],
+                        "std" : [1.0, 1.0, 1.0]
+                    }
+                ]
+            }
+        ]
+    },
+    "outputmetadata" :
+    {
+        "score" : [
+            {
+                "name" : "Convolutional_Pose_Machine/stage_5_out",
+                "index" : [-1, 1, 1, 1],
+                "top_number" : 1 ,
+                "threshold" : 0.3,
+                "score_type" : 0
+            }
+        ],
+        "landmark" : [
+            {
+                "name" : "Convolutional_Pose_Machine/stage_5_out",
+                "index" : [-1, 1, 1, 1],
+                "landmark_type" : 0,
+                "decoding_type" : 1,
+                "decoding_info" :
+                {
+                    "heatmap" :
+                     {
+                         "shape_type": 1
+                     }
+                }
+            }
+        ]
+    }
+}
diff --git a/meta-template/pld_mobilenet_v1_posenet_multi_257x257.json b/meta-template/pld_mobilenet_v1_posenet_multi_257x257.json
new file mode 100644 (file)
index 0000000..93084ce
--- /dev/null
@@ -0,0 +1,142 @@
+{
+    "inputmetadata" :
+    {
+        "tensor_info" : [
+            {
+                "name" : "sub_2",
+                "shape_type" : 1,
+                "shape_dims" : [ 1, 257, 257, 3],
+                "data_type" : 0,
+                "color_space" : "RGB888"
+            }
+        ],
+        "preprocess" : [
+            {
+                "normalization" : [
+                    {
+                        "mean" : [0.0, 0.0, 0.0],
+                        "std" : [255.0, 255.0, 255.0]
+                    }
+                ]
+            }
+        ]
+    },
+    "outputmetadata" :
+    {
+        "score" : [
+            {
+                "name" : "MobilenetV1/heatmap_2/BiasAdd",
+                "index" : [-1, 1, 1, 1],
+                "top_number" : 1,
+                "threshold" : 0.65,
+                "score_type" : 1
+            }
+        ],
+        "landmark" : [
+            {
+                "name" : "MobilenetV1/heatmap_2/BiasAdd",
+                "index" : [-1, 1, 1, 1],
+                "landmark_type" : 1,
+                "decoding_type" : 2,
+                "decoding_info" :
+                {
+                    "heatmap" :
+                     {
+                         "shape_type" : 1,
+                         "nms_radius" : 50.0
+                     }
+                }
+            }
+        ],
+        "offset" : [
+            {
+                "name" : "MobilenetV1/offset_2/BiasAdd",
+                "index" : [-1, 1, 1, 1],
+                "shape_type" : 1,
+                "dim_type" : 2
+            }
+        ],
+        "displacement" : [
+            {
+                "name" : "MobilenetV1/displacement_fwd_2/BiasAdd",
+                "index" : [-1, 1, 1, 1],
+                "shape_type" : 1,
+                "dim_type" : 2,
+                "type" : 0
+            },
+            {
+                "name" : "MobilenetV1/displacement_bwd_2/BiasAdd",
+                "index" : [-1, 1, 1, 1],
+                "shape_type" : 1,
+                "dim_type" : 2,
+                "type" : 1
+            }
+        ],
+        "edgemap" : [
+            {
+                "parent": 0,
+                "child": 1
+            },
+            {
+                "parent": 1,
+                "child": 3
+            },
+            {
+                "parent": 0,
+                "child": 2
+            },
+            {
+                "parent": 2,
+                "child": 4
+            },
+            {
+                "parent": 0,
+                "child": 5
+            },
+            {
+                "parent": 5,
+                "child": 7
+            },
+            {
+                "parent": 7,
+                "child": 9
+            },
+            {
+                "parent": 5,
+                "child": 11
+            },
+            {
+                "parent": 11,
+                "child": 13
+            },
+            {
+                "parent": 13,
+                "child": 15
+            },
+            {
+                "parent": 0,
+                "child": 6
+            },
+            {
+                "parent": 6,
+                "child": 8
+            },
+            {
+                "parent": 8,
+                "child": 10
+            },
+            {
+                "parent": 6,
+                "child": 12
+            },
+            {
+                "parent": 12,
+                "child": 14
+            },
+            {
+                "parent": 14,
+                "child": 16
+            }
+        ]
+    }
+}
index 877e0226df989e4ab6ea3b3d8bf33334af8f2727..579e9f10895da5170fc01f372a5ea29de4833a8a 100644 (file)
 #define PLD_MOTION_CAPTURE_MAPPING_FILE_PATH \
        "/usr/share/capi-media-vision/models/PLD/mocap/example-mocap-mapping.txt"
 
+/*
+ * Hosted models
+ */
+#define PLD_TFLITE_WEIGHT_CPM_192_PATH \
+       "/usr/share/capi-media-vision/models/PLD/tflite/pld_cpm_192x192.tflite"
+
+#define PLD_TFLITE_WEIGHT_MOBILENET_V1_POSENET_257_PATH \
+       "/usr/share/capi-media-vision/models/PLD/tflite/pld_mobilenet_v1_posenet_multi_257x257.tflite"
+#define PLD_LABEL_MOBILENET_V1_POSENET_257_PATH \
+       "/usr/share/capi-media-vision/models/PLD/tflite/pld_mobilenet_v1_posenet_multi_label.txt"
+
 /******
  * Public model:
  *  IC: mobilenet caffe, tf?
@@ -3180,15 +3191,87 @@ int perform_armnn_cpm_config(mv_engine_config_h *engine_cfg)
        return err;
 }
 
+int perform_hosted_tflite_cpm_192_config(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_CPM_192_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_mobilenet_v1_posenet_257_config(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_MOBILENET_V1_POSENET_257_PATH);
+
+/*
+       mv_engine_config_set_string_attribute(
+                                       handle, MV_INFERENCE_MODEL_USER_FILE_PATH,
+                                       PLD_LABEL_MOBILENET_V1_POSENET_257_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;
 
        int sel_opt = 0;
-       const int options[] = { 1, 2, 3, 4, 5 };
+       const int options[] = { 1, 2, 3, 4, 5, 6, 7 };
        const char *names[] = { "Configuration",
                                                "TFLITE(CPU) + CPM",
+                                               "Hosted: TFLITE(CPU) + CPM",
+                                               "Hosted: TFLITE(CPU) + MOBILENET_V1_POSENET",
                                                "Prepare",
                                                "Run",
                                                "Back" };
@@ -3213,7 +3296,7 @@ int perform_pose_landmark_detection()
                        err = perform_configuration(&engine_cfg);
                } break;
                case 2: {
-                       //perform SRID TweakCNN config
+                       //perform TweakCNN config
                        if (engine_cfg) {
                                int err2 = mv_destroy_engine_config(engine_cfg);
                                if (err2 != MEDIA_VISION_ERROR_NONE)
@@ -3223,6 +3306,26 @@ int perform_pose_landmark_detection()
                        err = perform_armnn_cpm_config(&engine_cfg);
                } break;
                case 3: {
+                       //perform cpm 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_cpm_192_config(&engine_cfg);
+               } break;
+               case 4: {
+                       //perform mobilenet-v1 posenet 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_mobilenet_v1_posenet_257_config(&engine_cfg);
+               } break;
+               case 5: {
                        // create - configure - prepare
                        if (infer) {
                                int err2 = mv_inference_destroy(infer);
@@ -3253,7 +3356,7 @@ int perform_pose_landmark_detection()
                                break;
                        }
                } break;
-               case 4: {
+               case 6: {
                        if (mvSource) {
                                int err2 = mv_destroy_source(mvSource);
                                if (err2 != MEDIA_VISION_ERROR_NONE)
@@ -3300,7 +3403,7 @@ int perform_pose_landmark_detection()
                        unsigned long timeDiff = gettotalmillisec(diffspec);
                        printf("elapsed time : %lu(ms)\n", timeDiff);
                } break;
-               case 5: {
+               case 7: {
                        //perform destroy
                        if (engine_cfg) {
                                err = mv_destroy_engine_config(engine_cfg);