Skip to content

Commit cfa4797

Browse files
committed
fix: fixed issue #31
1 parent 53f367b commit cfa4797

File tree

5 files changed

+21
-182
lines changed

5 files changed

+21
-182
lines changed

.github/workflows/gen_whl_to_pypi_rapid_orientation.yml .github/workflows/publish_whl.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ on:
55
tags:
66
- v*
77

8-
98
env:
109
RESOURCES_URL: https://github.com/RapidAI/RapidStructure/releases/download/v0.0.0/rapid_orientation_models.zip
1110

@@ -31,6 +30,7 @@ jobs:
3130
rm rapid_orientation/models/.gitkeep
3231
mv $DIR_NAME/*.onnx rapid_orientation/models/
3332
pip install -r requirements.txt
33+
pip install pytest
3434
pytest tests/test_orientation.py
3535
3636
GenerateWHL_PushPyPi:
@@ -49,12 +49,14 @@ jobs:
4949
- name: Run setup
5050
run: |
5151
pip install -r requirements.txt
52+
python -m pip install --upgrade pip
53+
pip install wheel get_pypi_latest_version
5254
wget $RESOURCES_URL
5355
ZIP_NAME=${RESOURCES_URL##*/}
5456
DIR_NAME=${ZIP_NAME%.*}
5557
unzip $ZIP_NAME
5658
mv $DIR_NAME/*.onnx rapid_orientation/models/
57-
python setup_orientation.py bdist_wheel ${{ github.ref_name }}
59+
python setup.py bdist_wheel ${{ github.ref_name }}
5860
5961
- name: Publish distribution 📦 to PyPI
6062
uses: pypa/gh-action-pypi-publish@v1.5.0

docs/doc_whl_rapid_orientation.md

+1-52
Original file line numberDiff line numberDiff line change
@@ -1,52 +1 @@
1-
## rapid-orientation
2-
<p align="left">
3-
<a href=""><img src="https://img.shields.io/badge/Python->=3.6,<3.12-aff.svg"></a>
4-
<a href=""><img src="https://img.shields.io/badge/OS-Linux%2C%20Win%2C%20Mac-pink.svg"></a>
5-
<a href="https://pypi.org/project/rapid-orientation/"><img alt="PyPI" src="https://img.shields.io/pypi/v/rapid-orientation"></a>
6-
<a href="https://pepy.tech/project/rapid-orientation"><img src="https://static.pepy.tech/personalized-badge/rapid-orientation?period=total&units=abbreviation&left_color=grey&right_color=blue&left_text=Downloads"></a>
7-
</p>
8-
9-
10-
### 1. Install package by pypi.
11-
```bash
12-
$ pip install rapid-orientation
13-
```
14-
15-
### 2. Run by script.
16-
- RapidOrientation has the default `model_path` value, you can set the different value of `model_path` to use different models, e.g. `orientation_engine = RapidOrientation(model_path='rapid_orientation.onnx')`
17-
- See details, for [README_Layout](https://github.com/RapidAI/RapidStructure/blob/main/docs/README_Orientation.md) .
18-
- 📌 `layout.png` source: [link](https://github.com/RapidAI/RapidStructure/blob/main/test_images/layout.png)
19-
20-
```python
21-
from rapid_orientation import RapidOrientation
22-
23-
orientation_engine = RapidOrientation()
24-
25-
with open('test_images/layout.png', 'rb') as f:
26-
img = f.read()
27-
orientation_res, elapse = orientation_engine(img)
28-
print(orientation_res)
29-
```
30-
31-
### 3. Run by command line.
32-
- Usage:
33-
```bash
34-
$ rapid_orientation -h
35-
usage: rapid_orientation [-h] -img IMG_PATH [-m MODEL_PATH]
36-
37-
optional arguments:
38-
-h, --help show this help message and exit
39-
-img IMG_PATH, --img_path IMG_PATH
40-
Path to image for layout.
41-
-m MODEL_PATH, --model_path MODEL_PATH
42-
The model path used for inference
43-
```
44-
- Example:
45-
```bash
46-
$ rapid_orientation -img layout.png
47-
```
48-
49-
### 4. Result.
50-
```python
51-
# Return str, four types::0 | 90 | 180 | 270
52-
```
1+
See [documentation](https://github.com/RapidAI/RapidOrientation)

rapid_main.py

-105
This file was deleted.

requirements.txt

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
numpy>=1.21.6,<2.0.0
22
opencv_python>=4.6.0.66
3-
setuptools>=61.2.0
43
PyYAML
5-
pytest==8.1.1
6-
pip>=24.0
74
onnxruntime
8-
wheel
9-
get_pypi_latest_version
10-
Pillow
11-
tqdm
12-
requests
5+
Pillow

setup_orientation.py setup.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,21 @@
33
# @Contact: liekkaskono@163.com
44
import sys
55
from pathlib import Path
6+
from typing import List
67

78
import setuptools
89
from get_pypi_latest_version import GetPyPiLatestVersion
910

1011

12+
def read_txt(txt_path: str) -> List:
13+
if not isinstance(txt_path, str):
14+
txt_path = str(txt_path)
15+
16+
with open(txt_path, "r", encoding="utf-8") as f:
17+
data = list(map(lambda x: x.rstrip("\n"), f))
18+
return data
19+
20+
1121
def get_readme():
1222
root_dir = Path(__file__).resolve().parent
1323
readme_path = str(root_dir / "docs" / "doc_whl_rapid_orientation.md")
@@ -32,22 +42,14 @@ def get_readme():
3242
name=MODULE_NAME,
3343
version=VERSION_NUM,
3444
platforms="Any",
35-
long_description=get_readme(),
36-
long_description_content_type="text/markdown",
3745
description="Tools for classifying the direction of images containing text based ONNXRuntime.",
3846
author="SWHL",
3947
author_email="liekkaskono@163.com",
40-
url="https://github.com/RapidAI/RapidStructure",
48+
url="https://github.com/RapidAI/RapidOrientation",
4149
license="Apache-2.0",
4250
include_package_data=True,
43-
install_requires=[
44-
"onnxruntime>=1.7.0",
45-
"PyYAML>=6.0",
46-
"opencv_python>=4.5.1.48",
47-
"numpy>=1.21.6",
48-
"Pillow",
49-
],
50-
packages=[MODULE_NAME, f"{MODULE_NAME}.models"],
51+
install_requires=read_txt("requirements.txt"),
52+
packages=[MODULE_NAME, f"{MODULE_NAME}.models", f"{MODULE_NAME}.utils"],
5153
package_data={"": ["*.onnx", "*.yaml"]},
5254
keywords=["ppstructure,layout,rapidocr,rapid_orientation"],
5355
classifiers=[
@@ -58,8 +60,6 @@ def get_readme():
5860
"Programming Language :: Python :: 3.10",
5961
"Programming Language :: Python :: 3.11",
6062
],
61-
python_requires=">=3.6,<3.12",
62-
entry_points={
63-
"console_scripts": [f"{MODULE_NAME}={MODULE_NAME}.{MODULE_NAME}:main"]
64-
},
63+
python_requires=">=3.6,<3.13",
64+
entry_points={"console_scripts": [f"{MODULE_NAME}={MODULE_NAME}.main:main"]},
6565
)

0 commit comments

Comments
 (0)