π Awesome OCR multiple programing languages toolkits based on ONNX Runtime, OpenVINO, MNN, PaddlePaddle, TensorRT and PyTorch.
chore: update files
SWHL6de719464733
diff --git a/python/demo.py b/python/demo.pyindex f90172b..c4cbda4 100644--- a/python/demo.py+++ b/python/demo.py@@ -18,7 +18,7 @@ from rapidocr import RapidOCR, VisRes# engine = engine = RapidOCR(# params={"Global.with_onnx": True, "EngineConfig.onnxruntime.use_cuda": True}# )-engine = RapidOCR(params={"Global.with_paddle": True, "Global.lang": "ch"})+engine = RapidOCR(params={"Global.with_openvino": True, "Global.lang": "ch"})vis = VisRes()image_path = "tests/test_files/ch_en_num.jpg"diff --git a/python/rapidocr/inference_engine/onnxruntime.py b/python/rapidocr/inference_engine/onnxruntime.pyindex 433c70b..60e3b0f 100644--- a/python/rapidocr/inference_engine/onnxruntime.py+++ b/python/rapidocr/inference_engine/onnxruntime.py@@ -6,7 +6,7 @@ import platformimport tracebackfrom enum import Enumfrom pathlib import Path-from typing import Any, Dict, List, Tuple+from typing import Any, Dict, List, Optional, Tupleimport numpy as npfrom onnxruntime import (@@ -28,7 +28,7 @@ class EP(Enum):class OrtInferSession(InferSession):- def __init__(self, config: Dict[str, Any]):+ def __init__(self, config: Dict[str, Any], mode: Optional[str] = None):self.logger = Logger(logger_name=__name__).get_log()model_path = config.get("model_path", None)diff --git a/python/rapidocr/inference_engine/openvino.py b/python/rapidocr/inference_engine/openvino.pyindex 168578a..3a15dbd 100644--- a/python/rapidocr/inference_engine/openvino.py+++ b/python/rapidocr/inference_engine/openvino.py@@ -4,6 +4,7 @@import osimport tracebackfrom pathlib import Path+from typing import Optionalimport numpy as npfrom omegaconf import DictConfig@@ -13,8 +14,9 @@ from .base import InferSessionclass OpenVINOInferSession(InferSession):- def __init__(self, config: DictConfig):+ def __init__(self, config: DictConfig, mode: Optional[str] = None):super().__init__(config)+ self.mode = modecore = Core()@@ -23,6 +25,9 @@ class OpenVINOInferSession(InferSession):default_model_url = self.get_model_url(config.engine_name, config.task_type, config.lang)+ if self.mode == "rec":+ default_model_url = default_model_url.model_dir+model_path = self.DEFAULT_MODE_PATH / Path(default_model_url).nameself.download_file(default_model_url, model_path)diff --git a/python/tests/test_main.py b/python/tests/test_main.pyindex 1d59739..6de89f8 100644--- a/python/tests/test_main.py+++ b/python/tests/test_main.py@@ -34,15 +34,24 @@ def get_engine(params: Optional[Dict[str, Any]] = None):return engine+def test_lang():+ engine = get_engine(params={"Global.lang": "ch", "Global.with_openvino": True})+ result = engine(img_path)+ assert result.txts is not None+ assert result.txts[0] == "ζ£εδΏι"++def test_engine_openvino():engine = get_engine(params={"Global.with_openvino": True})result = engine(img_path)+ assert result.txts is not Noneassert result.txts[0] == "ζ£εδΏι"def test_engine_paddle():engine = RapidOCR(params={"Global.with_paddle": True})result = engine(img_path)+ assert result.txts is not Noneassert result.txts[0] == "ζ£εδΏι"