mv_machine_learning: change model path for new task group API
authorInki Dae <inki.dae@samsung.com>
Wed, 12 Apr 2023 08:19:50 +0000 (17:19 +0900)
committerKwanghoon Son <k.son@samsung.com>
Wed, 14 Jun 2023 02:14:28 +0000 (11:14 +0900)
[Issue type] : code cleanup

Changed default model path for new task group API.

We have introduced rpk package to release model relevant resource files
for each task group so the model files will be installed to different
path.

Change-Id: I70bfdb217a02c6ca2b5816d63f0ba84157ba3cb2
Signed-off-by: Inki Dae <inki.dae@samsung.com>
mv_machine_learning/face_recognition/include/face_recognition_type.h
mv_machine_learning/face_recognition/include/facenet.h
mv_machine_learning/face_recognition/meta/face_recognition.json
mv_machine_learning/face_recognition/src/facenet.cpp

index 29aaf10cc0c475a19dd6beba451c16698b695789..dc1aed74df9030c6c8381ffb7758e5aee4177601 100644 (file)
 #include <vector>
 
 /**
- * @brief Defines #MV_FACENET_MODEL_FILE_PATH
- *        to set the backbone model file path.
+ * @brief Defines #MV_FACENET_MODEL_DEFAULT_PATH to set the backbone model default path.
+ */
+#define MV_FACENET_MODEL_DEFAULT_PATH "FACENET_MODEL_DEFAULT_PATH"
+
+/**
+ * @brief Defines #MV_FACENET_MODEL_FILE_PATH to set the backbone model file path.
  * @details This model file is used to extract the feature vectors from a given face image data.
  */
-#define MV_FACENET_MODEL_FILE_PATH "FACENET_MODEL_FILE_PATH"
+#define MV_FACENET_MODEL_FILE_NAME "FACENET_MODEL_FILE_NAME"
 
 /**
- * @brief Defines #MV_FACENET_MODEL_META_FILE_PATH
- *        to set the backbone model meta file path.
+ * @brief Defines #MV_FACENET_MODEL_META_FILE_PATH to set the backbone model meta file path.
  * @details This model meta file is used to provide input and output tensor info of a given model file.
  */
-#define MV_FACENET_MODEL_META_FILE_PATH "FACENET_MODEL_META_FILE_PATH"
+#define MV_FACENET_MODEL_META_FILE_NAME "FACENET_MODEL_META_FILE_NAME"
 
 #define MV_FACENET_OUTPUT_TENSOR_NAME "FACENET_OUTPUT_TENSOR_NAME"
 
index 577a929095bc9eb117e61e081d6cc08398202cde..0fd375bcee32962eb261fab964a411e170ec5753 100644 (file)
@@ -41,8 +41,8 @@ protected:
        FacenetOutput _result;
        inference_engine_tensor_buffer *_outputTensorBuffer {};
        Preprocess _preprocess;
-       std::string _modelFilePath;
-       std::string _modelMetaFilePath;
+       std::string _modelFileName;
+       std::string _modelMetaFileName;
        std::string _facenetOutputTensorName;
        int _backendType {};
        int _targetDeviceType {};
index 36451aa47b45bbe17a2a3e62f59b7ac4389948a3..9759d300a103d27e985763ec086bd27698065401 100644 (file)
@@ -2,14 +2,19 @@
     "attributes":
     [
         {
-            "name"  : "FACENET_MODEL_FILE_PATH",
+            "name"  : "FACENET_MODEL_DEFAULT_PATH",
             "type"  : "string",
-            "value" : "/home/owner/media/res/face_recognition/backbone/facenet.tflite"
+            "value" : "/opt/usr/globalapps/mediavision.face.recognition/models/tflite/"
         },
         {
-            "name"  : "FACENET_MODEL_META_FILE_PATH",
+            "name"  : "FACENET_MODEL_FILE_NAME",
             "type"  : "string",
-            "value" : "/home/owner/media/res/face_recognition/backbone/facenet.json"
+            "value" : "facenet.tflite"
+        },
+        {
+            "name"  : "FACENET_MODEL_META_FILE_NAME",
+            "type"  : "string",
+            "value" : "facenet.json"
         },
         {
             "name"  : "FACE_RECOGNITION_DEFAULT_PATH",
index 3bc3c98814a6308f4dbb4641194cfb7df6f9be5c..28b0b468963d2a79a56bc5406916fdbbc2d6e83b 100644 (file)
@@ -55,25 +55,35 @@ void Facenet::parseMetaFile()
        if (ret != MEDIA_VISION_ERROR_NONE)
                throw InvalidOperation("Fail to get target device type.");
 
-       ret = _config->getStringAttribute(MV_FACENET_MODEL_FILE_PATH, &_modelFilePath);
+       string modelDefaultPath;
+
+       ret = _config->getStringAttribute(MV_FACENET_MODEL_DEFAULT_PATH, &modelDefaultPath);
        if (ret != MEDIA_VISION_ERROR_NONE)
-               throw InvalidOperation("Fail to get model file path.");
+               throw InvalidOperation("Fail to get model default path.");
 
-       ret = _config->getStringAttribute(MV_FACENET_MODEL_META_FILE_PATH, &_modelMetaFilePath);
+       ret = _config->getStringAttribute(MV_FACENET_MODEL_FILE_NAME, &_modelFileName);
        if (ret != MEDIA_VISION_ERROR_NONE)
-               throw InvalidOperation("Fail to get model meta file path.");
+               throw InvalidOperation("Fail to get model file name.");
+
+       _modelFileName = modelDefaultPath + _modelFileName;
+
+       ret = _config->getStringAttribute(MV_FACENET_MODEL_META_FILE_NAME, &_modelMetaFileName);
+       if (ret != MEDIA_VISION_ERROR_NONE)
+               throw InvalidOperation("Fail to get model meta file name.");
+
+       _modelMetaFileName = modelDefaultPath + _modelMetaFileName;
 
        ret = _config->getStringAttribute(MV_FACENET_OUTPUT_TENSOR_NAME, &_facenetOutputTensorName);
        if (ret != MEDIA_VISION_ERROR_NONE)
                throw InvalidOperation("Fail to get facenet output tensor name.");
 
-       if (_modelMetaFilePath.empty())
+       if (_modelMetaFileName.empty())
                throw InvalidOperation("Model meta file doesn't exist.");
 
-       if (!isJsonFile(_modelMetaFilePath))
+       if (!isJsonFile(_modelMetaFileName))
                throw InvalidOperation("Model meta file should be json.");
 
-       _parser->load(_modelMetaFilePath);
+       _parser->load(_modelMetaFileName);
 }
 
 void Facenet::configure()
@@ -93,7 +103,7 @@ void Facenet::prepare()
        if (ret != MEDIA_VISION_ERROR_NONE)
                throw InvalidOperation("Fail to configure output tensor info from meta file.");
 
-       _inference->configureModelFiles("", _modelFilePath, "");
+       _inference->configureModelFiles("", _modelFileName, "");
 
        // Request to load model files to a backend engine.
        ret = _inference->load();