[testsuite] add additional hand model test config
authorTae-Young Chung <ty83.chung@samsung.com>
Fri, 17 Jul 2020 06:35:19 +0000 (15:35 +0900)
committerTae-Young Chung <ty83.chung@samsung.com>
Fri, 17 Jul 2020 06:35:29 +0000 (15:35 +0900)
Signed-off-by: Tae-Young Chung <ty83.chung@samsung.com>
test/testsuites/inference/inference_test_suite.c

index 03c59ee95776edc1c6fa4bb23ae448f18b3444ab..1f7532f8ee93e494ec998e20c72b5e8d5ccd0460 100644 (file)
        "/usr/share/capi-media-vision/models/PLD/tflite/pld-tflite-001.tflite"
 #define PLD_POSE_LABEL_PATH \
        "/usr/share/capi-media-vision/models/PLD/tflite/pose-label.txt"
+
+#define PLD_TFLITE_SRID_WEIGHT_PATH \
+       "/usr/share/capi-media-vision/models/PLD/tflite/pld-tflite-srid.tflite"
+#define PLD_POSE_LABEL_SRID_PATH \
+       "/usr/share/capi-media-vision/models/PLD/tflite/pose-label-srid.txt"
+
 #define PLD_MOTION_CAPTURE_FILE_PATH \
        "/usr/share/capi-media-vision/models/PLD/mocap/example.bvh"
 #define PLD_MOTION_CAPTURE_MAPPING_FILE_PATH \
@@ -2642,7 +2648,7 @@ int perform_facial_landmark_detection()
        return MEDIA_VISION_ERROR_NONE;
 }
 
-int perform_armnn_cpm_config(mv_engine_config_h *engine_cfg)
+int perform_tflite_cpm_config(mv_engine_config_h *engine_cfg)
 {
        int err = MEDIA_VISION_ERROR_NONE;
 
@@ -2705,14 +2711,78 @@ int perform_armnn_cpm_config(mv_engine_config_h *engine_cfg)
        return err;
 }
 
+int perform_tflite_srid_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 cofniguration.\n");
+                       }
+               }
+               return err;
+       }
+
+       char *inputNodeName = "image";
+       char *outputNodeName[] = { "Convolutional_Pose_Machine/stage_5_out" };
+
+       mv_engine_config_set_string_attribute(
+                       handle, MV_INFERENCE_MODEL_WEIGHT_FILE_PATH, PLD_TFLITE_SRID_WEIGHT_PATH);
+
+       mv_engine_config_set_int_attribute(handle, MV_INFERENCE_INPUT_DATA_TYPE,
+                                                                          MV_INFERENCE_DATA_FLOAT32);
+
+       mv_engine_config_set_string_attribute(
+                       handle, MV_INFERENCE_MODEL_USER_FILE_PATH, PLD_POSE_LABEL_SRID_PATH);
+
+       mv_engine_config_set_double_attribute(handle, MV_INFERENCE_MODEL_MEAN_VALUE,
+                                                                                 0.0);
+
+       mv_engine_config_set_double_attribute(handle, MV_INFERENCE_MODEL_STD_VALUE,
+                                                                                 1.0);
+
+       mv_engine_config_set_double_attribute(
+                       handle, MV_INFERENCE_CONFIDENCE_THRESHOLD, 0.3);
+
+       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);
+
+       mv_engine_config_set_int_attribute(handle, MV_INFERENCE_INPUT_TENSOR_WIDTH,
+                                                                          224);
+
+       mv_engine_config_set_int_attribute(handle, MV_INFERENCE_INPUT_TENSOR_HEIGHT,
+                                                                          224);
+
+       mv_engine_config_set_int_attribute(handle,
+                                                                          MV_INFERENCE_INPUT_TENSOR_CHANNELS, 3);
+
+       mv_engine_config_set_string_attribute(handle, MV_INFERENCE_INPUT_NODE_NAME,
+                                                                                 inputNodeName);
+
+       mv_engine_config_set_array_string_attribute(
+                       handle, MV_INFERENCE_OUTPUT_NODE_NAMES, outputNodeName, 1);
+
+       *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 };
        const *names[] = { "Configuration",
                                                "TFLITE(CPU) + CPM",
+                                               "TFLITE(CPU) + SRID",
                                                "Prepare",
                                                "Run",
                                                "Back" };
@@ -2737,16 +2807,26 @@ int perform_pose_landmark_detection()
                        err = perform_configuration(&engine_cfg);
                } break;
                case 2: {
-                       //perform SRID TweakCNN config
+                       //perform SRID
                        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_armnn_cpm_config(&engine_cfg);
+                       err = perform_tflite_cpm_config(&engine_cfg);
                } break;
                case 3: {
+                       //perform SRID 
+                       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_tflite_srid_config(&engine_cfg);
+               } break;
+               case 4: {
                        // create - configure - prepare
                        if (infer) {
                                int err2 = mv_inference_destroy(infer);
@@ -2777,7 +2857,7 @@ int perform_pose_landmark_detection()
                                break;
                        }
                } break;
-               case 4: {
+               case 5: {
                        if (mvSource) {
                                int err2 = mv_destroy_source(mvSource);
                                if (err2 != MEDIA_VISION_ERROR_NONE)
@@ -2824,7 +2904,7 @@ int perform_pose_landmark_detection()
                        unsigned long timeDiff = gettotalmillisec(diffspec);
                        printf("elapsed time : %lu(ms)\n", timeDiff);
                } break;
-               case 5: {
+               case 6: {
                        //perform destroy
                        if (engine_cfg) {
                                err = mv_destroy_engine_config(engine_cfg);