#define MV_MODEL_LABEL_FILE_NAME "MODEL_LABEL_FILE_NAME"
/**
+ * @brief Defines #MV_MODEL_CONFIDENCE_THRESHOLD to set inference
+ * models's confidence threshold value of the engine configuration.
+ * @details The file includes inference model's confidence threshold value.
+ *
+ * @since_tizen 8.0
+ */
+#define MV_MODEL_CONFIDENCE_THRESHOLD "CONFIDENCE_THRESHOLD"
+
+/**
* @brief Defines #MV_BACKEND_TYPE
* to set inference backend engine type. In default, tensorflow lite is used.
*
throw InvalidOperation("Fail to get model label file path");
_modelLabelFilePath = _modelDefaultPath + _modelLabelFilePath;
+
+ ret = config->getDoubleAttribute(MV_MODEL_CONFIDENCE_THRESHOLD, &_confidence_threshold);
+ if (ret != MEDIA_VISION_ERROR_NONE)
+ LOGW("threshold value doesn't exist.");
}
void MachineLearningConfig::loadMetaFile(unique_ptr<MetaParser> parser)
}
}
-}
\ No newline at end of file
+}
endif()
add_library(${PROJECT_NAME} SHARED ${MV_IMAGE_CLASSIFICATION_SOURCE_LIST})
-target_link_libraries(${PROJECT_NAME} ${MV_COMMON_LIB_NAME} ${OpenCV_LIBS} ${${PROJECT_NAME}_DEP_LIBRARIES} mv_inference)
+target_link_libraries(${PROJECT_NAME} ${MV_COMMON_LIB_NAME} ${OpenCV_LIBS} ${${PROJECT_NAME}_DEP_LIBRARIES} mv_ml_common mv_inference)
target_include_directories(${PROJECT_NAME} PRIVATE include ../inference/include ../common/include ../meta/include)
install(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR})
install(
#include "Inference.h"
#include "image_classification_type.h"
#include "MetaParser.h"
+#include "machine_learning_config.h"
#include "ImageClassificationParser.h"
-#include "image_classification_config.h"
#include "machine_learning_preprocess.h"
#include "async_manager.h"
protected:
std::unique_ptr<mediavision::inference::Inference> _inference;
- std::shared_ptr<ImageClassificationConfig> _config;
+ std::shared_ptr<MachineLearningConfig> _config;
Preprocess _preprocess;
std::vector<std::string> _labels;
std::vector<std::string> _valid_backends;
virtual ImageClassificationResult &result() = 0;
public:
- explicit ImageClassification(std::shared_ptr<ImageClassificationConfig> config);
+ explicit ImageClassification(std::shared_ptr<MachineLearningConfig> config);
virtual ~ImageClassification() = default;
void preDestroy();
#include "EngineConfig.h"
#include "itask.h"
-#include "image_classification_config.h"
+#include "machine_learning_config.h"
#include "image_classification_default.h"
namespace mediavision
{
private:
std::unique_ptr<ImageClassification> _image_classification;
- std::shared_ptr<ImageClassificationConfig> _config;
+ std::shared_ptr<MachineLearningConfig> _config;
T _source;
const std::string _config_file_name = "image_classification.json";
+++ /dev/null
-/**
- * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __IMAGE_CLASSIFICATION_CONFIG_H__
-#define __IMAGE_CLASSIFICATION_CONFIG_H__
-
-#include <mv_common.h>
-#include "mv_private.h"
-#include "EngineConfig.h"
-
-#include "MetaParser.h"
-#include "image_classification_type.h"
-
-namespace mediavision
-{
-namespace machine_learning
-{
-class ImageClassificationConfig
-{
-private:
- std::unique_ptr<MetaParser> _parser;
- std::string _modelFilePath;
- std::string _modelMetaFilePath;
- std::string _modelDefaultPath;
- std::string _modelLabelFilePath;
- int _backendType {};
- int _targetDeviceType {};
-
-public:
- ImageClassificationConfig();
- virtual ~ImageClassificationConfig() = default;
-
- void setUserModel(const std::string &model_file, const std::string &meta_file, const std::string &label_file);
- void parseConfigFile(const std::string &configFilePath);
- void parseMetaFile();
- void setBackendType(int backend_type);
- void setTargetDeviceType(int device_type);
- const std::string &getModelFilePath() const;
- const std::string &getLabelFilePath() const;
- MetaMap &getInputMetaMap() const;
- MetaMap &getOutputMetaMap() const;
- int getBackendType() const;
- int getTargetDeviceType() const;
- void loadMetaFile();
-};
-
-} // machine_learning
-} // mediavision
-
-#endif
\ No newline at end of file
ImageClassificationResult _result;
public:
- ImageClassificationDefault(std::shared_ptr<ImageClassificationConfig> config);
+ ImageClassificationDefault(std::shared_ptr<MachineLearningConfig> config);
~ImageClassificationDefault();
ImageClassificationResult &result() override;
"value" : "image-classification-001.tflite"
},
{
- "name" : "LABEL_FILE_NAME",
+ "name" : "DEFAULT_MODEL_NAME",
+ "type" : "string",
+ "value" : ""
+ },
+ {
+ "name" : "MODEL_LABEL_FILE_NAME",
"type" : "string",
"value" : "image-classification-label.txt"
},
{
- "name" : "META_FILE_NAME",
+ "name" : "MODEL_META_FILE_NAME",
"type" : "string",
"value" : "image-classification-001.json"
},
{
namespace machine_learning
{
-ImageClassification::ImageClassification(shared_ptr<ImageClassificationConfig> config) : _config(config)
+ImageClassification::ImageClassification(std::shared_ptr<MachineLearningConfig> config) : _config(config)
{
_inference = make_unique<Inference>();
- loadLabel();
}
void ImageClassification::preDestroy()
void ImageClassification::configure()
{
+ _config->loadMetaFile(make_unique<ImageClassificationParser>());
+ loadLabel();
+
int ret = _inference->bind(_config->getBackendType(), _config->getTargetDeviceType());
if (ret != MEDIA_VISION_ERROR_NONE)
throw InvalidOperation("Fail to bind a backend engine.");
{
template<typename T, typename V> ImageClassificationAdapter<T, V>::ImageClassificationAdapter() : _source()
{
- _config = make_shared<ImageClassificationConfig>();
+ _config = make_shared<MachineLearningConfig>();
_config->parseConfigFile(_config_file_name);
create();
template<typename T, typename V> void ImageClassificationAdapter<T, V>::create()
{
- // reallocate the parser and load the meta file
- _config->loadMetaFile();
-
_image_classification = make_unique<ImageClassificationDefault>(_config);
}
+++ /dev/null
-/**
- * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "machine_learning_exception.h"
-#include "mv_image_classification_config.h"
-#include "ImageClassificationParser.h"
-#include "image_classification_config.h"
-
-using namespace std;
-using namespace MediaVision::Common;
-using namespace mediavision::machine_learning;
-using namespace mediavision::machine_learning::exception;
-
-namespace mediavision
-{
-namespace machine_learning
-{
-ImageClassificationConfig::ImageClassificationConfig()
-{}
-
-void ImageClassificationConfig::setBackendType(int backend_type)
-{
- _backendType = backend_type;
-}
-
-void ImageClassificationConfig::setTargetDeviceType(int device_type)
-{
- _targetDeviceType = device_type;
-}
-
-const std::string &ImageClassificationConfig::getModelFilePath() const
-{
- return _modelFilePath;
-}
-
-const std::string &ImageClassificationConfig::getLabelFilePath() const
-{
- return _modelLabelFilePath;
-}
-
-MetaMap &ImageClassificationConfig::getInputMetaMap() const
-{
- return _parser->getInputMetaMap();
-}
-
-MetaMap &ImageClassificationConfig::getOutputMetaMap() const
-{
- return _parser->getOutputMetaMap();
-}
-
-int ImageClassificationConfig::getBackendType() const
-{
- return _backendType;
-}
-
-int ImageClassificationConfig::getTargetDeviceType() const
-{
- return _targetDeviceType;
-}
-
-void ImageClassificationConfig::setUserModel(const string &model_file, const string &meta_file,
- const string &label_file)
-{
- if (!model_file.empty())
- _modelFilePath = _modelDefaultPath + model_file;
- if (!meta_file.empty())
- _modelMetaFilePath = _modelDefaultPath + meta_file;
- if (!label_file.empty())
- _modelLabelFilePath = _modelDefaultPath + label_file;
-}
-
-static bool IsJsonFile(const string &fileName)
-{
- return (!fileName.substr(fileName.find_last_of(".") + 1).compare("json"));
-}
-
-void ImageClassificationConfig::parseConfigFile(const std::string &configFilePath)
-{
- auto config = make_unique<EngineConfig>(MV_CONFIG_PATH + configFilePath);
-
- int ret = MEDIA_VISION_ERROR_NONE;
-
- if (_backendType == MV_INFERENCE_BACKEND_NONE) {
- ret = config->getIntegerAttribute(MV_IMAGE_CLASSIFICATION_BACKEND_TYPE, &_backendType);
- if (ret != MEDIA_VISION_ERROR_NONE)
- throw InvalidOperation("Fail to get backend engine type.");
- }
-
- if (_targetDeviceType == MV_INFERENCE_TARGET_DEVICE_NONE) {
- ret = config->getIntegerAttribute(MV_IMAGE_CLASSIFICATION_TARGET_DEVICE_TYPE, &_targetDeviceType);
- if (ret != MEDIA_VISION_ERROR_NONE)
- throw InvalidOperation("Fail to get target device type.");
- }
-
- ret = config->getStringAttribute(MV_IMAGE_CLASSIFICATION_MODEL_DEFAULT_PATH, &_modelDefaultPath);
- if (ret != MEDIA_VISION_ERROR_NONE)
- throw InvalidOperation("Fail to get model default path");
-
- ret = config->getStringAttribute(MV_IMAGE_CLASSIFICATION_MODEL_FILE_NAME, &_modelFilePath);
- if (ret != MEDIA_VISION_ERROR_NONE)
- throw InvalidOperation("Fail to get model file path");
-
- _modelFilePath = _modelDefaultPath + _modelFilePath;
- LOGI("model file path = %s", _modelFilePath.c_str());
-
- ret = config->getStringAttribute(MV_IMAGE_CLASSIFICATION_MODEL_META_FILE_NAME, &_modelMetaFilePath);
- if (ret != MEDIA_VISION_ERROR_NONE)
- throw InvalidOperation("Fail to get model meta file path");
-
- if (_modelMetaFilePath.empty())
- throw InvalidOperation("Model meta file doesn't exist.");
-
- if (!IsJsonFile(_modelMetaFilePath))
- throw InvalidOperation("Model meta file should be json");
-
- _modelMetaFilePath = _modelDefaultPath + _modelMetaFilePath;
- LOGI("meta file path = %s", _modelMetaFilePath.c_str());
-
- ret = config->getStringAttribute(MV_IMAGE_CLASSIFICATION_MODEL_LABEL_FILE_NAME, &_modelLabelFilePath);
- if (ret != MEDIA_VISION_ERROR_NONE)
- throw InvalidOperation("Fail to get label file path");
-
- if (_modelLabelFilePath.empty()) {
- LOGW("Label doesn't exist.");
- return;
- }
-
- _modelLabelFilePath = _modelDefaultPath + _modelLabelFilePath;
- LOGI("label file path = %s", _modelLabelFilePath.c_str());
-}
-
-void ImageClassificationConfig::loadMetaFile()
-{
- _parser = make_unique<ImageClassificationParser>();
- _parser->load(_modelMetaFilePath);
-}
-
-}
-}
{
namespace machine_learning
{
-ImageClassificationDefault::ImageClassificationDefault(shared_ptr<ImageClassificationConfig> config)
+ImageClassificationDefault::ImageClassificationDefault(shared_ptr<MachineLearningConfig> config)
: ImageClassification(config), _result()
{}
endif()
add_library(${PROJECT_NAME} SHARED ${MV_LANDMARK_DETECTION_SOURCE_LIST})
-target_link_libraries(${PROJECT_NAME} ${MV_COMMON_LIB_NAME} ${OpenCV_LIBS} ${${PROJECT_NAME}_DEP_LIBRARIES} mv_inference)
+target_link_libraries(${PROJECT_NAME} ${MV_COMMON_LIB_NAME} ${OpenCV_LIBS} ${${PROJECT_NAME}_DEP_LIBRARIES} mv_ml_common mv_inference)
target_include_directories(${PROJECT_NAME} PRIVATE include ../inference/include ../common/include ../meta/include)
install(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR})
install(
#include "EngineConfig.h"
#include "itask.h"
-#include "landmark_detection_config.h"
+#include "machine_learning_config.h"
#include "fld_tweak_cnn.h"
namespace mediavision
{
private:
std::unique_ptr<LandmarkDetection> _landmark_detection;
- std::shared_ptr<LandmarkDetectionConfig> _config;
+ std::shared_ptr<MachineLearningConfig> _config;
T _source;
const std::string _config_file_name = "facial_landmark.json";
LandmarkDetectionResult _result;
public:
- FldTweakCnn(LandmarkDetectionTaskType task_type, std::shared_ptr<LandmarkDetectionConfig> config);
+ FldTweakCnn(LandmarkDetectionTaskType task_type, std::shared_ptr<MachineLearningConfig> config);
~FldTweakCnn();
LandmarkDetectionResult &result() override;
#include "landmark_detection_type.h"
#include "MetaParser.h"
#include "LandmarkDetectionParser.h"
-#include "landmark_detection_config.h"
+#include "machine_learning_config.h"
#include "machine_learning_preprocess.h"
#include "async_manager.h"
protected:
std::unique_ptr<mediavision::inference::Inference> _inference;
- std::shared_ptr<LandmarkDetectionConfig> _config;
+ std::shared_ptr<MachineLearningConfig> _config;
std::vector<std::string> _labels;
std::vector<std::string> _valid_backends;
std::vector<std::string> _valid_devices;
virtual LandmarkDetectionResult &result() = 0;
public:
- LandmarkDetection(LandmarkDetectionTaskType task_type, std::shared_ptr<LandmarkDetectionConfig> config);
+ LandmarkDetection(LandmarkDetectionTaskType task_type, std::shared_ptr<MachineLearningConfig> config);
virtual ~LandmarkDetection() = default;
void preDestroy();
LandmarkDetectionTaskType getTaskType();
+++ /dev/null
-/**
- * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __LANDMARK_DETECTION_CONFIG_H__
-#define __LANDMARK_DETECTION_CONFIG_H__
-
-#include <mv_common.h>
-#include "mv_private.h"
-#include "EngineConfig.h"
-
-#include "MetaParser.h"
-#include "landmark_detection_type.h"
-
-namespace mediavision
-{
-namespace machine_learning
-{
-class LandmarkDetectionConfig
-{
-private:
- std::unique_ptr<MetaParser> _parser;
- std::string _defaultModelName;
- std::string _modelFilePath;
- std::string _modelMetaFilePath;
- std::string _modelDefaultPath;
- std::string _modelLabelFilePath;
- int _backendType {};
- int _targetDeviceType {};
- double _confidence_threshold {};
-
-public:
- LandmarkDetectionConfig();
- virtual ~LandmarkDetectionConfig() = default;
-
- void setUserModel(const std::string &model_file, const std::string &meta_file, const std::string &label_file);
- void parseConfigFile(const std::string &configFilePath);
- void parseMetaFile();
- void setBackendType(int backend_type);
- void setTargetDeviceType(int device_type);
- const std::string &getDefaultModelName() const;
- const std::string &getModelFilePath() const;
- const std::string &getLabelFilePath() const;
- MetaMap &getInputMetaMap() const;
- MetaMap &getOutputMetaMap() const;
- double getConfidenceThreshold() const;
- int getBackendType() const;
- int getTargetDeviceType() const;
- void loadMetaFile();
-};
-
-} // machine_learning
-} // mediavision
-
-#endif
\ No newline at end of file
LandmarkDetectionResult _result;
public:
- PldCpm(LandmarkDetectionTaskType task_type, std::shared_ptr<LandmarkDetectionConfig> config);
+ PldCpm(LandmarkDetectionTaskType task_type, std::shared_ptr<MachineLearningConfig> config);
~PldCpm();
LandmarkDetectionResult &result() override;
#include "EngineConfig.h"
#include "itask.h"
-#include "landmark_detection_config.h"
+#include "machine_learning_config.h"
#include "pld_cpm.h"
namespace mediavision
{
private:
std::unique_ptr<LandmarkDetection> _landmark_detection;
- std::shared_ptr<LandmarkDetectionConfig> _config;
+ std::shared_ptr<MachineLearningConfig> _config;
T _source;
const std::string _config_file_name = "pose_landmark.json";
"value" : "FLD_TWEAK_CNN"
},
{
- "name" : "META_FILE_NAME",
+ "name" : "MODEL_META_FILE_NAME",
"type" : "string",
"value" : "fld_tweakcnn_128x128.json"
},
{
- "name" : "LABEL_FILE_NAME",
+ "name" : "MODEL_LABEL_FILE_NAME",
"type" : "string",
"value" : ""
},
"value" : "PLD_CPM"
},
{
- "name" : "META_FILE_NAME",
+ "name" : "MODEL_META_FILE_NAME",
"type" : "string",
"value" : "pld_cpm_192x192.json"
},
{
- "name" : "LABEL_FILE_NAME",
+ "name" : "MODEL_LABEL_FILE_NAME",
"type" : "string",
"value" : ""
},
{
template<typename T, typename V> FacialLandmarkAdapter<T, V>::FacialLandmarkAdapter() : _source()
{
- _config = make_shared<LandmarkDetectionConfig>();
+ _config = make_shared<MachineLearningConfig>();
_config->parseConfigFile(_config_file_name);
LandmarkDetectionTaskType model_type = convertToTaskType(_config->getDefaultModelName());
return;
}
- // if model name is changed by user then reallocate the parser and reload the meta file corresponding to the model name.
- _config->loadMetaFile();
-
if (task_type == LandmarkDetectionTaskType::FLD_TWEAK_CNN)
_landmark_detection = make_unique<FldTweakCnn>(task_type, _config);
}
{
namespace machine_learning
{
-FldTweakCnn::FldTweakCnn(LandmarkDetectionTaskType task_type, std::shared_ptr<LandmarkDetectionConfig> config)
+FldTweakCnn::FldTweakCnn(LandmarkDetectionTaskType task_type, std::shared_ptr<MachineLearningConfig> config)
: LandmarkDetection(task_type, config), _result()
{}
{
namespace machine_learning
{
-LandmarkDetection::LandmarkDetection(LandmarkDetectionTaskType task_type, shared_ptr<LandmarkDetectionConfig> config)
+LandmarkDetection::LandmarkDetection(LandmarkDetectionTaskType task_type, shared_ptr<MachineLearningConfig> config)
: _task_type(task_type), _config(config)
{
_inference = make_unique<Inference>();
- loadLabel();
}
void LandmarkDetection::preDestroy()
void LandmarkDetection::configure()
{
+ _config->loadMetaFile(make_unique<LandmarkDetectionParser>(static_cast<int>(_task_type)));
+ loadLabel();
+
int ret = _inference->bind(_config->getBackendType(), _config->getTargetDeviceType());
if (ret != MEDIA_VISION_ERROR_NONE)
throw InvalidOperation("Fail to bind a backend engine.");
+++ /dev/null
-/**
- * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "machine_learning_exception.h"
-#include "mv_landmark_detection_config.h"
-#include "LandmarkDetectionParser.h"
-#include "landmark_detection_config.h"
-
-using namespace std;
-using namespace MediaVision::Common;
-using namespace mediavision::machine_learning;
-using namespace mediavision::machine_learning::exception;
-
-namespace mediavision
-{
-namespace machine_learning
-{
-LandmarkDetectionConfig::LandmarkDetectionConfig()
-{}
-
-void LandmarkDetectionConfig::setBackendType(int backend_type)
-{
- _backendType = backend_type;
-}
-
-void LandmarkDetectionConfig::setTargetDeviceType(int device_type)
-{
- _targetDeviceType = device_type;
-}
-
-const std::string &LandmarkDetectionConfig::getDefaultModelName() const
-{
- return _defaultModelName;
-}
-
-const std::string &LandmarkDetectionConfig::getModelFilePath() const
-{
- return _modelFilePath;
-}
-
-const std::string &LandmarkDetectionConfig::getLabelFilePath() const
-{
- return _modelLabelFilePath;
-}
-
-MetaMap &LandmarkDetectionConfig::getInputMetaMap() const
-{
- return _parser->getInputMetaMap();
-}
-
-MetaMap &LandmarkDetectionConfig::getOutputMetaMap() const
-{
- return _parser->getOutputMetaMap();
-}
-
-double LandmarkDetectionConfig::getConfidenceThreshold() const
-{
- return _confidence_threshold;
-}
-
-int LandmarkDetectionConfig::getBackendType() const
-{
- return _backendType;
-}
-
-int LandmarkDetectionConfig::getTargetDeviceType() const
-{
- return _targetDeviceType;
-}
-
-void LandmarkDetectionConfig::setUserModel(const string &model_file, const string &meta_file, const string &label_file)
-{
- if (!model_file.empty())
- _modelFilePath = _modelDefaultPath + model_file;
- if (!meta_file.empty())
- _modelMetaFilePath = _modelDefaultPath + meta_file;
- if (!label_file.empty())
- _modelLabelFilePath = _modelDefaultPath + label_file;
-}
-
-static bool IsJsonFile(const string &fileName)
-{
- return (!fileName.substr(fileName.find_last_of(".") + 1).compare("json"));
-}
-
-void LandmarkDetectionConfig::parseConfigFile(const std::string &configFilePath)
-{
- auto config = make_unique<EngineConfig>(MV_CONFIG_PATH + configFilePath);
-
- int ret = config->getStringAttribute(MV_LANDMARK_DETECTION_DEFAULT_MODEL_NAME, &_defaultModelName);
- if (ret != MEDIA_VISION_ERROR_NONE)
- throw InvalidOperation("Fail to get default model name.");
-
- if (_backendType == MV_INFERENCE_BACKEND_NONE) {
- ret = config->getIntegerAttribute(MV_LANDMARK_DETECTION_BACKEND_TYPE, &_backendType);
- if (ret != MEDIA_VISION_ERROR_NONE)
- throw InvalidOperation("Fail to get backend engine type.");
- }
-
- if (_targetDeviceType == MV_INFERENCE_TARGET_DEVICE_NONE) {
- ret = config->getIntegerAttribute(MV_LANDMARK_DETECTION_TARGET_DEVICE_TYPE, &_targetDeviceType);
- if (ret != MEDIA_VISION_ERROR_NONE)
- throw InvalidOperation("Fail to get target device type.");
- }
-
- ret = config->getStringAttribute(MV_LANDMARK_DETECTION_MODEL_DEFAULT_PATH, &_modelDefaultPath);
- if (ret != MEDIA_VISION_ERROR_NONE)
- throw InvalidOperation("Fail to get model default path");
-
- ret = config->getStringAttribute(MV_LANDMARK_DETECTION_MODEL_FILE_PATH, &_modelFilePath);
- if (ret != MEDIA_VISION_ERROR_NONE)
- throw InvalidOperation("Fail to get model file path");
-
- _modelFilePath = _modelDefaultPath + _modelFilePath;
- LOGI("model file path = %s", _modelFilePath.c_str());
-
- ret = config->getStringAttribute(MV_LANDMARK_DETECTION_MODEL_META_FILE_PATH, &_modelMetaFilePath);
- if (ret != MEDIA_VISION_ERROR_NONE)
- throw InvalidOperation("Fail to get model meta file path");
-
- if (_modelMetaFilePath.empty())
- throw InvalidOperation("Model meta file doesn't exist.");
-
- if (!IsJsonFile(_modelMetaFilePath))
- throw InvalidOperation("Model meta file should be json");
-
- _modelMetaFilePath = _modelDefaultPath + _modelMetaFilePath;
- LOGI("meta file path = %s", _modelMetaFilePath.c_str());
-
- ret = config->getDoubleAttribute(MV_LANDMARK_DETECTION_CONFIDENCE_THRESHOLD, &_confidence_threshold);
- if (ret != MEDIA_VISION_ERROR_NONE)
- LOGW("threshold value doesn't exist.");
-
- ret = config->getStringAttribute(MV_LANDMARK_DETECTION_LABEL_FILE_NAME, &_modelLabelFilePath);
- if (ret != MEDIA_VISION_ERROR_NONE)
- throw InvalidOperation("Fail to get label file path");
-
- if (_modelLabelFilePath.empty()) {
- LOGW("Label doesn't exist.");
- return;
- }
-
- _modelLabelFilePath = _modelDefaultPath + _modelLabelFilePath;
- LOGI("label file path = %s", _modelLabelFilePath.c_str());
-}
-
-void LandmarkDetectionConfig::loadMetaFile()
-{
- _parser = make_unique<LandmarkDetectionParser>();
- _parser->load(_modelMetaFilePath);
-}
-
-}
-}
\ No newline at end of file
{
namespace machine_learning
{
-PldCpm::PldCpm(LandmarkDetectionTaskType task_type, std::shared_ptr<LandmarkDetectionConfig> config)
+PldCpm::PldCpm(LandmarkDetectionTaskType task_type, std::shared_ptr<MachineLearningConfig> config)
: LandmarkDetection(task_type, config), _result()
{}
{
template<typename T, typename V> PoseLandmarkAdapter<T, V>::PoseLandmarkAdapter() : _source()
{
- _config = make_shared<LandmarkDetectionConfig>();
+ _config = make_shared<MachineLearningConfig>();
_config->parseConfigFile(_config_file_name);
LandmarkDetectionTaskType model_type = convertToTaskType(_config->getDefaultModelName());
return;
}
- // if model name is changed by user then reallocate the parser and reload the meta file corresponding to the model name.
- _config->loadMetaFile();
-
if (task_type == LandmarkDetectionTaskType::PLD_CPM)
_landmark_detection = make_unique<PldCpm>(task_type, _config);
}
target_compile_definitions(${TEST_IMAGE_CLASSIFICATION} PRIVATE -DTEST_RES_PATH="${TEST_RES_PATH}")
target_link_libraries(${TEST_IMAGE_CLASSIFICATION} gtest gtest_main
+ mv_ml_common
mv_inference
mv_image_classification
mv_image_helper
target_compile_definitions(${TEST_IMAGE_CLASSIFICATION_ASYNC} PRIVATE -DTEST_RES_PATH="${TEST_RES_PATH}")
target_link_libraries(${TEST_IMAGE_CLASSIFICATION_ASYNC} gtest gtest_main pthread
+ mv_ml_common
mv_inference
mv_image_classification
mv_image_helper
add_executable(${TEST_LANDMARK_DETECTION_ASYNC} test_landmark_detection_async.cpp)
target_link_libraries(${TEST_LANDMARK_DETECTION} gtest gtest_main
+ mv_ml_common
mv_inference
mv_landmark_detection
mv_image_helper
)
target_link_libraries(${TEST_LANDMARK_DETECTION_ASYNC} gtest gtest_main pthread
+ mv_ml_common
mv_inference
mv_landmark_detection
mv_image_helper