Skip to content

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

Update rapid_table action.

SWHL9445d72c4306
diff --git a/.github/workflows/gen_whl_to_pypi_table.yml b/.github/workflows/gen_whl_to_pypi_table.yml
new file mode 100644
index 0000000..51da1db
--- /dev/null
+++ b/.github/workflows/gen_whl_to_pypi_table.yml
@@ -0,0 +1,88 @@
+name: Push rapidocr_table to pypi
+
+on:
+ push:
+ branches: [ main ]
+ paths:
+ - 'python/rapid_structure/rapid_table/**'
+ - 'docs/doc_whl_table.md'
+ - 'python/rapid_structure/setup_table.py'
+ - '.github/workflows/gen_whl_to_pypi_table.yml'
+
+jobs:
+ UnitTesting:
+ runs-on: windows-latest
+ steps:
+ - name: Install 7Zip PowerShell Module
+ shell: powershell
+ run: Install-Module 7Zip4PowerShell -Force -Verbose
+
+ - name: Pull latest code
+ uses: actions/checkout@v3
+
+ - name: Download rapid layout model
+ uses: suisei-cn/actions-download-file@v1
+ id: downloadfile3 # Remember to give an ID if you need the output filename
+ with:
+ url: "https://github.com/RapidAI/RapidOCR/releases/download/v1.1.0/rapid_table_models.zip"
+ target: ./
+
+ - name: Decompress
+ shell: powershell
+ run: |
+ Expand-7Zip -ArchiveFileName ./rapid_table_models.zip -TargetPath .\
+
+ - name: List all file
+ shell: cmd
+ run: |
+ dir .
+
+ - name: Unit testings
+ shell: cmd
+ run: |
+ set git_keep_path=%cur_dir%\python\rapid_structure\rapid_table\models\.gitkeep
+ del %git_keep_path%
+ move rapid_table_models\* python\rapid_structure\rapid_table\models\
+ cd python/rapid_structure
+ pip install -r requirements.txt
+ pip install onnxruntime
+ cd tests
+ pytest test_table.py
+
+ GenerateWHL_PushPyPi:
+ needs: UnitTesting
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v3
+
+ - 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
+ run: |
+ cd python/rapid_structure
+ python -m pip install --upgrade pip
+ wget https://github.com/RapidAI/RapidOCR/releases/download/v1.1.0/rapid_table_models.zip
+ unzip rapid_table_models.zip
+ mv rapid_table_models/en_ppstructure_mobile_v2_SLANet.onnx rapid_table/models/
+ python setup_table.py bdist_wheel
+
+ # - 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.RAPIDOCR_OPENVINO }}
+ packages_dir: python/rapid_structure/dist/
diff --git a/docs/doc_whl_layout.md b/docs/doc_whl_layout.md
index 4d47481..9f8b35d 100644
--- a/docs/doc_whl_layout.md
+++ b/docs/doc_whl_layout.md
@@ -24,7 +24,7 @@ print(layout_res)
### 3. Run by command line.
```bash
-$ rapid_layout --img_path test_images/ch.png
+$ rapid_layout --img_path test_images/layout.png
```
### 4. Result.
diff --git a/docs/doc_whl_table.md b/docs/doc_whl_table.md
new file mode 100644
index 0000000..1c2a10f
--- /dev/null
+++ b/docs/doc_whl_table.md
@@ -0,0 +1,37 @@
+## rapid-table Package
+<p>
+ <a href=""><img src="https://img.shields.io/badge/Python->=3.7,<=3.10-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-table
+```
+
+### 2. Run by script.
+```python
+import cv2
+from rapid_table import RapidTable
+
+rapid_table = RapidTable()
+
+img = cv2.imread('test_images/table.jpg')
+table_html_str, _ = rapid_table(img)
+print(table_html_str)
+```
+
+### 3. Run by command line.
+```bash
+$ rapid_talbe --img_path test_images/table.jpg
+```
+
+### 4. Result.
+- Return value.
+ ```html
+ <html><body><table><thead><tr><td>Methods</td><td></td><td></td><td></td><td>FPS</td></tr></thead><tbody><tr><td>SegLink [26]</td><td>70.0</td><td>86d><td.0</td><td>77.0</td><td>8.9</td></tr><tr><td>PixelLink [4]</td><td>73.2</td><td>83.0</td><td>77.8</td><td></td></tr><tr><td>TextSnake [18]</td><td>73.9</td><td>83.2</td><td>78.3</td><td>1.1</td></tr><tr><td>TextField [37]</td><td>75.9</td><td>87.4</td><td>81.3</td><td>5.2</td></tr><tr><td>MSR[38]</td><td>76.7</td><td>87.87.4</td><td>81.7</td><td></td></tr><tr><td>FTSN [3]</td><td>77.1</td><td>87.6</td><td>82.0</td><td></td></tr><tr><td>LSE[30]</td><td>81.7</td><td>84.2</td><td>82.9</td><><ttd></td></tr><tr><td>CRAFT [2]</td><td>78.2</td><td>88.2</td><td>82.9</td><td>8.6</td></tr><tr><td>MCN[16]</td><td>79</td><td>88</td><td>83</td><td></td></tr><tr><td>ATRR</>[35]</td><td>82.1</td><td>85.2</td><td>83.6</td><td></td></tr><tr><td>PAN [34]</td><td>83.8</td><td>84.4</td><td>84.1</td><td>30.2</td></tr><tr><td>DB[12]</td><td>79.2</t91/d><td>91.5</td><td>84.9</td><td>32.0</td></tr><tr><td>DRRG[41]</td><td>82.30</td><td>88.05</td><td>85.08</td><td></td></tr><tr><td>Ours (SynText)</td><td>80.68</td><td>85<t..40</td><td>82.97</td><td>12.68</td></tr><tr><td>Ours (MLT-17)</td><td>84.54</td><td>86.62</td><td>85.57</td><td>12.31</td></tr></tbody></table></body></html>
+ ```
+- Visualize result.
+ <div align="center">
+ <table><thead><tr><td>Methods</td><td></td><td></td><td></td><td>FPS</td></tr></thead><tbody><tr><td>SegLink [26]</td><td>70.0</td><td>86d><td.0</td><td>77.0</td><td>8.9</td></tr><tr><td>PixelLink [4]</td><td>73.2</td><td>83.0</td><td>77.8</td><td></td></tr><tr><td>TextSnake [18]</td><td>73.9</td><td>83.2</td><td>78.3</td><td>1.1</td></tr><tr><td>TextField [37]</td><td>75.9</td><td>87.4</td><td>81.3</td><td>5.2</td></tr><tr><td>MSR[38]</td><td>76.7</td><td>87.87.4</td><td>81.7</td><td></td></tr><tr><td>FTSN [3]</td><td>77.1</td><td>87.6</td><td>82.0</td><td></td></tr><tr><td>LSE[30]</td><td>81.7</td><td>84.2</td><td>82.9</td><><ttd></td></tr><tr><td>CRAFT [2]</td><td>78.2</td><td>88.2</td><td>82.9</td><td>8.6</td></tr><tr><td>MCN[16]</td><td>79</td><td>88</td><td>83</td><td></td></tr><tr><td>ATRR</>[35]</td><td>82.1</td><td>85.2</td><td>83.6</td><td></td></tr><tr><td>PAN [34]</td><td>83.8</td><td>84.4</td><td>84.1</td><td>30.2</td></tr><tr><td>DB[12]</td><td>79.2</t91/d><td>91.5</td><td>84.9</td><td>32.0</td></tr><tr><td>DRRG[41]</td><td>82.30</td><td>88.05</td><td>85.08</td><td></td></tr><tr><td>Ours (SynText)</td><td>80.68</td><td>85<t..40</td><td>82.97</td><td>12.68</td></tr><tr><td>Ours (MLT-17)</td><td>84.54</td><td>86.62</td><td>85.57</td><td>12.31</td></tr></tbody></table>
+ </div>
diff --git a/python/rapid_structure/setup_layout.py b/python/rapid_structure/setup_layout.py
index a45dd11..0c000fd 100644
--- a/python/rapid_structure/setup_layout.py
+++ b/python/rapid_structure/setup_layout.py
@@ -1,9 +1,10 @@
# -*- encoding: utf-8 -*-
# @Author: SWHL
# @Contact: [email protected]
+import subprocess
from pathlib import Path
+
import setuptools
-import subprocess
def get_latest_version(package_name):
diff --git a/python/rapid_structure/setup_table.py b/python/rapid_structure/setup_table.py
index 563bb08..3d53690 100644
--- a/python/rapid_structure/setup_table.py
+++ b/python/rapid_structure/setup_table.py
@@ -1,9 +1,10 @@
# -*- encoding: utf-8 -*-
# @Author: SWHL
# @Contact: [email protected]
+import subprocess
from pathlib import Path
+
import setuptools
-import subprocess
def get_latest_version(package_name):
@@ -28,7 +29,7 @@ def version_add_one(version, add_loc=-1):
def get_readme():
root_dir = Path(__file__).resolve().parent.parent.parent
- readme_path = str(root_dir / 'docs' / 'doc_whl_layout.md')
+ readme_path = str(root_dir / 'docs' / 'doc_whl_table.md')
with open(readme_path, 'r', encoding='utf-8') as f:
readme = f.read()
return readme
@@ -53,8 +54,11 @@ setuptools.setup(
install_requires=["onnxruntime>=1.7.0", "PyYAML>=6.0",
"opencv_python>=4.5.1.48", "numpy>=1.21.6",
"rapidocr_onnxruntime>=1.1.18"],
- packages=[MODULE_NAME, f'{MODULE_NAME}.models'],
- package_data={'': ['layout_cdla.onnx']},
+ packages=[MODULE_NAME,
+ f'{MODULE_NAME}.models',
+ f'{MODULE_NAME}.table_matcher',
+ f'{MODULE_NAME}.table_structure'],
+ package_data={'': ['*.onnx']},
keywords=[
'ppstructure,table,rapidocr'
],