Skip to content

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

Add unit test of rec v3

SWHLd2690cdf857a
diff --git a/python/rapidocr_onnxruntime/ch_ppocr_v3_rec/config.yaml b/python/rapidocr_onnxruntime/ch_ppocr_v3_rec/config.yaml
index 2428429..c07c65b 100644
--- a/python/rapidocr_onnxruntime/ch_ppocr_v3_rec/config.yaml
+++ b/python/rapidocr_onnxruntime/ch_ppocr_v3_rec/config.yaml
@@ -1,4 +1,4 @@
-model_path: resources/models/PPOCRv3/ch_PP-OCRv3_rec_infer.onnx
+model_path: resources/models/ch_PP-OCRv3_rec_infer.onnx
use_cuda: false
# Details of the params: https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html
diff --git a/python/tests/test_rec_v2.py b/python/tests/test_rec_v2.py
index 4a45ab6..0717ffa 100644
--- a/python/tests/test_rec_v2.py
+++ b/python/tests/test_rec_v2.py
@@ -14,11 +14,11 @@ config = base.read_yaml(str(yaml_path))
config['model_path'] = str(base.root_dir / config['model_path'])
config['keys_path'] = str(base.root_dir / config['keys_path'])
-text_cls = TextRecognizer(config)
+text_rec = TextRecognizer(config)
def test_rec():
img_path = 'test_files/text_rec.jpg'
img = cv2.imread(img_path)
- rec_res, elapse = text_cls([img])
+ rec_res, elapse = text_rec([img])
assert rec_res[0][0] == 'ιŸ©ε›½ε°ι¦†'
diff --git a/python/tests/test_rec_v3.py b/python/tests/test_rec_v3.py
new file mode 100644
index 0000000..69fef63
--- /dev/null
+++ b/python/tests/test_rec_v3.py
@@ -0,0 +1,24 @@
+# -*- encoding: utf-8 -*-
+# @Author: SWHL
+# @Contact: [email protected]
+import base
+import cv2
+
+
+module_name = 'ch_ppocr_v3_rec'
+class_name = 'TextRecognizer'
+TextRecognizer = base.init_module(module_name, class_name)
+
+yaml_path = base.root_dir / base.package_name / module_name / 'config.yaml'
+config = base.read_yaml(str(yaml_path))
+config['model_path'] = str(base.root_dir / config['model_path'])
+config['keys_path'] = str(base.root_dir / config['keys_path'])
+
+text_rec = TextRecognizer(config)
+
+
+def test_rec():
+ img_path = 'test_files/text_rec.jpg'
+ img = cv2.imread(img_path)
+ rec_res, elapse = text_rec([img])
+ assert rec_res[0][0] == 'ιŸ©ε›½ε°ι¦†'