From a8ea87c4cffbfe5b5de0f599ad239ff94357bc5b Mon Sep 17 00:00:00 2001 From: Elwin <61868295+hzhaoy@users.noreply.github.com> Date: Fri, 25 Apr 2025 20:42:16 +0800 Subject: [PATCH] fix(rapidocr): fixed issue #405 (#406) make sure `model_path` is type of `Path` --- python/rapidocr/inference_engine/base.py | 2 ++ python/rapidocr/inference_engine/torch.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/python/rapidocr/inference_engine/base.py b/python/rapidocr/inference_engine/base.py index 8e161a7..bb14919 100644 --- a/python/rapidocr/inference_engine/base.py +++ b/python/rapidocr/inference_engine/base.py @@ -121,6 +121,8 @@ class InferSession(abc.ABC): if not model_path.is_file(): raise FileExistsError(f"{model_path} is not a file.") + return model_path + @abc.abstractmethod def have_key(self, key: str = "character") -> bool: pass diff --git a/python/rapidocr/inference_engine/torch.py b/python/rapidocr/inference_engine/torch.py index 651862a..2e69293 100644 --- a/python/rapidocr/inference_engine/torch.py +++ b/python/rapidocr/inference_engine/torch.py @@ -36,7 +36,7 @@ class TorchInferSession(InferSession): ) ) - self._verify_model(model_path) + model_path = self._verify_model(model_path) all_arch_config = OmegaConf.load(DEFAULT_CFG_PATH) file_name = model_path.stem