Skip to content

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

Add unit tests

SWHL706343c8ec6c
diff --git a/python/rapidocr_onnxruntime/ch_ppocr_v2_cls/config.yaml b/python/rapidocr_onnxruntime/ch_ppocr_v2_cls/config.yaml
index 89497ae..f4bce0b 100644
--- a/python/rapidocr_onnxruntime/ch_ppocr_v2_cls/config.yaml
+++ b/python/rapidocr_onnxruntime/ch_ppocr_v2_cls/config.yaml
@@ -5,7 +5,6 @@ use_cuda: false
CUDAExecutionProvider:
device_id: 0
arena_extend_strategy: kNextPowerOfTwo
- gpu_mem_limit: 2 * 1024 * 1024 * 1024
cudnn_conv_algo_search: EXHAUSTIVE
do_copy_in_default_stream: true
diff --git a/python/rapidocr_onnxruntime/ch_ppocr_v2_rec/config.yaml b/python/rapidocr_onnxruntime/ch_ppocr_v2_rec/config.yaml
index ffcfc1d..035d74e 100644
--- a/python/rapidocr_onnxruntime/ch_ppocr_v2_rec/config.yaml
+++ b/python/rapidocr_onnxruntime/ch_ppocr_v2_rec/config.yaml
@@ -1,4 +1,4 @@
-model_path: resources/models/ch_ppocr_server_v2.0_rec_infer.onnx
+model_path: resources/models/ch_ppocr_mobile_v2.0_rec_infer.onnx
use_cuda: false
# Details of the params: https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html
diff --git a/python/rapidocr_openvino/ch_ppocr_v2_det/config.yaml b/python/rapidocr_openvino/ch_ppocr_v2_det/config.yaml
index 0f08b09..7940478 100644
--- a/python/rapidocr_openvino/ch_ppocr_v2_det/config.yaml
+++ b/python/rapidocr_openvino/ch_ppocr_v2_det/config.yaml
@@ -1,4 +1,4 @@
-model_path: resources/models/ch_ppocr_server_v2.0_det_infer.onnx
+model_path: resources/models/ch_PP-OCRv2_det_infer.onnx
pre_process:
DetResizeForTest:
diff --git a/python/rapidocr_openvino/ch_ppocr_v2_rec/config.yaml b/python/rapidocr_openvino/ch_ppocr_v2_rec/config.yaml
index 3c3c9df..167c3b6 100644
--- a/python/rapidocr_openvino/ch_ppocr_v2_rec/config.yaml
+++ b/python/rapidocr_openvino/ch_ppocr_v2_rec/config.yaml
@@ -1,4 +1,4 @@
-model_path: resources/models/ch_ppocr_server_v2.0_rec_infer.onnx
+model_path: resources/models/ch_ppocr_mobile_v2.0_rec_infer.onnx
rec_img_shape: [3, 32, 320]
rec_batch_num: 6
diff --git a/python/tests/base.py b/python/tests/base.py
index 8b07ee7..274c72a 100644
--- a/python/tests/base.py
+++ b/python/tests/base.py
@@ -9,6 +9,7 @@ import sys
import yaml
package_name = 'rapidocr_onnxruntime'
+# package_name = 'rapidocr_openvino'
root_dir = Path(__file__).resolve().parent.parent
sys.path.append(str(root_dir))
@@ -23,4 +24,4 @@ def init_module(module_name, class_name):
def read_yaml(yaml_path):
with open(yaml_path, 'rb') as f:
data = yaml.load(f, Loader=yaml.Loader)
- return data
\ No newline at end of file
+ return data
diff --git a/python/tests/test_det.py b/python/tests/test_det.py
index b0f8f2a..be4a3c7 100644
--- a/python/tests/test_det.py
+++ b/python/tests/test_det.py
@@ -17,7 +17,7 @@ text_det = TextDetector(config)
def test_det():
- img_path = 'test_files/ch_en_num.jpg'
+ img_path = 'test_files/text_det.jpg'
img = cv2.imread(img_path)
diff --git a/python/tests/test_files/ch_en_num.jpg b/python/tests/test_files/text_det.jpg
similarity index 100%
rename from python/tests/test_files/ch_en_num.jpg
rename to python/tests/test_files/text_det.jpg
diff --git a/python/rapidocr_openvino/ch_ppocr_v2_rec/word_1.jpg b/python/tests/test_files/text_rec.jpg
similarity index 65%
rename from python/rapidocr_openvino/ch_ppocr_v2_rec/word_1.jpg
rename to python/tests/test_files/text_rec.jpg
index 934cc1c..cb5451e 100644
Binary files a/python/rapidocr_openvino/ch_ppocr_v2_rec/word_1.jpg and b/python/tests/test_files/text_rec.jpg differ
diff --git a/python/tests/test_rec_v2.py b/python/tests/test_rec_v2.py
new file mode 100644
index 0000000..4a45ab6
--- /dev/null
+++ b/python/tests/test_rec_v2.py
@@ -0,0 +1,24 @@
+# -*- encoding: utf-8 -*-
+# @Author: SWHL
+# @Contact: [email protected]
+import base
+import cv2
+
+
+module_name = 'ch_ppocr_v2_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_cls = TextRecognizer(config)
+
+
+def test_rec():
+ img_path = 'test_files/text_rec.jpg'
+ img = cv2.imread(img_path)
+ rec_res, elapse = text_cls([img])
+ assert rec_res[0][0] == 'ιŸ©ε›½ε°ι¦†'