π Awesome OCR multiple programing languages toolkits based on ONNX Runtime, OpenVINO, MNN, PaddlePaddle, TensorRT and PyTorch.
chore: Optimize code structure
SWHL6b60256ee77a
diff --git a/python/rapidocr_onnxruntime/ch_ppocr_v2_cls/__init__.py b/python/rapidocr_onnxruntime/ch_ppocr_cls/__init__.pysimilarity index 100%rename from python/rapidocr_onnxruntime/ch_ppocr_v2_cls/__init__.pyrename to python/rapidocr_onnxruntime/ch_ppocr_cls/__init__.pydiff --git a/python/rapidocr_onnxruntime/ch_ppocr_v2_cls/text_cls.py b/python/rapidocr_onnxruntime/ch_ppocr_cls/text_cls.pysimilarity index 100%rename from python/rapidocr_onnxruntime/ch_ppocr_v2_cls/text_cls.pyrename to python/rapidocr_onnxruntime/ch_ppocr_cls/text_cls.pydiff --git a/python/rapidocr_onnxruntime/ch_ppocr_v2_cls/utils.py b/python/rapidocr_onnxruntime/ch_ppocr_cls/utils.pysimilarity index 100%rename from python/rapidocr_onnxruntime/ch_ppocr_v2_cls/utils.pyrename to python/rapidocr_onnxruntime/ch_ppocr_cls/utils.pydiff --git a/python/rapidocr_onnxruntime/ch_ppocr_v3_det/__init__.py b/python/rapidocr_onnxruntime/ch_ppocr_det/__init__.pysimilarity index 100%rename from python/rapidocr_onnxruntime/ch_ppocr_v3_det/__init__.pyrename to python/rapidocr_onnxruntime/ch_ppocr_det/__init__.pydiff --git a/python/rapidocr_onnxruntime/ch_ppocr_v3_det/text_detect.py b/python/rapidocr_onnxruntime/ch_ppocr_det/text_detect.pysimilarity index 100%rename from python/rapidocr_onnxruntime/ch_ppocr_v3_det/text_detect.pyrename to python/rapidocr_onnxruntime/ch_ppocr_det/text_detect.pydiff --git a/python/rapidocr_onnxruntime/ch_ppocr_v3_det/utils.py b/python/rapidocr_onnxruntime/ch_ppocr_det/utils.pysimilarity index 100%rename from python/rapidocr_onnxruntime/ch_ppocr_v3_det/utils.pyrename to python/rapidocr_onnxruntime/ch_ppocr_det/utils.pydiff --git a/python/rapidocr_onnxruntime/ch_ppocr_v3_rec/__init__.py b/python/rapidocr_onnxruntime/ch_ppocr_rec/__init__.pysimilarity index 100%rename from python/rapidocr_onnxruntime/ch_ppocr_v3_rec/__init__.pyrename to python/rapidocr_onnxruntime/ch_ppocr_rec/__init__.pydiff --git a/python/rapidocr_onnxruntime/ch_ppocr_v3_rec/text_recognize.py b/python/rapidocr_onnxruntime/ch_ppocr_rec/text_recognize.pysimilarity index 100%rename from python/rapidocr_onnxruntime/ch_ppocr_v3_rec/text_recognize.pyrename to python/rapidocr_onnxruntime/ch_ppocr_rec/text_recognize.pydiff --git a/python/rapidocr_onnxruntime/ch_ppocr_v3_rec/utils.py b/python/rapidocr_onnxruntime/ch_ppocr_rec/utils.pysimilarity index 100%rename from python/rapidocr_onnxruntime/ch_ppocr_v3_rec/utils.pyrename to python/rapidocr_onnxruntime/ch_ppocr_rec/utils.pydiff --git a/python/rapidocr_onnxruntime/ch_ppocr_v2_cls/config.yaml b/python/rapidocr_onnxruntime/ch_ppocr_v2_cls/config.yamldeleted file mode 100644index 0ec669e..0000000--- a/python/rapidocr_onnxruntime/ch_ppocr_v2_cls/config.yaml+++ /dev/null@@ -1,14 +0,0 @@-model_path: models/ch_ppocr_mobile_v2.0_cls_infer.onnx--use_cuda: false-# Details of the params: https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html-CUDAExecutionProvider:- device_id: 0- arena_extend_strategy: kNextPowerOfTwo- cudnn_conv_algo_search: EXHAUSTIVE- do_copy_in_default_stream: true--cls_image_shape: [3, 48, 192]-cls_batch_num: 6-cls_thresh: 0.9-label_list: ['0', '180']\ No newline at end of filediff --git a/python/rapidocr_onnxruntime/ch_ppocr_v3_det/config.yaml b/python/rapidocr_onnxruntime/ch_ppocr_v3_det/config.yamldeleted file mode 100644index 259ef4a..0000000--- a/python/rapidocr_onnxruntime/ch_ppocr_v3_det/config.yaml+++ /dev/null@@ -1,29 +0,0 @@-model_path: models/ch_PP-OCRv4_det_infer.onnx--use_cuda: false-CUDAExecutionProvider:- device_id: 0- arena_extend_strategy: kNextPowerOfTwo- cudnn_conv_algo_search: EXHAUSTIVE- do_copy_in_default_stream: true--pre_process:- DetResizeForTest:- limit_side_len: 736- limit_type: min- NormalizeImage:- std: [0.229, 0.224, 0.225]- mean: [0.485, 0.456, 0.406]- scale: 1./255.- order: hwc- ToCHWImage:- KeepKeys:- keep_keys: ['image', 'shape']--post_process:- thresh: 0.3- box_thresh: 0.5- max_candidates: 1000- unclip_ratio: 1.6- use_dilation: true- score_mode: "fast"diff --git a/python/rapidocr_onnxruntime/ch_ppocr_v3_rec/config.yaml b/python/rapidocr_onnxruntime/ch_ppocr_v3_rec/config.yamldeleted file mode 100644index 5a91403..0000000--- a/python/rapidocr_onnxruntime/ch_ppocr_v3_rec/config.yaml+++ /dev/null@@ -1,12 +0,0 @@-model_path: models/ch_PP-OCRv4_rec_infer.onnx--use_cuda: false-# Details of the params: https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html-CUDAExecutionProvider:- device_id: 0- arena_extend_strategy: kNextPowerOfTwo- cudnn_conv_algo_search: EXHAUSTIVE- do_copy_in_default_stream: true--rec_img_shape: [3, 48, 320]-rec_batch_num: 6diff --git a/python/rapidocr_onnxruntime/main.py b/python/rapidocr_onnxruntime/main.pyindex 262e299..f53a7d7 100644--- a/python/rapidocr_onnxruntime/main.py+++ b/python/rapidocr_onnxruntime/main.py@@ -8,9 +8,9 @@ from typing import Any, List, Optional, Tuple, Unionimport cv2import numpy as np-from .ch_ppocr_v2_cls import TextClassifier-from .ch_ppocr_v3_det import TextDetector-from .ch_ppocr_v3_rec import TextRecognizer+from .ch_ppocr_cls import TextClassifier+from .ch_ppocr_det import TextDetector+from .ch_ppocr_rec import TextRecognizerfrom .utils import (LoadImage,UpdateParameters,diff --git a/python/tests/test_ort.py b/python/tests/test_ort.pyindex b7304d4..0814da3 100644--- a/python/tests/test_ort.py+++ b/python/tests/test_ort.py@@ -8,7 +8,6 @@ from pathlib import Pathimport cv2import numpy as npimport pytest-from base_module import BaseModuleroot_dir = Path(__file__).resolve().parent.parentsys.path.append(str(root_dir))@@ -208,59 +207,3 @@ def test_input_three_ndim_one_channel():assert result[0][1] == "ζ£εδΏι"assert len(result) == 17---def test_det():- module_name = "ch_ppocr_v3_det"- class_name = "TextDetector"-- base = BaseModule(package_name)- TextDetector = base.init_module(module_name, class_name)-- yaml_path = base.package_dir / module_name / "config.yaml"- config = base.read_yaml(str(yaml_path))- config["model_path"] = str(base.package_dir / config["model_path"])-- text_det = TextDetector(config)- img_path = base.tests_dir / "test_files" / "text_det.jpg"- img = cv2.imread(str(img_path))- dt_boxes, elapse = text_det(img)- assert dt_boxes.shape == (18, 4, 2)---def test_cls():- module_name = "ch_ppocr_v2_cls"- class_name = "TextClassifier"-- base = BaseModule(package_name=package_name)- TextClassifier = base.init_module(module_name, class_name)-- yaml_path = base.package_dir / module_name / "config.yaml"- config = base.read_yaml(str(yaml_path))- config["model_path"] = str(base.package_dir / config["model_path"])-- text_cls = TextClassifier(config)-- img_path = base.tests_dir / "test_files" / "text_cls.jpg"- img = cv2.imread(str(img_path))- result = text_cls([img])- assert result[1][0][0] == "180"---def test_rec():- module_name = "ch_ppocr_v3_rec"- class_name = "TextRecognizer"-- base = BaseModule(package_name)- TextRecognizer = base.init_module(module_name, class_name)-- yaml_path = base.package_dir / module_name / "config.yaml"- config = base.read_yaml(str(yaml_path))- config["model_path"] = str(base.package_dir / config["model_path"])-- text_rec = TextRecognizer(config)-- img_path = base.tests_dir / "test_files" / "text_rec.jpg"- img = cv2.imread(str(img_path))- rec_res, elapse = text_rec(img)- assert rec_res[0][0] == "ι©ε½ε°ι¦"