Spaces:
Running
Running
Upload 3 files
Browse files- .gitattributes +38 -35
- app.py +73 -0
- requirements.txt +2 -0
.gitattributes
CHANGED
@@ -1,35 +1,38 @@
|
|
1 |
-
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
-
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
-
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
-
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
-
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
-
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
-
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
-
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
-
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
-
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
-
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
-
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
-
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
-
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
-
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
-
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
-
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
-
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
-
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
-
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
-
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
-
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
-
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
-
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
-
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
-
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
-
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
-
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
models/*.onnx filter=lfs diff=lfs merge=lfs -text
|
37 |
+
images/*.jpg filter=lfs diff=lfs merge=lfs -text
|
38 |
+
images/*.png filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from rapid_unwrap.inference import DocUnwrapper
|
3 |
+
|
4 |
+
# 初始化模型
|
5 |
+
model_path = "models/uvdoc.onnx"
|
6 |
+
doc_unwrapper = DocUnwrapper(model_path=model_path)
|
7 |
+
# 添加示例
|
8 |
+
example_images = [
|
9 |
+
"images/demo1.jpg",
|
10 |
+
"images/demo1.png",
|
11 |
+
"images/demo2.png",
|
12 |
+
"images/demo3.jpg",
|
13 |
+
|
14 |
+
]
|
15 |
+
|
16 |
+
|
17 |
+
def process_image(img_path):
|
18 |
+
unwrapped_img, elapse = doc_unwrapper(img_path)
|
19 |
+
print(f"doc unwrap elapse: {elapse}")
|
20 |
+
return unwrapped_img
|
21 |
+
|
22 |
+
|
23 |
+
def main():
|
24 |
+
# 定义Gradio界面
|
25 |
+
with gr.Blocks(css="""
|
26 |
+
.scrollable-container {
|
27 |
+
overflow-x: auto;
|
28 |
+
white-space: nowrap;
|
29 |
+
}
|
30 |
+
.header-links {
|
31 |
+
text-align: center;
|
32 |
+
}
|
33 |
+
.header-links a {
|
34 |
+
display: inline-block;
|
35 |
+
text-align: center;
|
36 |
+
margin-right: 10px; /* 调整间距 */
|
37 |
+
}
|
38 |
+
""") as demo:
|
39 |
+
gr.HTML(
|
40 |
+
"<h1 style='text-align: center;'><a href='https://github.com/Joker1212/RapidUnWrap'>RapidUnWrap</a></h1>"
|
41 |
+
)
|
42 |
+
gr.HTML('''
|
43 |
+
<div class="header-links">
|
44 |
+
<a href=""><img src="https://img.shields.io/badge/Python->=3.8,<3.13-aff.svg"></a>
|
45 |
+
<a href=""><img src="https://img.shields.io/badge/OS-Linux%2C%20Mac%2C%20Win-pink.svg"></a>
|
46 |
+
<a href="https://semver.org/"><img alt="SemVer2.0" src="https://img.shields.io/badge/SemVer-2.0-brightgreen"></a>
|
47 |
+
<a href="https://github.com/psf/black"><img src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
|
48 |
+
<a href="https://github.com/RapidAI/TableStructureRec/blob/c41bbd23898cb27a957ed962b0ffee3c74dfeff1/LICENSE"><img alt="GitHub" src="https://img.shields.io/badge/license-Apache 2.0-blue"></a>
|
49 |
+
</div>
|
50 |
+
''')
|
51 |
+
with gr.Row():
|
52 |
+
with gr.Column(scale=1): # 左边占1/3
|
53 |
+
img_input = gr.Image(label="Upload or Select Image", sources="upload", value="images/demo1.jpg")
|
54 |
+
# 示例图片选择器
|
55 |
+
examples = gr.Examples(
|
56 |
+
examples=example_images,
|
57 |
+
examples_per_page=len(example_images),
|
58 |
+
inputs=img_input,
|
59 |
+
fn=lambda x: x, # 简单返回图片路径
|
60 |
+
outputs=img_input,
|
61 |
+
cache_examples=False
|
62 |
+
)
|
63 |
+
run_button = gr.Button("summit")
|
64 |
+
with gr.Column(scale=2): # 右边占2/3
|
65 |
+
output_image = gr.Image(label="output")
|
66 |
+
|
67 |
+
# 绑定按钮点击事件
|
68 |
+
run_button.click(fn=process_image, inputs=img_input, outputs=output_image)
|
69 |
+
|
70 |
+
# 启动应用
|
71 |
+
demo.launch()
|
72 |
+
if __name__ == '__main__':
|
73 |
+
main()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
rapid_unwrap
|
2 |
+
gradio
|