mv_machine_learning: code cleanup to mv_inference_open.cpp
authorInki Dae <inki.dae@samsung.com>
Mon, 23 May 2022 09:34:59 +0000 (18:34 +0900)
committerInki Dae <inki.dae@samsung.com>
Wed, 20 Jul 2022 05:16:57 +0000 (14:16 +0900)
[Version] : 0.23.1-0
[Issue type] : code cleanup

Cleaned up  mv_inference_open.cpp module by dropping redundant code
and doing code sliding.

Change-Id: Iab8eab6465503a8403f0b029b094bbd49765d89d
Signed-off-by: Inki Dae <inki.dae@samsung.com>
mv_machine_learning/inference/src/mv_inference_open.cpp
packaging/capi-media-vision.spec

index 6c644e11d254b41cda0cb6ddb0edb4609b6a75f1..a84151a3818eb7f6cc6e1e84d2cbbb40621bd1c3 100644 (file)
@@ -142,7 +142,6 @@ int mv_inference_configure_model_open(mv_inference_h infer,
        char *modelWeightFilePath = NULL;
        char *modelUserFilePath = NULL;
        char *modelMetaFilePath = NULL;
-       double modelMeanValue = 0.0;
        int backendType = 0;
        size_t userFileLength = 0;
 
@@ -170,45 +169,30 @@ int mv_inference_configure_model_open(mv_inference_h infer,
                goto release_model_weight_file_path;
        }
 
-       ret = mv_engine_config_get_string_attribute(
-                       engine_config, MV_INFERENCE_MODEL_META_FILE_PATH,
-                       &modelMetaFilePath);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to get model meta file path");
-               goto release_model_user_file_path;
-       }
-
-       ret = mv_engine_config_get_double_attribute(
-                       engine_config, MV_INFERENCE_MODEL_MEAN_VALUE, &modelMeanValue);
-       if (ret != MEDIA_VISION_ERROR_NONE) {
-               LOGE("Fail to get model mean value");
-               goto release_model_meta_file_path;
-       }
-
        ret = mv_engine_config_get_int_attribute(
                        engine_config, MV_INFERENCE_BACKEND_TYPE, &backendType);
        if (ret != MEDIA_VISION_ERROR_NONE) {
                LOGE("Fail to get inference backend type");
-               goto release_model_meta_file_path;
+               goto release_model_user_file_path;
        }
 
        if (!IsValidBackendType(backendType)) {
                LOGE("Invalid backend type(%d).", backendType);
                ret = MEDIA_VISION_ERROR_INVALID_PARAMETER;
-               goto release_model_meta_file_path;
+               goto release_model_user_file_path;
        }
 
        if (access(modelWeightFilePath, F_OK)) {
                LOGE("weightFilePath in [%s] ", modelWeightFilePath);
                ret = MEDIA_VISION_ERROR_INVALID_PATH;
-               goto release_model_meta_file_path;
+               goto release_model_user_file_path;
        }
 
        if (IsConfigFilePathRequired(pInfer->GetTargetType(), backendType)) {
                if (access(modelConfigFilePath, F_OK)) {
                        LOGE("modelConfigFilePath in [%s] ", modelConfigFilePath);
                        ret = MEDIA_VISION_ERROR_INVALID_PATH;
-                       goto release_model_meta_file_path;
+                       goto release_model_user_file_path;
                }
        }
 
@@ -217,13 +201,21 @@ int mv_inference_configure_model_open(mv_inference_h infer,
        if (userFileLength > 0 && access(modelUserFilePath, F_OK)) {
                LOGE("categoryFilePath in [%s] ", modelUserFilePath);
                ret = MEDIA_VISION_ERROR_INVALID_PATH;
-               goto release_model_meta_file_path;
+               goto release_model_user_file_path;
        }
 
        pInfer->ConfigureModelFiles(std::string(modelConfigFilePath),
                                                                std::string(modelWeightFilePath),
                                                                std::string(modelUserFilePath));
 
+       ret = mv_engine_config_get_string_attribute(
+                       engine_config, MV_INFERENCE_MODEL_META_FILE_PATH,
+                       &modelMetaFilePath);
+       if (ret != MEDIA_VISION_ERROR_NONE) {
+               LOGE("Fail to get model meta file path");
+               goto release_model_user_file_path;
+       }
+
        if (std::string(modelMetaFilePath).empty()) {
                LOGW("Skip ParseMetadata and run without Metadata");
                goto release_model_meta_file_path;
index 64010bc1862289a90c2d6b151442338f280f4852..6c430e25222b2010bcfa38f49cb263c1bdef4956 100644 (file)
@@ -1,6 +1,6 @@
 Name:        capi-media-vision
 Summary:     Media Vision library for Tizen Native API
-Version:     0.23.0
+Version:     0.23.1
 Release:     0
 Group:       Multimedia/Framework
 License:     Apache-2.0 and BSD-3-Clause