Skip to content

πŸ“„ Awesome OCR multiple programing languages toolkits based on ONNX Runtime, OpenVINO, MNN, PaddlePaddle, TensorRT and PyTorch.

chore: update files

SWHL6189f611b62e
diff --git a/python/demo.py b/python/demo.py
index 40cc3d9..e855434 100644
--- a/python/demo.py
+++ b/python/demo.py
@@ -15,7 +15,10 @@ from rapidocr import RapidOCR, VisRes
# yaml_path = "tests/test_files/config.yaml"
# engine = RapidOCR(config_path=yaml_path)
-engine = RapidOCR()
+engine = engine = RapidOCR(
+ params={"Global.with_onnx": True, "EngineConfig.onnxruntime.use_cuda": True}
+)
+# engine = RapidOCR(params={"Global.with_openvino": True})
vis = VisRes()
image_path = "tests/test_files/ch_en_num.jpg"
diff --git a/python/rapidocr/ch_ppocr_cls/main.py b/python/rapidocr/ch_ppocr_cls/main.py
index 7e8974a..e57b8e0 100644
--- a/python/rapidocr/ch_ppocr_cls/main.py
+++ b/python/rapidocr/ch_ppocr_cls/main.py
@@ -19,7 +19,7 @@ from typing import Any, Dict, List, Union
import cv2
import numpy as np
-from rapidocr.inference_engine import get_engine
+from rapidocr.inference_engine.base import get_engine
from .utils import ClsPostProcess, TextClsOutput
diff --git a/python/rapidocr/ch_ppocr_det/main.py b/python/rapidocr/ch_ppocr_det/main.py
index 58a1cf9..c432eb0 100644
--- a/python/rapidocr/ch_ppocr_det/main.py
+++ b/python/rapidocr/ch_ppocr_det/main.py
@@ -19,7 +19,7 @@ from typing import Any, Dict, List
import numpy as np
-from rapidocr.inference_engine import get_engine
+from rapidocr.inference_engine.base import get_engine
from .utils import DBPostProcess, DetPreProcess, TextDetOutput
diff --git a/python/rapidocr/ch_ppocr_rec/main.py b/python/rapidocr/ch_ppocr_rec/main.py
index 866f232..c138217 100644
--- a/python/rapidocr/ch_ppocr_rec/main.py
+++ b/python/rapidocr/ch_ppocr_rec/main.py
@@ -19,11 +19,12 @@ from typing import Any, Dict
import cv2
import numpy as np
-from rapidocr.inference_engine import get_engine
+from rapidocr.inference_engine.base import get_engine
from .utils import CTCLabelDecode, TextRecInput, TextRecOutput
DEFAULT_DICT_PATH = str(Path(__file__).parent.parent / "models" / "ppocr_keys_v1.txt")
+DEFAULT_DICT_URL = "https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/paddle/PP-OCRv4/rec/ch_PP-OCRv4_rec_infer/ppocr_keys_v1.txt"
class TextRecognizer:
@@ -36,6 +37,9 @@ class TextRecognizer:
dict_path = config.get("rec_keys_path", None)
character_dict_path = dict_path if dict_path else DEFAULT_DICT_PATH
+ if not Path(character_dict_path).exists():
+ self.session.download_file(DEFAULT_DICT_URL, character_dict_path)
+
self.postprocess_op = CTCLabelDecode(
character=character, character_path=character_dict_path
)
diff --git a/python/rapidocr/config.yaml b/python/rapidocr/config.yaml
index 83ffc81..7e82857 100644
--- a/python/rapidocr/config.yaml
+++ b/python/rapidocr/config.yaml
@@ -1,6 +1,7 @@
Global:
lang: "ch"
text_score: 0.5
+
use_det: true
use_cls: true
use_rec: true
@@ -60,6 +61,7 @@ Cls:
Rec:
model_path: models/ch_PP-OCRv4_rec_infer.onnx
+ rec_keys_path: models/ppocr_keys_v1.txt
rec_img_shape: [3, 48, 320]
rec_batch_num: 6
diff --git a/python/rapidocr/inference_engine/MODEL_URL.yaml b/python/rapidocr/inference_engine/MODEL_URL.yaml
index 29fc6b6..e35ff56 100644
--- a/python/rapidocr/inference_engine/MODEL_URL.yaml
+++ b/python/rapidocr/inference_engine/MODEL_URL.yaml
@@ -27,18 +27,42 @@ openvino:
en_PP-OCRv3_det_infer.onnx: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/onnx/PP-OCRv4/det/en_PP-OCRv3_det_infer.onnx
Multilingual_PP-OCRv3_det_infer.onnx: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/onnx/PP-OCRv4/det/Multilingual_PP-OCRv3_det_infer.onnx
rec:
- arabic_PP-OCRv4_rec_infer.onnx: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/onnx/PP-OCRv4/rec/arabic_PP-OCRv4_rec_infer.onnx
- ch_PP-OCRv4_rec_infer.onnx: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/onnx/PP-OCRv4/rec/ch_PP-OCRv4_rec_infer.onnx
- chinese_cht_PP-OCRv3_rec_infer.onnx: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/onnx/PP-OCRv4/rec/chinese_cht_PP-OCRv3_rec_infer.onnx
- cyrillic_PP-OCRv3_rec_infer.onnx: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/onnx/PP-OCRv4/rec/cyrillic_PP-OCRv3_rec_infer.onnx
- devanagari_PP-OCRv4_rec_infer.onnx: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/onnx/PP-OCRv4/rec/devanagari_PP-OCRv4_rec_infer.onnx
- en_PP-OCRv4_rec_infer.onnx: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/onnx/PP-OCRv4/rec/en_PP-OCRv4_rec_infer.onnx
- japan_PP-OCRv4_rec_infer.onnx: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/onnx/PP-OCRv4/rec/japan_PP-OCRv4_rec_infer.onnx
- ka_PP-OCRv4_rec_infer.onnx: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/onnx/PP-OCRv4/rec/ka_PP-OCRv4_rec_infer.onnx
- korean_PP-OCRv4_rec_infer.onnx: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/onnx/PP-OCRv4/rec/korean_PP-OCRv4_rec_infer.onnx
- latin_PP-OCRv3_rec_infer.onnx: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/onnx/PP-OCRv4/rec/latin_PP-OCRv3_rec_infer.onnx
- ta_PP-OCRv4_rec_infer.onnx: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/onnx/PP-OCRv4/rec/ta_PP-OCRv4_rec_infer.onnx
- te_PP-OCRv4_rec_infer.onnx: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/onnx/PP-OCRv4/rec/te_PP-OCRv4_rec_infer.onnx
+ arabic_PP-OCRv4_rec_infer:
+ model_dir: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/onnx/PP-OCRv4/rec/arabic_PP-OCRv4_rec_infer.onnx
+ dict_url: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/paddle/PP-OCRv4/rec/arabic_PP-OCRv4_rec_infer/arabic_dict.txt
+ ch_PP-OCRv4_rec_infer:
+ model_dir: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/onnx/PP-OCRv4/rec/ch_PP-OCRv4_rec_infer.onnx
+ dict_url: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/paddle/PP-OCRv4/rec/ch_PP-OCRv4_rec_infer/ppocr_keys_v1.txt
+ chinese_cht_PP-OCRv3_rec_infer:
+ model_dir: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/onnx/PP-OCRv4/rec/chinese_cht_PP-OCRv3_rec_infer.onnx
+ dict_url: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/paddle/PP-OCRv4/rec/chinese_cht_PP-OCRv3_rec_infer/chinese_cht_dict.txt
+ cyrillic_PP-OCRv3_rec_infer:
+ model_dir: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/onnx/PP-OCRv4/rec/cyrillic_PP-OCRv3_rec_infer.onnx
+ dict_url: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/paddle/PP-OCRv4/rec/cyrillic_PP-OCRv3_rec_infer/cyrillic_dict.txt
+ devanagari_PP-OCRv4_rec_infer:
+ model_dir: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/onnx/PP-OCRv4/rec/devanagari_PP-OCRv4_rec_infer.onnx
+ dict_url: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/paddle/PP-OCRv4/rec/devanagari_PP-OCRv4_rec_infer/devanagari_dict.txt
+ en_PP-OCRv4_rec_infer:
+ model_dir: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/onnx/PP-OCRv4/rec/en_PP-OCRv4_rec_infer.onnx
+ dict_url: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/paddle/PP-OCRv4/rec/en_PP-OCRv4_rec_infer/en_dict.txt
+ japan_PP-OCRv4_rec_infer:
+ model_dir: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/onnx/PP-OCRv4/rec/japan_PP-OCRv4_rec_infer.onnx
+ dict_url: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/paddle/PP-OCRv4/rec/japan_PP-OCRv4_rec_infer/japan_dict.txt
+ ka_PP-OCRv4_rec_infer:
+ model_dir: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/onnx/PP-OCRv4/rec/ka_PP-OCRv4_rec_infer.onnx
+ dict_url: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/paddle/PP-OCRv4/rec/kannada_PP-OCRv4_rec_infer/ka_dict.txt
+ korean_PP-OCRv4_rec_infer:
+ model_dir: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/onnx/PP-OCRv4/rec/korean_PP-OCRv4_rec_infer.onnx
+ dict_url: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/paddle/PP-OCRv4/rec/korean_PP-OCRv4_rec_infer/korean_dict.txt
+ latin_PP-OCRv3_rec_infer:
+ model_dir: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/onnx/PP-OCRv4/rec/latin_PP-OCRv3_rec_infer.onnx
+ dict_url: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/paddle/PP-OCRv4/rec/latin_PP-OCRv3_rec_infer/latin_dict.txt
+ ta_PP-OCRv4_rec_infer:
+ model_dir: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/onnx/PP-OCRv4/rec/ta_PP-OCRv4_rec_infer.onnx
+ dict_url: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/paddle/PP-OCRv4/rec/ta_PP-OCRv4_rec_infer/ta_dict.txt
+ te_PP-OCRv4_rec_infer:
+ model_dir: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/onnx/PP-OCRv4/rec/te_PP-OCRv4_rec_infer.onnx
+ dict_url: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/paddle/PP-OCRv4/rec/te_PP-OCRv4_rec_infer/te_dict.txt
cls:
ch_ppocr_mobile_v2.0_cls_infer.onnx: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/onnx/PP-OCRv4/cls/ch_ppocr_mobile_v2.0_cls_infer.onnx
@@ -52,11 +76,9 @@ paddlepaddle:
arabic_PP-OCRv4_rec_infer:
model_dir: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/paddle/PP-OCRv4/rec/arabic_PP-OCRv4_rec_infer
dict_url: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/paddle/PP-OCRv4/rec/arabic_PP-OCRv4_rec_infer/arabic_dict.txt
-
ch_PP-OCRv4_rec_infer:
model_dir: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/paddle/PP-OCRv4/rec/ch_PP-OCRv4_rec_infer
dict_url: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/paddle/PP-OCRv4/rec/ch_PP-OCRv4_rec_infer/ppocr_keys_v1.txt
-
chinese_cht_PP-OCRv3_rec_infer:
model_dir: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/paddle/PP-OCRv4/rec/chinese_cht_PP-OCRv3_rec_infer
dict_url: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/paddle/PP-OCRv4/rec/chinese_cht_PP-OCRv3_rec_infer/chinese_cht_dict.txt
@@ -88,7 +110,7 @@ paddlepaddle:
model_dir: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/paddle/PP-OCRv4/rec/te_PP-OCRv4_rec_infer
dict_url: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/paddle/PP-OCRv4/rec/te_PP-OCRv4_rec_infer/te_dict.txt
cls:
- ch_ppocr_mobile_v2.0_cls_infer.onnx: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/onnx/PP-OCRv4/cls/ch_ppocr_mobile_v2.0_cls_infer.onnx
+ ch_ppocr_mobile_v2.0_cls_infer: https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/master/paddle/PP-OCRv4/cls/ch_ppocr_mobile_v2_cls_infer/inference.pdiparams
torch:
PP-OCRv4:
diff --git a/python/rapidocr/inference_engine/__init__.py b/python/rapidocr/inference_engine/__init__.py
index eda5cf5..ab1f42d 100644
--- a/python/rapidocr/inference_engine/__init__.py
+++ b/python/rapidocr/inference_engine/__init__.py
@@ -1,57 +1,6 @@
# -*- encoding: utf-8 -*-
# @Author: SWHL
# @Contact: [email protected]
-from enum import Enum
-
-from omegaconf import DictConfig
-
from .onnxruntime import OrtInferSession
-from .openvino import OpenVINOInferSession
from .paddlepaddle import PaddleInferSession
from .torch import TorchInferSession
-
-
-class Engine(Enum):
- ONNXRUNTIME = "onnxruntime"
- OPENVINO = "openvino"
- PADDLE = "paddlepaddle"
- TORCH = "torch"
-
-
-def get_engine(engine_name: str):
- print("engine_name:", engine_name)
-
- if engine_name == Engine.ONNXRUNTIME.value:
- return OrtInferSession
-
- if engine_name == Engine.OPENVINO.value:
- return OpenVINOInferSession
-
- if engine_name == Engine.PADDLE.value:
- return PaddleInferSession
-
- if engine_name == Engine.TORCH.value:
- return TorchInferSession
-
- raise ValueError(f"Unsupported engine: {engine_name}")
-
-
-def get_engine_name(config: DictConfig) -> str:
- with_onnx = config.Global.with_onnx
- with_openvino = config.Global.with_openvino
- with_paddle = config.Global.with_paddle
- with_torch = config.Global.with_torch
-
- if with_onnx:
- return Engine.ONNXRUNTIME.value
-
- if with_openvino:
- return Engine.OPENVINO.value
-
- if with_paddle:
- return Engine.PADDLE.value
-
- if with_torch:
- return Engine.TORCH.value
-
- return Engine.ONNXRUNTIME.value
diff --git a/python/rapidocr/inference_engine/base.py b/python/rapidocr/inference_engine/base.py
index 0220bd1..82bfe6a 100644
--- a/python/rapidocr/inference_engine/base.py
+++ b/python/rapidocr/inference_engine/base.py
@@ -2,21 +2,82 @@
# @Author: SWHL
# @Contact: [email protected]
import abc
+from enum import Enum
from pathlib import Path
from typing import Union
import numpy as np
import requests
-from omegaconf import OmegaConf
+from omegaconf import DictConfig, OmegaConf
from tqdm import tqdm
+from ..utils.logger import Logger
+
cur_dir = Path(__file__).resolve().parent
MODEL_URL_PATH = cur_dir / "MODEL_URL.yaml"
+logger = Logger(logger_name=__name__).get_log()
+
+
+class Engine(Enum):
+ ONNXRUNTIME = "onnxruntime"
+ OPENVINO = "openvino"
+ PADDLE = "paddlepaddle"
+ TORCH = "torch"
+
+
+def get_engine(engine_name: str):
+ logger.info("Using engine_name: %s", engine_name)
+
+ if engine_name == Engine.ONNXRUNTIME.value:
+ from .onnxruntime import OrtInferSession
+
+ return OrtInferSession
+
+ if engine_name == Engine.OPENVINO.value:
+ from .openvino import OpenVINOInferSession
+
+ return OpenVINOInferSession
+
+ if engine_name == Engine.PADDLE.value:
+ from .paddlepaddle import PaddleInferSession
+
+ return PaddleInferSession
+
+ if engine_name == Engine.TORCH.value:
+ from .torch import TorchInferSession
+
+ return TorchInferSession
+
+ raise ValueError(f"Unsupported engine: {engine_name}")
+
+
+def get_engine_name(config: DictConfig) -> str:
+ with_onnx = config.Global.with_onnx
+ with_openvino = config.Global.with_openvino
+ with_paddle = config.Global.with_paddle
+ with_torch = config.Global.with_torch
+
+ if with_onnx:
+ return Engine.ONNXRUNTIME.value
+
+ if with_openvino:
+ return Engine.OPENVINO.value
+
+ if with_paddle:
+ return Engine.PADDLE.value
+
+ if with_torch:
+ return Engine.TORCH.value
+
+ return Engine.ONNXRUNTIME.value
+
+
class InferSession(abc.ABC):
model_info = OmegaConf.load(MODEL_URL_PATH)
DEFAULT_MODE_PATH = cur_dir.parent / "models"
+ logger = Logger(logger_name=__name__).get_log()
@abc.abstractmethod
def __init__(self, config):
@@ -44,9 +105,9 @@ class InferSession(abc.ABC):
def have_key(self, key: str = "character") -> bool:
pass
- @staticmethod
- def download_file(url: str, save_path: Union[str, Path]):
- print(f"Downloading model from {url} to {save_path}")
+ @classmethod
+ def download_file(cls, url: str, save_path: Union[str, Path]):
+ cls.logger.info("Downloading model from %s to %s", url, save_path)
response = requests.get(url, stream=True, timeout=60)
status_code = response.status_code
diff --git a/python/rapidocr/inference_engine/openvino.py b/python/rapidocr/inference_engine/openvino.py
index dd71975..eaa8bf0 100644
--- a/python/rapidocr/inference_engine/openvino.py
+++ b/python/rapidocr/inference_engine/openvino.py
@@ -13,6 +13,8 @@ from .base import InferSession
class OpenVINOInferSession(InferSession):
def __init__(self, config: DictConfig):
+ super().__init__(config)
+
core = Core()
self._verify_model(config["model_path"])
diff --git a/python/rapidocr/main.py b/python/rapidocr/main.py
index 06bd012..884d35c 100644
--- a/python/rapidocr/main.py
+++ b/python/rapidocr/main.py
@@ -12,7 +12,7 @@ from .cal_rec_boxes import CalRecBoxes
from .ch_ppocr_cls import TextClassifier, TextClsOutput
from .ch_ppocr_det import TextDetector, TextDetOutput
from .ch_ppocr_rec import TextRecInput, TextRecognizer, TextRecOutput
-from .inference_engine import get_engine_name
+from .inference_engine.base import get_engine_name
from .utils import (
LoadImage,
Logger,
@@ -39,6 +39,7 @@ class RapidOCR:
else:
config = ParseParams.load(DEFAULT_CFG_PATH)
config = ParseParams.update_model_path(config)
+ config = ParseParams.update_dict_path(config)
if params:
config = ParseParams.update_batch(config, params)
diff --git a/python/rapidocr/utils/logger.py b/python/rapidocr/utils/logger.py
index 408685c..4bd91cc 100644
--- a/python/rapidocr/utils/logger.py
+++ b/python/rapidocr/utils/logger.py
@@ -8,12 +8,11 @@ class Logger:
def __init__(self, log_level=logging.DEBUG, logger_name=None):
self.logger = logging.getLogger(logger_name)
self.logger.setLevel(log_level)
+ self.logger.propagate = False
fmt = "[%(levelname)s] %(asctime)s %(filename)s:%(lineno)d: %(message)s"
formatter = logging.Formatter(fmt)
- self.logger.handlers.clear()
-
if not self.logger.handlers:
ch = logging.StreamHandler()
ch.setLevel(log_level)
diff --git a/python/rapidocr/utils/parse_parameters.py b/python/rapidocr/utils/parse_parameters.py
index d6e5639..289fb00 100644
--- a/python/rapidocr/utils/parse_parameters.py
+++ b/python/rapidocr/utils/parse_parameters.py
@@ -122,6 +122,13 @@ class ParseParams(OmegaConf):
cls.update(cfg, f"Rec.{key}", str(root_dir / cfg.Rec[key]))
return cfg
+ @classmethod
+ def update_dict_path(
+ cls, cfg: DictConfig, key: str = "rec_keys_path"
+ ) -> DictConfig:
+ cls.update(cfg, f"Rec.{key}", str(root_dir / cfg.Rec[key]))
+ return cfg
+
@classmethod
def update_batch(cls, cfg: DictConfig, params: Dict[str, str]) -> DictConfig:
for k, v in params.items():
diff --git a/python/tests/test_main.py b/python/tests/test_main.py
index c5b0e12..ff44997 100644
--- a/python/tests/test_main.py
+++ b/python/tests/test_main.py
@@ -4,7 +4,7 @@
import logging
import sys
from pathlib import Path
-from typing import List
+from typing import Any, Dict, List, Optional
import cv2
import numpy as np
@@ -16,15 +16,29 @@ sys.path.append(str(root_dir))
from rapidocr import LoadImageError, RapidOCR
from rapidocr.inference_engine.base import InferSession
-engine = RapidOCR()
tests_dir = root_dir / "tests" / "test_files"
img_path = tests_dir / "ch_en_num.jpg"
-# def test_engine_openvino():
-# engine = RapidOCR(params={"Global.with_openvino": True})
-# result = engine(img_path)
-# assert result.txts[0] == "正品促销"
+def engine():
+ engine = RapidOCR()
+ return engine
+
+
+def get_engine(params: Optional[Dict[str, Any]] = None):
+ if params:
+ engine = RapidOCR(params=params)
+ return engine
+
+ engine = RapidOCR()
+ return engine
+
+
+def test_engine_openvino():
+ engine = get_engine(params={"Global.with_openvino": True})
+ result = engine(img_path)
+ assert result.txts[0] == "正品促销"
# def test_engine_paddle():
@@ -39,7 +53,7 @@ img_path = tests_dir / "ch_en_num.jpg"
# assert result.txts[0] == "正品促销"
-def test_long_img():
+def test_long_img(engine):
img_url = "https://github.com/RapidAI/RapidOCR/releases/download/v1.1.0/long.jpeg"
img_path = tests_dir / "long.jpeg"
InferSession.download_file(img_url, save_path=img_path)
@@ -56,7 +70,6 @@ def test_ort_cuda_warning(caplog):
params={"Global.with_onnx": True, "EngineConfig.onnxruntime.use_cuda": True}
)
caplog.set_level(logging.WARNING)
-
assert caplog.records[0].levelname == "WARNING"
assert "CUDAExecutionProvider" in caplog.records[0].message
@@ -71,7 +84,7 @@ def test_ort_dml_warning(caplog):
assert "DirectML" in caplog.records[0].message
-def test_mode_one_img():
+def test_mode_one_img(engine):
img_path = tests_dir / "issue_170.png"
result = engine(img_path)
assert result.txts[0] == "TEST"