Spaces:
Running
Running
Add three pages
Browse files- pages/1_rapid_orientation.py +46 -0
- pages/2_rapid_layout.py +35 -0
- pages/3_rapid_table.py +35 -0
pages/1_rapid_orientation.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- encoding: utf-8 -*-
|
2 |
+
# @Author: SWHL
|
3 |
+
# @Contact: liekkaskono@163.com
|
4 |
+
import cv2
|
5 |
+
import numpy as np
|
6 |
+
import streamlit as st
|
7 |
+
from PIL import Image
|
8 |
+
from rapid_orientation import RapidOrientation
|
9 |
+
|
10 |
+
orientation_engine = RapidOrientation()
|
11 |
+
|
12 |
+
|
13 |
+
if __name__ == '__main__':
|
14 |
+
st.markdown("<h1 style='text-align: center;'><a href='https://github.com/RapidAI/RapidStructure/blob/main/docs/README_Orientation.md' style='text-decoration: none'>rapid-orientation</a></h1>", unsafe_allow_html=True)
|
15 |
+
st.markdown("""
|
16 |
+
<p align="left">
|
17 |
+
<a href=""><img src="https://img.shields.io/badge/Python->=3.7,<=3.10-aff.svg"></a>
|
18 |
+
<a href=""><img src="https://img.shields.io/badge/OS-Linux%2C%20Win%2C%20Mac-pink.svg"></a>
|
19 |
+
<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=rapid-orientation"></a>
|
20 |
+
</p>
|
21 |
+
|
22 |
+
#### 简介
|
23 |
+
- 该部分主要是做含文字图像方向分类模型。模型来源:[PaddleClas 含文字图像方向分类模型](https://github.com/PaddlePaddle/PaddleClas/blob/177e4be74639c0960efeae2c5166d3226c9a02eb/docs/zh_CN/models/PULC/PULC_text_image_orientation.md)
|
24 |
+
|
25 |
+
| 模型类型 | 模型名称 | 模型大小 | 支持种类 |
|
26 |
+
|:---:|:---:|:---:|:---:|
|
27 |
+
| 四方向分类 | `rapid_orientation.onnx` | 6.5M | `0 90 180 270`|
|
28 |
+
|
29 |
+
#### 试一下
|
30 |
+
""", unsafe_allow_html=True)
|
31 |
+
|
32 |
+
img_suffix = ["png", "jpg", "jpeg"]
|
33 |
+
|
34 |
+
img_file_buffer = st.file_uploader("Upload an image", type=img_suffix)
|
35 |
+
col1, col2 = st.columns([5, 5])
|
36 |
+
|
37 |
+
img_empty = col1.empty()
|
38 |
+
if img_file_buffer:
|
39 |
+
image = Image.open(img_file_buffer)
|
40 |
+
img = np.array(image)
|
41 |
+
img_empty.image(image, use_column_width=True)
|
42 |
+
|
43 |
+
img_array = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
|
44 |
+
orientation_res, elapse = orientation_engine(img)
|
45 |
+
|
46 |
+
col2.markdown(f'- 方向分类结果:{orientation_res}° \n - 耗费时间:{elapse:.4f}s')
|
pages/2_rapid_layout.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- encoding: utf-8 -*-
|
2 |
+
# @Author: SWHL
|
3 |
+
# @Contact: liekkaskono@163.com
|
4 |
+
import numpy as np
|
5 |
+
import streamlit as st
|
6 |
+
from PIL import Image
|
7 |
+
|
8 |
+
|
9 |
+
if __name__ == '__main__':
|
10 |
+
st.markdown("<h1 style='text-align: center;'><a href='https://github.com/RapidAI/RapidStructure' style='text-decoration: none'>Rapid Structure</a></h1>", unsafe_allow_html=True)
|
11 |
+
st.markdown("""
|
12 |
+
<p align="left">
|
13 |
+
<a href=""><img src="https://img.shields.io/badge/Python->=3.7,<=3.10-aff.svg"></a>
|
14 |
+
<a href=""><img src="https://img.shields.io/badge/OS-Linux%2C%20Win%2C%20Mac-pink.svg"></a>
|
15 |
+
<a href="https://pepy.tech/project/rapid-layout"><img src="https://static.pepy.tech/personalized-badge/rapid-layout?period=total&units=abbreviation&left_color=grey&right_color=blue&left_text=rapid-layout"></a>
|
16 |
+
<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=rapid-orientation"></a>
|
17 |
+
<a href="https://pepy.tech/project/rapid-table"><img src="https://static.pepy.tech/personalized-badge/rapid-table?period=total&units=abbreviation&left_color=grey&right_color=blue&left_text=rapid-table"></a>
|
18 |
+
</p>
|
19 |
+
""", unsafe_allow_html=True)
|
20 |
+
|
21 |
+
img_suffix = ["png", "jpg", "jpeg"]
|
22 |
+
|
23 |
+
st.markdown('##### rapid-orientation (文档图像分类) demo')
|
24 |
+
img_empty = st.empty()
|
25 |
+
img_file_buffer = st.file_uploader("Upload an image",
|
26 |
+
type=img_suffix,
|
27 |
+
label_visibility='hidden')
|
28 |
+
if img_file_buffer:
|
29 |
+
image = Image.open(img_file_buffer)
|
30 |
+
img_array = np.array(image)
|
31 |
+
if image:
|
32 |
+
img_empty.image(image, use_column_width=True)
|
33 |
+
|
34 |
+
st.markdown('##### rapid-layout (版面分析) demo')
|
35 |
+
st.markdown('##### rapid-table (表格还原) demo')
|
pages/3_rapid_table.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- encoding: utf-8 -*-
|
2 |
+
# @Author: SWHL
|
3 |
+
# @Contact: liekkaskono@163.com
|
4 |
+
import numpy as np
|
5 |
+
import streamlit as st
|
6 |
+
from PIL import Image
|
7 |
+
|
8 |
+
|
9 |
+
if __name__ == '__main__':
|
10 |
+
st.markdown("<h1 style='text-align: center;'><a href='https://github.com/RapidAI/RapidStructure' style='text-decoration: none'>Rapid Structure</a></h1>", unsafe_allow_html=True)
|
11 |
+
st.markdown("""
|
12 |
+
<p align="left">
|
13 |
+
<a href=""><img src="https://img.shields.io/badge/Python->=3.7,<=3.10-aff.svg"></a>
|
14 |
+
<a href=""><img src="https://img.shields.io/badge/OS-Linux%2C%20Win%2C%20Mac-pink.svg"></a>
|
15 |
+
<a href="https://pepy.tech/project/rapid-layout"><img src="https://static.pepy.tech/personalized-badge/rapid-layout?period=total&units=abbreviation&left_color=grey&right_color=blue&left_text=rapid-layout"></a>
|
16 |
+
<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=rapid-orientation"></a>
|
17 |
+
<a href="https://pepy.tech/project/rapid-table"><img src="https://static.pepy.tech/personalized-badge/rapid-table?period=total&units=abbreviation&left_color=grey&right_color=blue&left_text=rapid-table"></a>
|
18 |
+
</p>
|
19 |
+
""", unsafe_allow_html=True)
|
20 |
+
|
21 |
+
img_suffix = ["png", "jpg", "jpeg"]
|
22 |
+
|
23 |
+
st.markdown('##### rapid-orientation (文档图像分类) demo')
|
24 |
+
img_empty = st.empty()
|
25 |
+
img_file_buffer = st.file_uploader("Upload an image",
|
26 |
+
type=img_suffix,
|
27 |
+
label_visibility='hidden')
|
28 |
+
if img_file_buffer:
|
29 |
+
image = Image.open(img_file_buffer)
|
30 |
+
img_array = np.array(image)
|
31 |
+
if image:
|
32 |
+
img_empty.image(image, use_column_width=True)
|
33 |
+
|
34 |
+
st.markdown('##### rapid-layout (版面分析) demo')
|
35 |
+
st.markdown('##### rapid-table (表格还原) demo')
|