π 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.yamlindex 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: falseCUDAExecutionProvider:device_id: 0arena_extend_strategy: kNextPowerOfTwo- gpu_mem_limit: 2 * 1024 * 1024 * 1024cudnn_conv_algo_search: EXHAUSTIVEdo_copy_in_default_stream: truediff --git a/python/rapidocr_onnxruntime/ch_ppocr_v2_rec/config.yaml b/python/rapidocr_onnxruntime/ch_ppocr_v2_rec/config.yamlindex 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.onnxuse_cuda: false# Details of the params: https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.htmldiff --git a/python/rapidocr_openvino/ch_ppocr_v2_det/config.yaml b/python/rapidocr_openvino/ch_ppocr_v2_det/config.yamlindex 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.onnxpre_process:DetResizeForTest:diff --git a/python/rapidocr_openvino/ch_ppocr_v2_rec/config.yaml b/python/rapidocr_openvino/ch_ppocr_v2_rec/config.yamlindex 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.onnxrec_img_shape: [3, 32, 320]rec_batch_num: 6diff --git a/python/tests/base.py b/python/tests/base.pyindex 8b07ee7..274c72a 100644--- a/python/tests/base.py+++ b/python/tests/base.py@@ -9,6 +9,7 @@ import sysimport yamlpackage_name = 'rapidocr_onnxruntime'+# package_name = 'rapidocr_openvino'root_dir = Path(__file__).resolve().parent.parentsys.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 datadiff --git a/python/tests/test_det.py b/python/tests/test_det.pyindex 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.jpgsimilarity index 100%rename from python/tests/test_files/ch_en_num.jpgrename to python/tests/test_files/text_det.jpgdiff --git a/python/rapidocr_openvino/ch_ppocr_v2_rec/word_1.jpg b/python/tests/test_files/text_rec.jpgsimilarity index 65%rename from python/rapidocr_openvino/ch_ppocr_v2_rec/word_1.jpgrename to python/tests/test_files/text_rec.jpgindex 934cc1c..cb5451e 100644Binary files a/python/rapidocr_openvino/ch_ppocr_v2_rec/word_1.jpg and b/python/tests/test_files/text_rec.jpg differdiff --git a/python/tests/test_rec_v2.py b/python/tests/test_rec_v2.pynew file mode 100644index 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] == 'ι©ε½ε°ι¦'