test: Add face detection with ARMNN
authorInki Dae <inki.dae@samsung.com>
Mon, 24 Feb 2020 07:03:21 +0000 (16:03 +0900)
committerInki Dae <inki.dae@samsung.com>
Tue, 14 Apr 2020 00:40:31 +0000 (09:40 +0900)
Change-Id: I66ad64dcc3861e37362422a5609ac798b04dd705
Signed-off-by: Inki Dae <inki.dae@samsung.com>
test/testsuites/inference/inference_test_suite.c

index 21ddfff60058a654b7289486af01bc5abc621ed1..186bfd532c2d764e143f82639323891531fc86b3 100644 (file)
@@ -1379,14 +1379,87 @@ int perform_tflite_mobilenetv1ssd_face(mv_engine_config_h *engine_cfg)
     return err;
 }
 
+int perform_armnn_mobilenetv1ssd_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 cofniguration.\n");
+            }
+        }
+        return err;
+    }
+
+    char *inputNodeName = "normalized_input_image_tensor";
+    char *outputNodeName[4] = {"TFLite_Detection_PostProcess",
+                                "TFLite_Detection_PostProcess:1",
+                                "TFLite_Detection_PostProcess:2",
+                                "TFLite_Detection_PostProcess:3"};
+
+    mv_engine_config_set_string_attribute(handle,
+                        MV_INFERENCE_MODEL_WEIGHT_FILE_PATH,
+                        FD_TFLITE_WEIGHT_PATH);
+
+    mv_engine_config_set_double_attribute(handle,
+                        MV_INFERENCE_MODEL_MEAN_VALUE,
+                        127.5);
+
+    mv_engine_config_set_double_attribute(handle,
+                        MV_INFERENCE_MODEL_STD_VALUE,
+                        127.5);
+
+    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_ARMNN);
+
+    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,
+                        300);
+
+    mv_engine_config_set_int_attribute(handle,
+                        MV_INFERENCE_INPUT_TENSOR_HEIGHT,
+                        300);
+
+    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,
+                        4);
+
+    *engine_cfg = handle;
+    return err;
+}
+
 int perform_face_detection()
 {
     int err = MEDIA_VISION_ERROR_NONE;
 
     int sel_opt = 0;
-    const int options[5] = {1, 2, 3, 4, 5};
+    const int options[5] = {1, 2, 3, 4, 5, 6};
     const *names[5] = { "Configuration",
                         "TFLite(CPU) + MobileNetV1 + SSD",
+                        "ARMNN(CPU) + MobileNetV1 + SSD",
                         "Prepare",
                         "Run",
                         "Back"};
@@ -1425,6 +1498,18 @@ int perform_face_detection()
         }
             break;
         case 3:
+        {
+            //perform TF Lite Mobilenetssd 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);
+            }
+
+            err = perform_armnn_mobilenetv1ssd_face(&engine_cfg);
+        }
+            break;
+        case 4:
         {
             // create - configure - prepare
             if (infer) {
@@ -1457,7 +1542,7 @@ int perform_face_detection()
             }
         }
             break;
-        case 4:
+        case 5:
         {
             if (mvSource) {
                 int err2 = mv_destroy_source(mvSource);
@@ -1493,7 +1578,7 @@ int perform_face_detection()
             err = mv_inference_face_detect(mvSource, infer, _face_detected_cb, NULL);
         }
             break;
-        case 5:
+        case 6:
         {
             //perform destroy
             if (engine_cfg) {