{
private:
std::unique_ptr<MetaParser> _parser;
- LandmarkDetectionTaskType _task_type { LandmarkDetectionTaskType::LANDMARK_DETECTION_TASK_NONE };
std::string _defaultModelName;
std::string _modelFilePath;
std::string _modelMetaFilePath;
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 setTaskType(LandmarkDetectionTaskType task_type);
void setBackendType(int backend_type);
void setTargetDeviceType(int device_type);
- LandmarkDetectionTaskType getTaskType() const;
const std::string &getDefaultModelName() const;
const std::string &getModelFilePath() const;
const std::string &getLabelFilePath() const;
double getConfidenceThreshold() const;
int getBackendType() const;
int getTargetDeviceType() const;
+ void loadMetaFile(LandmarkDetectionTaskType task_type);
};
} // machine_learning
_config->parseConfigFile(_config_file_name);
LandmarkDetectionTaskType model_type = convertToTaskType(_config->getDefaultModelName());
-
create(model_type);
- _config->setTaskType(model_type);
}
template<typename T, typename V> FacialLandmarkAdapter<T, V>::~FacialLandmarkAdapter()
return;
}
+ // if model name is changed by user then reallocate the parser and reload the meta file corresponding to the model name.
+ _config->loadMetaFile(task_type);
+
if (task_type == LandmarkDetectionTaskType::FLD_TWEAK_CNN)
_landmark_detection = make_unique<FldTweakCnn>(task_type, _config);
}
const char *model_name)
{
try {
- LandmarkDetectionTaskType model_type = convertToTaskType(model_name);
-
_config->setUserModel(model_file, meta_file, label_file);
+
+ LandmarkDetectionTaskType model_type = convertToTaskType(model_name);
create(model_type);
- _config->setTaskType(model_type);
} catch (const BaseException &e) {
LOGW("A given model name is invalid so default task type will be used.");
}
namespace machine_learning
{
LandmarkDetectionConfig::LandmarkDetectionConfig()
-{
- _parser = make_unique<LandmarkDetectionParser>();
-}
-
-void LandmarkDetectionConfig::setTaskType(LandmarkDetectionTaskType task_type)
-{
- _task_type = task_type;
-}
+{}
void LandmarkDetectionConfig::setBackendType(int backend_type)
{
_targetDeviceType = device_type;
}
-LandmarkDetectionTaskType LandmarkDetectionConfig::getTaskType() const
-{
- return _task_type;
-}
-
const std::string &LandmarkDetectionConfig::getDefaultModelName() const
{
return _defaultModelName;
{
if (!model_file.empty())
_modelFilePath = _modelDefaultPath + model_file;
- if (meta_file.empty())
+ if (!meta_file.empty())
_modelMetaFilePath = _modelDefaultPath + meta_file;
- if (label_file.empty())
+ if (!label_file.empty())
_modelLabelFilePath = _modelDefaultPath + label_file;
}
_modelMetaFilePath = _modelDefaultPath + _modelMetaFilePath;
LOGI("meta file path = %s", _modelMetaFilePath.c_str());
- _parser->load(_modelMetaFilePath);
-
ret = config->getDoubleAttribute(MV_LANDMARK_DETECTION_CONFIDENCE_THRESHOLD, &_confidence_threshold);
if (ret != MEDIA_VISION_ERROR_NONE)
LOGW("threshold value doesn't exist.");
LOGI("label file path = %s", _modelLabelFilePath.c_str());
}
+void LandmarkDetectionConfig::loadMetaFile(LandmarkDetectionTaskType task_type)
+{
+ _parser = make_unique<LandmarkDetectionParser>();
+ _parser->setTaskType(static_cast<int>(task_type));
+ _parser->load(_modelMetaFilePath);
+}
+
}
}
\ No newline at end of file
_config->parseConfigFile(_config_file_name);
LandmarkDetectionTaskType model_type = convertToTaskType(_config->getDefaultModelName());
-
create(model_type);
- _config->setTaskType(model_type);
}
template<typename T, typename V> PoseLandmarkAdapter<T, V>::~PoseLandmarkAdapter()
return;
}
+ // if model name is changed by user then reallocate the parser and reload the meta file corresponding to the model name.
+ _config->loadMetaFile(task_type);
+
if (task_type == LandmarkDetectionTaskType::PLD_CPM)
_landmark_detection = make_unique<PldCpm>(task_type, _config);
}
const char *model_name)
{
try {
- LandmarkDetectionTaskType model_type = convertToTaskType(model_name);
-
_config->setUserModel(model_file, meta_file, label_file);
+
+ LandmarkDetectionTaskType model_type = convertToTaskType(model_name);
create(model_type);
- _config->setTaskType(model_type);
} catch (const BaseException &e) {
LOGW("A given model name is invalid so default task type will be used.");
}