Fix model extract race issue to all classes
This commit is contained in:
@@ -13,6 +13,15 @@ namespace ANSCENTER {
|
||||
{
|
||||
bool result = ANSOCRBase::Initialize(licenseKey, modelConfig, modelZipFilePath, modelZipPassword, engineMode);
|
||||
if (!result) return false;
|
||||
// Serialize derived init against concurrent extract re-entries on the
|
||||
// same folder. See ModelFolderLockGuard in Utility.h.
|
||||
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSCPUOCR::Initialize");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ANSCPUOCR::Initialize",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
|
||||
//Override the paddleocrv3 for openvino only
|
||||
switch (_modelConfig.ocrLanguage) {
|
||||
|
||||
@@ -9,6 +9,15 @@ namespace ANSCENTER {
|
||||
{
|
||||
bool result = ANSOCRBase::Initialize(licenseKey, modelConfig, modelZipFilePath, modelZipPassword, engineMode);
|
||||
if (!result) return false;
|
||||
// Serialize derived init against concurrent extract re-entries on the
|
||||
// same folder. See ModelFolderLockGuard in Utility.h.
|
||||
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSOCR::Initialize");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ANSOCR::Initialize",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
auto option = fastdeploy::RuntimeOption();
|
||||
// Add default values to modelConfig if required.
|
||||
_modelConfig.precisionType = "fp32";
|
||||
|
||||
@@ -96,6 +96,15 @@ namespace ANSCENTER {
|
||||
this->_logger.LogError("ANSOCRBase::Initialize. Output model folder is not exist", modelName, __FILE__, __LINE__);
|
||||
return false; // That means the model file is not exist or the password is not correct
|
||||
}
|
||||
// Serialize derived init against concurrent extract re-entries on the
|
||||
// same folder. See ModelFolderLockGuard in Utility.h.
|
||||
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSOCRBase::Initialize");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ANSOCRBase::Initialize",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -149,6 +158,15 @@ namespace ANSCENTER {
|
||||
this->_logger.LogError("ANSOCRBase::Initialize. Output model folder is not exist", modelName, __FILE__, __LINE__);
|
||||
return false; // That means the model file is not exist or the password is not correct
|
||||
}
|
||||
// Serialize derived init against concurrent extract re-entries on the
|
||||
// same folder. See ModelFolderLockGuard in Utility.h.
|
||||
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSOCRBase::Initialize");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ANSOCRBase::Initialize",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
// 3. Check if the model has the configuration file
|
||||
std::string modelConfigName = "model_config.json";
|
||||
_modelConfigFile = CreateFilePath(_modelFolder, modelConfigName);
|
||||
|
||||
@@ -9,6 +9,15 @@ bool ANSONNXOCR::Initialize(const std::string& licenseKey, OCRModelConfig modelC
|
||||
try {
|
||||
bool result = ANSOCRBase::Initialize(licenseKey, modelConfig, modelZipFilePath, modelZipPassword, engineMode);
|
||||
if (!result) return false;
|
||||
// Serialize derived init against concurrent extract re-entries on the
|
||||
// same folder. See ModelFolderLockGuard in Utility.h.
|
||||
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSONNXOCR::Initialize");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ANSONNXOCR::Initialize",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Validate detection model
|
||||
if (!FileExist(_modelConfig.detectionModelFile)) {
|
||||
|
||||
@@ -9,6 +9,15 @@ bool ANSRTOCR::Initialize(const std::string& licenseKey, OCRModelConfig modelCon
|
||||
try {
|
||||
bool result = ANSOCRBase::Initialize(licenseKey, modelConfig, modelZipFilePath, modelZipPassword, engineMode);
|
||||
if (!result) return false;
|
||||
// Serialize derived init against concurrent extract re-entries on the
|
||||
// same folder. See ModelFolderLockGuard in Utility.h.
|
||||
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSRTOCR::Initialize");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ANSRTOCR::Initialize",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Validate detection model
|
||||
if (!FileExist(_modelConfig.detectionModelFile)) {
|
||||
|
||||
Reference in New Issue
Block a user