Skip to content

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

Add rapidocr_openvino whl

SWHL09d78c2c0e27
diff --git a/.github/workflows/gen_whl_to_pypi.yml b/.github/workflows/gen_whl_to_pypi_onnxruntime.yml
similarity index 86%
rename from .github/workflows/gen_whl_to_pypi.yml
rename to .github/workflows/gen_whl_to_pypi_onnxruntime.yml
index 24dbba1..faeb58a 100644
--- a/.github/workflows/gen_whl_to_pypi.yml
+++ b/.github/workflows/gen_whl_to_pypi_onnxruntime.yml
@@ -1,12 +1,12 @@
-name: Package whl files to push to pypi
+name: push rapidocr_onnxruntime to pypi
on:
push:
branches: [ main ]
paths:
- 'python/rapidocr_onnxruntime/**'
- - 'docs/doc_whl_en.md'
- - 'python/setup.py'
+ - 'docs/doc_whl_en_onnxruntime.md'
+ - 'python/setup_onnxruntime.py'
jobs:
build:
@@ -24,7 +24,7 @@ jobs:
chmod 600 ~/.ssh/id_rsa
chmod 700 ~/.ssh && chmod 600 ~/.ssh/*
- - name: Run setup.py
+ - name: Run setup_onnxruntime.py
run: |
cd python
mkdir rapidocr_onnxruntime_t
@@ -35,7 +35,7 @@ jobs:
cd ..
python -m pip install --upgrade pip
- python setup.py bdist_wheel
+ python setup_onnxruntime.py bdist_wheel
mv dist ../
# - name: Publish distribution πŸ“¦ to Test PyPI
diff --git a/.github/workflows/gen_whl_to_pypi_openvino.yml b/.github/workflows/gen_whl_to_pypi_openvino.yml
new file mode 100644
index 0000000..3b28044
--- /dev/null
+++ b/.github/workflows/gen_whl_to_pypi_openvino.yml
@@ -0,0 +1,52 @@
+name: push rapidocr_onnxruntime to pypi
+
+on:
+ push:
+ branches: [ main ]
+ paths:
+ - 'python/rapidocr_openvino/**'
+ - 'docs/doc_whl_en_openvino.md'
+ - 'python/setup_openvino.py'
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Set SSH Environment
+ env:
+ DEPLOY_KEYS: ${{ secrets.GEN_PYTHON_SDK }}
+ run: |
+ mkdir -p ~/.ssh/
+ echo "$DEPLOY_KEYS" > ~/.ssh/id_rsa
+ chmod 600 ~/.ssh/id_rsa
+ chmod 700 ~/.ssh && chmod 600 ~/.ssh/*
+
+ - name: Run setup_openvino.py
+ run: |
+ cd python
+ mkdir rapidocr_openvino_t
+ mv rapidocr_openvino rapidocr_openvino_t
+ mv rapidocr_openvino_t rapidocr_openvino
+ cd rapidocr_openvino
+ echo "from .rapidocr_openvino.rapid_ocr_api import TextSystem" > __init__.py
+
+ cd ..
+ python -m pip install --upgrade pip
+ python setup_openvino.py bdist_wheel
+ mv 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
+ uses: pypa/[email protected]
+ with:
+ password: ${{ secrets.PYPI_API_TOKEN }}
+ packages_dir: dist/
diff --git a/docs/doc_whl_en.md b/docs/doc_whl_en_onnxruntime.md
similarity index 100%
rename from docs/doc_whl_en.md
rename to docs/doc_whl_en_onnxruntime.md
diff --git a/docs/doc_whl_en_openvino.md b/docs/doc_whl_en_openvino.md
new file mode 100644
index 0000000..1dd97a1
--- /dev/null
+++ b/docs/doc_whl_en_openvino.md
@@ -0,0 +1,49 @@
+## rapidocr-openvino Package
+<p>
+ <a href=""><img src="https://img.shields.io/badge/Python-3.6+-aff.svg"></a>
+ <a href=""><img src="https://img.shields.io/badge/OS-Linux%2C%20Win%2C%20Mac-pink.svg"></a>
+</p>
+
+### 1. Install package by pypi.
+```bash
+pip install rapidocr-openvino
+```
+
+### 2. Download the models and config yaml.
+```bash
+wget https://github.com/RapidAI/RapidOCR/releases/download/v1.1.0/required_for_whl_v1.1.0.zip
+
+# or by gitee
+# wget https://gitee.com/RapidAI/RapidOCR/releases/download/v1.1.0/required_for_whl_v1.1.0.zip
+
+unzip required_for_whl_v1.1.0.zip
+cd required_for_whl_v1.1.0
+```
+
+- The final directory of the folder:
+ ```text
+ required_for_whl_v1.1.0/
+ β”œβ”€β”€ config.yaml
+ β”œβ”€β”€ README.md
+ β”œβ”€β”€ test_demo.py
+ β”œβ”€β”€ resources
+ β”‚ └── models
+ β”‚ β”œβ”€β”€ ch_ppocr_mobile_v2.0_cls_infer.onnx
+ β”‚ β”œβ”€β”€ ch_PP-OCRv3_det_infer.onnx
+ β”‚ └── ch_PP-OCRv3_rec_infer.onnx
+ └── test_images
+ └── ch_en_num.jpg
+ ```
+
+### 3. Use.
+```python
+import cv2
+from rapidocr_openvino import TextSystem
+
+text_sys = TextSystem('config.yaml')
+
+img = cv2.imread('test_images/ch_en_num.jpg')
+
+dt_boxes, rec_res = text_sys(img)
+print(rec_res)
+```
diff --git a/python/setup.py b/python/setup_onnxruntime.py
similarity index 96%
rename from python/setup.py
rename to python/setup_onnxruntime.py
index a5ac8ba..f009936 100644
--- a/python/setup.py
+++ b/python/setup_onnxruntime.py
@@ -31,7 +31,7 @@ def version_add_one(version, add_loc=-1):
def get_readme():
root_dir = Path(__file__).resolve().parent.parent
- readme_path = str(root_dir / 'docs' / 'doc_whl_en.md')
+ readme_path = str(root_dir / 'docs' / 'doc_whl_en_onnxruntime.md')
print(readme_path)
with open(readme_path, 'r') as f:
readme = f.read()
@@ -62,4 +62,3 @@ setuptools.setup(
'ocr text_detection text_recognition db onnxruntime paddleocr openvino'
],
)
-
diff --git a/python/setup_openvino.py b/python/setup_openvino.py
new file mode 100644
index 0000000..42e523e
--- /dev/null
+++ b/python/setup_openvino.py
@@ -0,0 +1,66 @@
+# -*- encoding: utf-8 -*-
+# @Author: SWHL
+# @Contact: [email protected]
+from pathlib import Path
+import setuptools
+import subprocess
+
+
+def get_latest_version(package_name):
+ output = subprocess.run(["pip", "index", "versions", package_name],
+ capture_output=True)
+ output = output.stdout.decode('utf-8')
+ if output:
+ 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
+
+
+def version_add_one(version, add_loc=-1):
+ if version:
+ version_list = version.split('.')
+ mini_version = str(int(version_list[add_loc]) + 1)
+ version_list[add_loc] = mini_version
+ new_version = '.'.join(version_list)
+ return new_version
+ else:
+ return '0.0.0'
+
+
+def get_readme():
+ root_dir = Path(__file__).resolve().parent.parent
+ readme_path = str(root_dir / 'docs' / 'doc_whl_en_openvino.md')
+ print(readme_path)
+ with open(readme_path, 'r', encoding='utf-8') as f:
+ readme = f.read()
+ return readme
+
+
+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,
+ platforms="Windows & Linux & Mac",
+ description="RapidOCR",
+ long_description=get_readme(),
+ long_description_content_type='text/markdown',
+ author="SWHL",
+ 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",
+ "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),
+ keywords=[
+ 'ocr text_detection text_recognition db onnxruntime paddleocr openvino'
+ ],
+)
diff --git a/python/test_demo.py b/python/test_demo.py
index 30fd8cb..307022e 100644
--- a/python/test_demo.py
+++ b/python/test_demo.py
@@ -9,8 +9,8 @@ import cv2
import numpy as np
from PIL import Image, ImageDraw, ImageFont
-from rapidocr_onnxruntime import TextSystem
-# from rapidocr_openvino import TextSystem
+# from rapidocr_onnxruntime import TextSystem
+from rapidocr_openvino import TextSystem
def draw_ocr_box_txt(image, boxes, txts, font_path,