π Awesome OCR multiple programing languages toolkits based on ONNX Runtime, OpenVINO, MNN, PaddlePaddle, TensorRT and PyTorch.
Optim code.
SWHLd9c17f3dab56
diff --git a/.github/workflows/gen_whl_to_pypi_rapidocr_ort.yml b/.github/workflows/gen_whl_to_pypi_rapidocr_ort.ymlindex f1baa9f..4f47f61 100644--- a/.github/workflows/gen_whl_to_pypi_rapidocr_ort.yml+++ b/.github/workflows/gen_whl_to_pypi_rapidocr_ort.yml@@ -8,6 +8,9 @@ on:- 'docs/doc_whl_rapidocr_ort.md'- 'python/setup_onnxruntime.py'+env:+ RESOURCES_URL: https://github.com/RapidAI/RapidOCR/releases/download/v1.1.0/required_for_whl_v1.1.0.zip+jobs:UnitTesting:runs-on: windows-latest@@ -23,7 +26,7 @@ jobs:uses: suisei-cn/actions-download-file@v1id: downloadfile3 # Remember to give an ID if you need the output filenamewith:- url: "https://github.com/RapidAI/RapidOCR/releases/download/v1.1.0/required_for_whl_v1.1.0.zip"+ url: $RESOURCES_URLtarget: ./- name: Decompress@@ -41,7 +44,8 @@ jobs:run: |set git_keep_path=%cur_dir%\python\resoureces\models\.gitkeepdel %git_keep_path%- move required_for_whl_v1.1.0\resources\models\* python\resources\models\+ copy required_for_whl_v1.1.0\resources\models\* python\rapidocr_onnxruntime\models\+ copy required_for_whl_v1.1.0\resources\models\* python\rapidocr_openvino\models\cd pythonpip install -r requirements.txtpip install onnxruntime==1.11.0 openvino==2022.2.0@@ -64,9 +68,15 @@ jobs:chmod 600 ~/.ssh/id_rsachmod 700 ~/.ssh && chmod 600 ~/.ssh/*- - name: Run setup_onnxruntime.py+ - name: Download modelsrun: |cd python+ wget $RESOURCES_URL+ unzip $RESOURCES_URL+ cp required_for_whl_v1.1.0/resources/models/*.onnx rapidocr_onnxruntime/models++ - name: Run setup_onnxruntime.py+ run: |mkdir rapidocr_onnxruntime_tmv rapidocr_onnxruntime rapidocr_onnxruntime_tmv rapidocr_onnxruntime_t rapidocr_onnxruntime@@ -78,15 +88,15 @@ jobs:python setup_onnxruntime.py bdist_wheelmv dist ../- # - name: Publish distribution π¦ to Test PyPI- # uses: pypa/[email protected]- # with:- # password: ${{ secrets.TEST_PYPI_API_TOKEN }}- # repository_url: https://test.pypi.org/legacy/- # packages_dir: dist/-- - name: Publish distribution π¦ to PyPI+ - name: Publish distribution π¦ to Test PyPIuses: pypa/[email protected]with:- password: ${{ secrets.PYPI_API_TOKEN }}+ password: ${{ secrets.TEST_PYPI_API_TOKEN }}+ repository_url: https://test.pypi.org/legacy/packages_dir: dist/++ # - name: Publish distribution π¦ to PyPI+ # uses: pypa/[email protected]+ # with:+ # password: ${{ secrets.PYPI_API_TOKEN }}+ # packages_dir: dist/diff --git a/.github/workflows/gen_whl_to_pypi_rapidocr_vino.yml b/.github/workflows/gen_whl_to_pypi_rapidocr_vino.ymlindex 2b7fa30..57695f8 100644--- a/.github/workflows/gen_whl_to_pypi_rapidocr_vino.yml+++ b/.github/workflows/gen_whl_to_pypi_rapidocr_vino.yml@@ -7,6 +7,9 @@ on:- 'python/rapidocr_openvino/**'- 'docs/doc_whl_rapidocr_vino.md'- 'python/setup_openvino.py'+env:+ RESOURCES_URL: https://github.com/RapidAI/RapidOCR/releases/download/v1.1.0/required_for_whl_v1.1.0.zip+jobs:UnitTesting:@@ -19,11 +22,11 @@ jobs:- name: Pull latest codeuses: actions/checkout@v3- - uses: suisei-cn/actions-download-file@v1+ - name: Download required_for_whl_v1.1.0+ uses: suisei-cn/actions-download-file@v1id: downloadfile3 # Remember to give an ID if you need the output filename- name: Download required_for_whl_v1.1.0with:- url: "https://github.com/RapidAI/RapidOCR/releases/download/v1.1.0/required_for_whl_v1.1.0.zip"+ url: $RESOURCES_URLtarget: ./- name: Decompress@@ -41,7 +44,8 @@ jobs:run: |set git_keep_path=%cur_dir%\python\resoureces\models\.gitkeepdel %git_keep_path%- move required_for_whl_v1.1.0\resources\models\* python\resources\models\+ copy required_for_whl_v1.1.0\resources\models\* python\rapidocr_onnxruntime\models\+ copy required_for_whl_v1.1.0\resources\models\* python\rapidocr_openvino\models\cd pythonpip install -r requirements.txtpip install onnxruntime==1.11.0 openvino==2022.2.0@@ -64,9 +68,15 @@ jobs:chmod 600 ~/.ssh/id_rsachmod 700 ~/.ssh && chmod 600 ~/.ssh/*- - name: Run setup_openvino.py+ - name: Download modelsrun: |cd python+ wget $RESOURCES_URL+ unzip $RESOURCES_URL+ cp required_for_whl_v1.1.0/resources/models/*.onnx rapidocr_openvino/models++ - name: Run setup_openvino.py+ run: |mkdir rapidocr_openvino_tmv rapidocr_openvino rapidocr_openvino_tmv rapidocr_openvino_t rapidocr_openvino@@ -78,15 +88,15 @@ jobs:python setup_openvino.py bdist_wheelmv dist ../- # - name: Publish distribution π¦ to Test PyPI- # uses: pypa/[email protected]- # with:- # password: ${{ secrets.TEST_PYPI_API_TOKEN }}- # repository_url: https://test.pypi.org/legacy/- # packages_dir: dist/-- - name: Publish distribution π¦ to PyPI+ - name: Publish distribution π¦ to Test PyPIuses: pypa/[email protected]with:- password: ${{ secrets.RAPIDOCR_OPENVINO }}+ password: ${{ secrets.TEST_PYPI_API_TOKEN }}+ repository_url: https://test.pypi.org/legacy/packages_dir: dist/++ # - name: Publish distribution π¦ to PyPI+ # uses: pypa/[email protected]+ # with:+ # password: ${{ secrets.RAPIDOCR_OPENVINO }}+ # packages_dir: dist/diff --git a/python/demo.py b/python/demo.pyindex 827cfb6..a742646 100644--- a/python/demo.py+++ b/python/demo.py@@ -88,7 +88,7 @@ def visualize(image_path, result, font_path="resources/fonts/FZYTK.TTF"):if __name__ == '__main__':- text_sys = RapidOCR('config.yaml')+ text_sys = RapidOCR()image_path = 'test_images/ch_en_num.jpg'img = cv2.imread(image_path)diff --git a/python/rapidocr_onnxruntime/ch_ppocr_v2_cls/config.yaml b/python/rapidocr_onnxruntime/ch_ppocr_v2_cls/config.yamlindex f4bce0b..0ec669e 100644--- a/python/rapidocr_onnxruntime/ch_ppocr_v2_cls/config.yaml+++ b/python/rapidocr_onnxruntime/ch_ppocr_v2_cls/config.yaml@@ -1,4 +1,4 @@-model_path: resources/models/ch_ppocr_mobile_v2.0_cls_infer.onnx+model_path: models/ch_ppocr_mobile_v2.0_cls_infer.onnxuse_cuda: false# Details of the params: https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.htmldiff --git a/python/rapidocr_onnxruntime/ch_ppocr_v2_cls/utils.py b/python/rapidocr_onnxruntime/ch_ppocr_v2_cls/utils.pyindex a15cd65..b37a8be 100644--- a/python/rapidocr_onnxruntime/ch_ppocr_v2_cls/utils.py+++ b/python/rapidocr_onnxruntime/ch_ppocr_v2_cls/utils.py@@ -18,6 +18,7 @@ import yamlfrom onnxruntime import (get_available_providers, get_device,SessionOptions, InferenceSession,GraphOptimizationLevel)+root_dir = Path(__file__).resolve().parent.parentclass OrtInferSession(object):@@ -39,6 +40,7 @@ class OrtInferSession(object):EP_list = [(cuda_ep, config[cuda_ep])]EP_list.append((cpu_ep, cpu_provider_options))+ config['model_path'] = str(root_dir / config['model_path'])self._verify_model(config['model_path'])self.session = InferenceSession(config['model_path'],sess_options=sess_opt,diff --git a/python/rapidocr_onnxruntime/ch_ppocr_v3_det/config.yaml b/python/rapidocr_onnxruntime/ch_ppocr_v3_det/config.yamlindex 60e7780..9bac869 100644--- a/python/rapidocr_onnxruntime/ch_ppocr_v3_det/config.yaml+++ b/python/rapidocr_onnxruntime/ch_ppocr_v3_det/config.yaml@@ -1,4 +1,4 @@-model_path: resources/models/ch_PP-OCRv3_det_infer.onnx+model_path: models/ch_PP-OCRv3_det_infer.onnxuse_cuda: falseCUDAExecutionProvider:diff --git a/python/rapidocr_onnxruntime/ch_ppocr_v3_det/text_detect.py b/python/rapidocr_onnxruntime/ch_ppocr_v3_det/text_detect.pyindex 7ce5293..c3ebf6e 100644--- a/python/rapidocr_onnxruntime/ch_ppocr_v3_det/text_detect.py+++ b/python/rapidocr_onnxruntime/ch_ppocr_v3_det/text_detect.py@@ -28,7 +28,7 @@ except:transform, read_yaml, OrtInferSession)-class TextDetector(object):+class TextDetector():def __init__(self, config):self.preprocess_op = create_operators(config['pre_process'])self.postprocess_op = DBPostProcess(**config['post_process'])diff --git a/python/rapidocr_onnxruntime/ch_ppocr_v3_det/utils.py b/python/rapidocr_onnxruntime/ch_ppocr_v3_det/utils.pyindex c2c9e17..d6511b1 100644--- a/python/rapidocr_onnxruntime/ch_ppocr_v3_det/utils.py+++ b/python/rapidocr_onnxruntime/ch_ppocr_v3_det/utils.py@@ -16,19 +16,20 @@# -*- encoding: utf-8 -*-# @Author: SWHL# @Contact: [email protected]-from pathlib import Pathimport sysimport warnings+from pathlib import Pathimport cv2import numpy as npimport pyclipperimport siximport yaml+from onnxruntime import (GraphOptimizationLevel, InferenceSession,+ SessionOptions, get_available_providers, get_device)from shapely.geometry import Polygon-from onnxruntime import (get_available_providers, get_device,- SessionOptions, InferenceSession,- GraphOptimizationLevel)++root_dir = Path(__file__).resolve().parent.parentclass OrtInferSession(object):@@ -50,6 +51,7 @@ class OrtInferSession(object):EP_list = [(cuda_ep, config[cuda_ep])]EP_list.append((cpu_ep, cpu_provider_options))+ config['model_path'] = str(root_dir / config['model_path'])self._verify_model(config['model_path'])self.session = InferenceSession(config['model_path'],sess_options=sess_opt,diff --git a/python/rapidocr_onnxruntime/ch_ppocr_v3_rec/config.yaml b/python/rapidocr_onnxruntime/ch_ppocr_v3_rec/config.yamlindex e2dab8c..4b71491 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/ch_PP-OCRv3_rec_infer.onnx+model_path: models/ch_PP-OCRv3_rec_infer.onnxuse_cuda: false# Details of the params: https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.htmldiff --git a/python/rapidocr_onnxruntime/ch_ppocr_v3_rec/utils.py b/python/rapidocr_onnxruntime/ch_ppocr_v3_rec/utils.pyindex 1938404..0860460 100644--- a/python/rapidocr_onnxruntime/ch_ppocr_v3_rec/utils.py+++ b/python/rapidocr_onnxruntime/ch_ppocr_v3_rec/utils.py@@ -1,14 +1,15 @@# -*- encoding: utf-8 -*-# @Author: SWHL# @Contact: [email protected]-from pathlib import Pathimport warnings+from pathlib import Pathimport numpy as npimport yaml-from onnxruntime import (get_available_providers, get_device,- SessionOptions, InferenceSession,- GraphOptimizationLevel)+from onnxruntime import (GraphOptimizationLevel, InferenceSession,+ SessionOptions, get_available_providers, get_device)++root_dir = Path(__file__).resolve().parent.parentclass OrtInferSession(object):@@ -30,6 +31,7 @@ class OrtInferSession(object):EP_list = [(cuda_ep, config[cuda_ep])]EP_list.append((cpu_ep, cpu_provider_options))+ config['model_path'] = str(root_dir / config['model_path'])self._verify_model(config['model_path'])self.session = InferenceSession(config['model_path'],sess_options=sess_opt,diff --git a/python/config.yaml b/python/rapidocr_onnxruntime/config.yamlsimilarity index 90%rename from python/config.yamlrename to python/rapidocr_onnxruntime/config.yamlindex 81de531..4b849b7 100644--- a/python/config.yaml+++ b/python/rapidocr_onnxruntime/config.yaml@@ -9,7 +9,7 @@ Global:Det:module_name: ch_ppocr_v3_detclass_name: TextDetector- model_path: resources/models/ch_PP-OCRv3_det_infer.onnx+ model_path: models/ch_PP-OCRv3_det_infer.onnxuse_cuda: false# Details of the params: https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html@@ -43,7 +43,7 @@ Det:Cls:module_name: ch_ppocr_v2_clsclass_name: TextClassifier- model_path: resources/models/ch_ppocr_mobile_v2.0_cls_infer.onnx+ model_path: models/ch_ppocr_mobile_v2.0_cls_infer.onnxuse_cuda: falseCUDAExecutionProvider:@@ -60,7 +60,7 @@ Cls:Rec:module_name: ch_ppocr_v3_recclass_name: TextRecognizer- model_path: resources/models/ch_PP-OCRv3_rec_infer.onnx+ model_path: models/ch_PP-OCRv3_rec_infer.onnxuse_cuda: falseCUDAExecutionProvider:diff --git a/python/resources/models/.gitkeep b/python/rapidocr_onnxruntime/models/.gitkeepsimilarity index 100%rename from python/resources/models/.gitkeeprename to python/rapidocr_onnxruntime/models/.gitkeepdiff --git a/python/rapidocr_onnxruntime/rapid_ocr_api.py b/python/rapidocr_onnxruntime/rapid_ocr_api.pyindex 914e8a9..0eadb57 100644--- a/python/rapidocr_onnxruntime/rapid_ocr_api.py+++ b/python/rapidocr_onnxruntime/rapid_ocr_api.py@@ -14,8 +14,8 @@ root_dir = Path(__file__).resolve().parentsys.path.append(str(root_dir))-class RapidOCR(object):- def __init__(self, config_path):+class RapidOCR():+ def __init__(self, config_path=str(root_dir / 'config.yaml')):super(RapidOCR).__init__()if not Path(config_path).exists():raise FileExistsError(f'{config_path} does not exist!')diff --git a/python/rapidocr_openvino/ch_ppocr_v2_cls/config.yaml b/python/rapidocr_openvino/ch_ppocr_v2_cls/config.yamlindex f4bce0b..0ec669e 100644--- a/python/rapidocr_openvino/ch_ppocr_v2_cls/config.yaml+++ b/python/rapidocr_openvino/ch_ppocr_v2_cls/config.yaml@@ -1,4 +1,4 @@-model_path: resources/models/ch_ppocr_mobile_v2.0_cls_infer.onnx+model_path: models/ch_ppocr_mobile_v2.0_cls_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_cls/utils.py b/python/rapidocr_openvino/ch_ppocr_v2_cls/utils.pyindex 37ce4c4..08fae56 100644--- a/python/rapidocr_openvino/ch_ppocr_v2_cls/utils.py+++ b/python/rapidocr_openvino/ch_ppocr_v2_cls/utils.py@@ -16,10 +16,14 @@ import yamlfrom openvino.runtime import Core+root_dir = Path(__file__).resolve().parent.parent++class OpenVINOInferSession(object):def __init__(self, config):ie = Core()+ config['model_path'] = str(root_dir / config['model_path'])self._verify_model(config['model_path'])model_onnx = ie.read_model(config['model_path'])compile_model = ie.compile_model(model=model_onnx, device_name='CPU')diff --git a/python/rapidocr_openvino/ch_ppocr_v3_det/config.yaml b/python/rapidocr_openvino/ch_ppocr_v3_det/config.yamlindex c871700..7ed39a4 100644--- a/python/rapidocr_openvino/ch_ppocr_v3_det/config.yaml+++ b/python/rapidocr_openvino/ch_ppocr_v3_det/config.yaml@@ -1,4 +1,4 @@-model_path: resources/models/ch_PP-OCRv3_det_infer.onnx+model_path: models/ch_PP-OCRv3_det_infer.onnxpre_process:DetResizeForTest:diff --git a/python/rapidocr_openvino/ch_ppocr_v3_det/utils.py b/python/rapidocr_openvino/ch_ppocr_v3_det/utils.pyindex 3d57926..0e2888a 100644--- a/python/rapidocr_openvino/ch_ppocr_v3_det/utils.py+++ b/python/rapidocr_openvino/ch_ppocr_v3_det/utils.py@@ -27,11 +27,14 @@ import yamlfrom openvino.runtime import Corefrom shapely.geometry import Polygon+root_dir = Path(__file__).resolve().parent.parent+class OpenVINOInferSession(object):def __init__(self, config):ie = Core()+ config['model_path'] = str(root_dir / config['model_path'])self._verify_model(config['model_path'])model_onnx = ie.read_model(config['model_path'])compile_model = ie.compile_model(model=model_onnx, device_name='CPU')diff --git a/python/rapidocr_openvino/ch_ppocr_v3_rec/config.yaml b/python/rapidocr_openvino/ch_ppocr_v3_rec/config.yamlindex a9e4c13..5248e73 100644--- a/python/rapidocr_openvino/ch_ppocr_v3_rec/config.yaml+++ b/python/rapidocr_openvino/ch_ppocr_v3_rec/config.yaml@@ -1,4 +1,4 @@-model_path: resources/models/ch_PP-OCRv3_rec_infer.onnx+model_path: models/ch_PP-OCRv3_rec_infer.onnxrec_img_shape: [3, 32, 320]rec_batch_num: 6diff --git a/python/rapidocr_openvino/ch_ppocr_v3_rec/utils.py b/python/rapidocr_openvino/ch_ppocr_v3_rec/utils.pyindex e671f6e..2e23ce0 100644--- a/python/rapidocr_openvino/ch_ppocr_v3_rec/utils.py+++ b/python/rapidocr_openvino/ch_ppocr_v3_rec/utils.py@@ -7,9 +7,14 @@ import yamlfrom openvino.runtime import Core+root_dir = Path(__file__).resolve().parent.parent++class OpenVINOInferSession(object):def __init__(self, config):ie = Core()++ config['model_path'] = str(root_dir / config['model_path'])self._verify_model(config['model_path'])model_onnx = ie.read_model(config['model_path'])compile_model = ie.compile_model(model=model_onnx, device_name='CPU')diff --git a/python/rapidocr_openvino/config.yaml b/python/rapidocr_openvino/config.yamlnew file mode 100644index 0000000..4b849b7--- /dev/null+++ b/python/rapidocr_openvino/config.yaml@@ -0,0 +1,73 @@+Global:+ text_score: 0.5+ use_angle_cls: true+ use_text_det: true+ print_verbose: true+ min_height: 30+ width_height_ratio: 8++Det:+ module_name: ch_ppocr_v3_det+ class_name: TextDetector+ model_path: models/ch_PP-OCRv3_det_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++ 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++Cls:+ module_name: ch_ppocr_v2_cls+ class_name: TextClassifier+ model_path: models/ch_ppocr_mobile_v2.0_cls_infer.onnx++ use_cuda: false+ 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']++Rec:+ module_name: ch_ppocr_v3_rec+ class_name: TextRecognizer+ model_path: models/ch_PP-OCRv3_rec_infer.onnx++ use_cuda: false+ 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_openvino/models/.gitkeep b/python/rapidocr_openvino/models/.gitkeepnew file mode 100644index 0000000..e69de29diff --git a/python/rapidocr_openvino/rapid_ocr_api.py b/python/rapidocr_openvino/rapid_ocr_api.pyindex 914e8a9..0566206 100644--- a/python/rapidocr_openvino/rapid_ocr_api.py+++ b/python/rapidocr_openvino/rapid_ocr_api.py@@ -15,7 +15,7 @@ sys.path.append(str(root_dir))class RapidOCR(object):- def __init__(self, config_path):+ def __init__(self, config_path=str(root_dir / 'config.yaml')):super(RapidOCR).__init__()if not Path(config_path).exists():raise FileExistsError(f'{config_path} does not exist!')diff --git a/python/setup_onnxruntime.py b/python/setup_onnxruntime.pyindex a2514fd..944235f 100644--- a/python/setup_onnxruntime.py+++ b/python/setup_onnxruntime.py@@ -14,8 +14,7 @@ def get_latest_version(package_name):output = list(filter(lambda x: len(x) > 0, output.split('\n')))latest_version = output[0].split(' ')[-1][1:-1]return latest_version- else:- return None+ return Nonedef version_add_one(version, add_loc=-1):@@ -25,26 +24,25 @@ def version_add_one(version, add_loc=-1):version_list[add_loc] = mini_versionnew_version = '.'.join(version_list)return new_version- else:- return None+ return '0.0.0'def get_readme():root_dir = Path(__file__).resolve().parent.parentreadme_path = str(root_dir / 'docs' / 'doc_whl_rapidocr_ort.md')print(readme_path)- with open(readme_path, 'r') as f:+ with open(readme_path, 'r', encoding='utf-8') as f:readme = f.read()return readme-module_name = 'rapidocr_onnxruntime'-latest_version = get_latest_version(module_name)-version_num = version_add_one(latest_version)+MODULE_NAME = 'rapidocr_onnxruntime'+latest_version = get_latest_version(MODULE_NAME)+VERSION_NUM = version_add_one(latest_version)setuptools.setup(- name=module_name,- version=version_num,+ name=MODULE_NAME,+ version=VERSION_NUM,platforms="Any",description="RapidOCR",long_description=get_readme(),@@ -57,10 +55,11 @@ setuptools.setup(install_requires=["pyclipper>=1.2.1", "onnxruntime>=1.7.0","opencv_python>=4.5.1.48", "numpy>=1.19.3","six>=1.15.0", "Shapely>=1.7.1"],- package_dir={'': module_name},- packages=setuptools.find_packages(where=module_name),+ package_dir={'': MODULE_NAME},+ packages=setuptools.find_namespace_packages(where=MODULE_NAME),+ package_data={'': ['*.onnx', '*.yaml']},keywords=[- 'ocr text_detection text_recognition db onnxruntime paddleocr openvino'+ 'ocr,text_detection,text_recognition,db,onnxruntime,paddleocr,openvino,rapidocr'],classifiers=['Programming Language :: Python :: 3.6',diff --git a/python/setup_openvino.py b/python/setup_openvino.pyindex 56396ec..b307965 100644--- a/python/setup_openvino.py+++ b/python/setup_openvino.py@@ -14,8 +14,7 @@ def get_latest_version(package_name):output = list(filter(lambda x: len(x) > 0, output.split('\n')))latest_version = output[0].split(' ')[-1][1:-1]return latest_version- else:- return None+ return Nonedef version_add_one(version, add_loc=-1):@@ -25,8 +24,7 @@ def version_add_one(version, add_loc=-1):version_list[add_loc] = mini_versionnew_version = '.'.join(version_list)return new_version- else:- return '0.0.0'+ return '0.0.0'def get_readme():@@ -38,13 +36,13 @@ def get_readme():return readme-module_name = 'rapidocr_openvino'-latest_version = get_latest_version(module_name)-version_num = version_add_one(latest_version)+MODULE_NAME = 'rapidocr_openvino'+latest_version = get_latest_version(MODULE_NAME)+VERSION_NUM = version_add_one(latest_version)setuptools.setup(- name=module_name,- version=version_num,+ name=MODULE_NAME,+ version=VERSION_NUM,platforms="Any",description="RapidOCR",long_description=get_readme(),@@ -53,15 +51,15 @@ setuptools.setup(author_email="[email protected]",url="https://github.com/RapidAI/RapidOCR",license='Apache-2.0',- install_requires=["pyclipper>=1.2.1", "openvino==2022.2.0.dev20220829",+ include_package_data=True,+ install_requires=["pyclipper>=1.2.1", "openvino>=2022.2.0","opencv_python>=4.5.1.48", "numpy>=1.19.3","six>=1.15.0", "Shapely>=1.7.1"],- include_package_data=True,- package_data={"": ["*.txt"]},- package_dir={'': module_name},- packages=setuptools.find_packages(where=module_name),+ package_dir={'': MODULE_NAME},+ packages=setuptools.find_namespace_packages(where=MODULE_NAME),+ package_data={'': ['*.onnx', '*.yaml', '*.txt']},keywords=[- 'ocr text_detection text_recognition db onnxruntime paddleocr openvino'+ 'ocr,text_detection,text_recognition,db,onnxruntime,paddleocr,openvino,rapidocr'],classifiers=['Programming Language :: Python :: 3.6',diff --git a/python/tests/base_module.py b/python/tests/base_module.pyindex eccf51b..6cc2001 100644--- a/python/tests/base_module.py+++ b/python/tests/base_module.py@@ -12,9 +12,10 @@ class BaseModule(object):def __init__(self, package_name: str = 'rapidocr_onnxruntime'):self.package_name = package_nameself.root_dir = Path(__file__).resolve().parent.parent+ self.package_dir = self.root_dir / self.package_namesys.path.append(str(self.root_dir))- sys.path.append(str(self.root_dir / self.package_name))+ sys.path.append(str(self.package_dir))def init_module(self, module_name: str, class_name: str = None):if class_name is None:diff --git a/python/tests/benchmark/config.yaml b/python/tests/benchmark/config.yamlindex 5b84273..fd7717e 100644--- a/python/tests/benchmark/config.yaml+++ b/python/tests/benchmark/config.yaml@@ -8,7 +8,7 @@ Global:Det:module_name: ch_ppocr_v3_detclass_name: TextDetector- model_path: resources/models/ch_PP-OCRv3_det_infer.onnx+ model_path: models/ch_PP-OCRv3_det_infer.onnxuse_cuda: false# Details of the params: https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html@@ -42,7 +42,7 @@ Det:Cls:module_name: ch_ppocr_v2_clsclass_name: TextClassifier- model_path: resources/models/ch_ppocr_mobile_v2.0_cls_infer.onnx+ model_path: models/ch_ppocr_mobile_v2.0_cls_infer.onnxuse_cuda: falseCUDAExecutionProvider:@@ -59,7 +59,7 @@ Cls:Rec:module_name: ch_ppocr_v3_recclass_name: TextRecognizer- model_path: resources/models/ch_PP-OCRv3_rec_infer.onnx+ model_path: models/ch_PP-OCRv3_rec_infer.onnxuse_cuda: falseCUDAExecutionProvider:diff --git a/python/tests/benchmark/config_gpu.yaml b/python/tests/benchmark/config_gpu.yamlindex eaca238..66d7a64 100644--- a/python/tests/benchmark/config_gpu.yaml+++ b/python/tests/benchmark/config_gpu.yaml@@ -8,7 +8,7 @@ Global:Det:module_name: ch_ppocr_v3_detclass_name: TextDetector- model_path: resources/models/ch_PP-OCRv3_det_infer.onnx+ model_path: models/ch_PP-OCRv3_det_infer.onnxuse_cuda: true# Details of the params: https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html@@ -41,7 +41,7 @@ Det:Cls:module_name: ch_ppocr_v2_clsclass_name: TextClassifier- model_path: resources/models/ch_ppocr_mobile_v2.0_cls_infer.onnx+ model_path: models/ch_ppocr_mobile_v2.0_cls_infer.onnxuse_cuda: trueCUDAExecutionProvider:@@ -58,7 +58,7 @@ Cls:Rec:module_name: ch_ppocr_v3_recclass_name: TextRecognizer- model_path: resources/models/ch_PP-OCRv3_rec_infer.onnx+ model_path: models/ch_PP-OCRv3_rec_infer.onnxuse_cuda: trueCUDAExecutionProvider:diff --git a/python/tests/test_cls.py b/python/tests/test_cls.pyindex 84fb82a..ed4cc6c 100644--- a/python/tests/test_cls.py+++ b/python/tests/test_cls.py@@ -13,9 +13,9 @@ class TestONNXRuntime():TextClassifier = base.init_module(module_name, class_name)- yaml_path = base.root_dir / base.package_name / module_name / 'config.yaml'+ yaml_path = base.package_dir / module_name / 'config.yaml'config = base.read_yaml(str(yaml_path))- config['model_path'] = str(base.root_dir / config['model_path'])+ config['model_path'] = str(base.package_dir / config['model_path'])text_cls = TextClassifier(config)@@ -34,9 +34,9 @@ class TestOpenVINO():TextClassifier = base.init_module(module_name, class_name)- yaml_path = base.root_dir / base.package_name / module_name / 'config.yaml'+ yaml_path = base.package_dir / module_name / 'config.yaml'config = base.read_yaml(str(yaml_path))- config['model_path'] = str(base.root_dir / config['model_path'])+ config['model_path'] = str(base.package_dir / config['model_path'])text_cls = TextClassifier(config)diff --git a/python/tests/test_det.py b/python/tests/test_det.pyindex 5033474..1e03a06 100644--- a/python/tests/test_det.py+++ b/python/tests/test_det.py@@ -12,9 +12,9 @@ class TestONNXRuntime():base = BaseModule(package_name='rapidocr_onnxruntime')TextDetector = base.init_module(module_name, class_name)- yaml_path = base.root_dir / base.package_name / module_name / 'config.yaml'+ yaml_path = base.package_dir / module_name / 'config.yaml'config = base.read_yaml(str(yaml_path))- config['model_path'] = str(base.root_dir / config['model_path'])+ config['model_path'] = str(base.package_dir / config['model_path'])text_det = TextDetector(config)@@ -34,9 +34,9 @@ class TestOpenVINO():base = BaseModule(package_name='rapidocr_openvino')TextDetector = base.init_module(module_name, class_name)- yaml_path = base.root_dir / base.package_name / module_name / 'config.yaml'+ yaml_path = base.package_dir / module_name / 'config.yaml'config = base.read_yaml(str(yaml_path))- config['model_path'] = str(base.root_dir / config['model_path'])+ config['model_path'] = str(base.package_dir / config['model_path'])text_det = TextDetector(config)diff --git a/python/tests/test_rec.py b/python/tests/test_rec.pyindex 71a10bc..34b4041 100644--- a/python/tests/test_rec.py+++ b/python/tests/test_rec.py@@ -12,9 +12,9 @@ class TestONNXRuntime():base = BaseModule(package_name='rapidocr_onnxruntime')TextRecognizer = base.init_module(module_name, class_name)- yaml_path = base.root_dir / base.package_name / module_name / 'config.yaml'+ yaml_path = base.package_dir / module_name / 'config.yaml'config = base.read_yaml(str(yaml_path))- config['model_path'] = str(base.root_dir / config['model_path'])+ config['model_path'] = str(base.package_dir / config['model_path'])text_rec = TextRecognizer(config)@@ -32,9 +32,9 @@ class TestOpenVINO():base = BaseModule(package_name='rapidocr_openvino')TextRecognizer = base.init_module(module_name, class_name)- yaml_path = base.root_dir / base.package_name / module_name / 'config.yaml'+ yaml_path = base.package_dir / module_name / 'config.yaml'config = base.read_yaml(str(yaml_path))- config['model_path'] = str(base.root_dir / config['model_path'])+ config['model_path'] = str(base.package_dir / config['model_path'])text_rec = TextRecognizer(config)