mirror of
https://github.com/RapidAI/RapidOCR.git
synced 2026-11-10 21:10:55 +08:00
fix(rapidocr): fixed path error of infernce engine when customizing incoming parameters
This commit is contained in:
1 parent
a87ecab2d3
commit
b2dd2db830
4 files changed
+9
-5
No files matched your search
@@ -32,7 +32,7 @@ class OrtInferSession(InferSession):
|
||||
def __init__(self, config: Dict[str, Any]):
|
||||
self.logger = Logger(logger_name=__name__).get_log()
|
||||
|
||||
model_path = Path(config.get("model_path", None))
|
||||
model_path = config.get("model_path", None)
|
||||
if model_path is None:
|
||||
# 说明用户没有指定自己模型,使用默认模型
|
||||
model_info = self.get_model_url(
|
||||
@@ -47,6 +47,7 @@ class OrtInferSession(InferSession):
|
||||
)
|
||||
DownloadFile.run(download_params)
|
||||
|
||||
model_path = Path(model_path)
|
||||
self._verify_model(model_path)
|
||||
|
||||
self.cfg_use_cuda = config.engine_cfg.get("use_cuda", None)
|
||||
|
||||
@@ -21,7 +21,7 @@ class OpenVINOInferSession(InferSession):
|
||||
|
||||
core = Core()
|
||||
|
||||
model_path = Path(config.get("model_path", None))
|
||||
model_path = config.get("model_path", None)
|
||||
if model_path is None:
|
||||
model_info = self.get_model_url(
|
||||
config.engine_name, config.task_type, config.lang
|
||||
@@ -35,14 +35,15 @@ class OpenVINOInferSession(InferSession):
|
||||
)
|
||||
DownloadFile.run(download_params)
|
||||
|
||||
model_path = Path(model_path)
|
||||
self._verify_model(model_path)
|
||||
model_onnx = core.read_model(model_path)
|
||||
|
||||
cpu_nums = os.cpu_count()
|
||||
infer_num_threads = config.get("inference_num_threads", -1)
|
||||
if infer_num_threads != -1 and 1 <= infer_num_threads <= cpu_nums:
|
||||
core.set_property("CPU", {"INFERENCE_NUM_THREADS": str(infer_num_threads)})
|
||||
|
||||
model_onnx = core.read_model(model_path)
|
||||
compile_model = core.compile_model(model=model_onnx, device_name="CPU")
|
||||
self.session = compile_model.create_infer_request()
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class PaddleInferSession(InferSession):
|
||||
self.logger = Logger(logger_name=__name__).get_log()
|
||||
self.mode = mode
|
||||
|
||||
model_dir = Path(config.get("model_dir", None))
|
||||
model_dir = config.get("model_dir", None)
|
||||
if model_dir is None:
|
||||
model_info = self.get_model_url(
|
||||
config.engine_name, config.task_type, config.lang
|
||||
@@ -57,6 +57,7 @@ class PaddleInferSession(InferSession):
|
||||
)
|
||||
)
|
||||
else:
|
||||
model_dir = Path(model_dir)
|
||||
pdmodel_path = model_dir / "inference.pdmodel"
|
||||
pdiparams_path = model_dir / "inference.pdiparams"
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class TorchInferSession(InferSession):
|
||||
def __init__(self, config) -> None:
|
||||
self.logger = Logger(logger_name=__name__).get_log()
|
||||
|
||||
model_path = Path(config.get("model_path", None))
|
||||
model_path = config.get("model_path", None)
|
||||
if model_path is None:
|
||||
model_info = self.get_model_url(
|
||||
config.engine_name, config.task_type, config.lang
|
||||
@@ -36,6 +36,7 @@ class TorchInferSession(InferSession):
|
||||
)
|
||||
)
|
||||
|
||||
model_path = Path(model_path)
|
||||
self._verify_model(model_path)
|
||||
|
||||
all_arch_config = OmegaConf.load(DEFAULT_CFG_PATH)
|
||||
|
||||
Reference in new issue
Block a user