diff --git a/python/rapidocr_onnxruntime/ch_ppocr_v2_cls/__init__.py b/python/rapidocr_onnxruntime/ch_ppocr_cls/__init__.py similarity index 100% rename from python/rapidocr_onnxruntime/ch_ppocr_v2_cls/__init__.py rename to python/rapidocr_onnxruntime/ch_ppocr_cls/__init__.py diff --git a/python/rapidocr_onnxruntime/ch_ppocr_v2_cls/text_cls.py b/python/rapidocr_onnxruntime/ch_ppocr_cls/text_cls.py similarity index 100% rename from python/rapidocr_onnxruntime/ch_ppocr_v2_cls/text_cls.py rename to python/rapidocr_onnxruntime/ch_ppocr_cls/text_cls.py diff --git a/python/rapidocr_onnxruntime/ch_ppocr_v2_cls/utils.py b/python/rapidocr_onnxruntime/ch_ppocr_cls/utils.py similarity index 100% rename from python/rapidocr_onnxruntime/ch_ppocr_v2_cls/utils.py rename to python/rapidocr_onnxruntime/ch_ppocr_cls/utils.py diff --git a/python/rapidocr_onnxruntime/ch_ppocr_v3_det/__init__.py b/python/rapidocr_onnxruntime/ch_ppocr_det/__init__.py similarity index 100% rename from python/rapidocr_onnxruntime/ch_ppocr_v3_det/__init__.py rename to python/rapidocr_onnxruntime/ch_ppocr_det/__init__.py diff --git a/python/rapidocr_onnxruntime/ch_ppocr_v3_det/text_detect.py b/python/rapidocr_onnxruntime/ch_ppocr_det/text_detect.py similarity index 100% rename from python/rapidocr_onnxruntime/ch_ppocr_v3_det/text_detect.py rename to python/rapidocr_onnxruntime/ch_ppocr_det/text_detect.py diff --git a/python/rapidocr_onnxruntime/ch_ppocr_v3_det/utils.py b/python/rapidocr_onnxruntime/ch_ppocr_det/utils.py similarity index 100% rename from python/rapidocr_onnxruntime/ch_ppocr_v3_det/utils.py rename to python/rapidocr_onnxruntime/ch_ppocr_det/utils.py diff --git a/python/rapidocr_onnxruntime/ch_ppocr_v3_rec/__init__.py b/python/rapidocr_onnxruntime/ch_ppocr_rec/__init__.py similarity index 100% rename from python/rapidocr_onnxruntime/ch_ppocr_v3_rec/__init__.py rename to python/rapidocr_onnxruntime/ch_ppocr_rec/__init__.py diff --git a/python/rapidocr_onnxruntime/ch_ppocr_v3_rec/text_recognize.py b/python/rapidocr_onnxruntime/ch_ppocr_rec/text_recognize.py similarity index 100% rename from python/rapidocr_onnxruntime/ch_ppocr_v3_rec/text_recognize.py rename to python/rapidocr_onnxruntime/ch_ppocr_rec/text_recognize.py diff --git a/python/rapidocr_onnxruntime/ch_ppocr_v3_rec/utils.py b/python/rapidocr_onnxruntime/ch_ppocr_rec/utils.py similarity index 100% rename from python/rapidocr_onnxruntime/ch_ppocr_v3_rec/utils.py rename to python/rapidocr_onnxruntime/ch_ppocr_rec/utils.py diff --git a/python/rapidocr_onnxruntime/ch_ppocr_v2_cls/config.yaml b/python/rapidocr_onnxruntime/ch_ppocr_v2_cls/config.yaml deleted file mode 100644 index 0ec669ec8..000000000 --- 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 file diff --git a/python/rapidocr_onnxruntime/ch_ppocr_v3_det/config.yaml b/python/rapidocr_onnxruntime/ch_ppocr_v3_det/config.yaml deleted file mode 100644 index 259ef4a35..000000000 --- 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.yaml deleted file mode 100644 index 5a91403b4..000000000 --- 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: 6 diff --git a/python/rapidocr_onnxruntime/main.py b/python/rapidocr_onnxruntime/main.py index 262e299c2..f53a7d7b8 100644 --- a/python/rapidocr_onnxruntime/main.py +++ b/python/rapidocr_onnxruntime/main.py @@ -8,9 +8,9 @@ import cv2 import 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 TextRecognizer from .utils import ( LoadImage, UpdateParameters, diff --git a/python/tests/test_ort.py b/python/tests/test_ort.py index b7304d4cc..0814da33e 100644 --- a/python/tests/test_ort.py +++ b/python/tests/test_ort.py @@ -8,7 +8,6 @@ import cv2 import numpy as np import pytest -from base_module import BaseModule root_dir = Path(__file__).resolve().parent.parent sys.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] == "韩国小馆"