Spaces:
Running
on
Zero
Running
on
Zero
Add examples and header
Browse files
app.py
CHANGED
@@ -4,6 +4,19 @@ import spaces
|
|
4 |
from inference_gradio import inference_one_image, model_init
|
5 |
|
6 |
MODEL_PATH = "./checkpoints/docres.pkl"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
possible_tasks = [
|
9 |
"dewarping",
|
@@ -33,11 +46,13 @@ def run_tasks(image, tasks):
|
|
33 |
|
34 |
|
35 |
with gr.Blocks() as demo:
|
|
|
|
|
|
|
36 |
with gr.Row():
|
37 |
-
input_image = gr.Image(type="numpy")
|
38 |
-
output_image = gr.Image(type="numpy")
|
39 |
|
40 |
-
task = gr.CheckboxGroup(choices=possible_tasks, label="Choose tasks:")
|
41 |
button = gr.Button()
|
42 |
button.click(
|
43 |
run_tasks, inputs=[input_image, task], outputs=[output_image]
|
@@ -45,7 +60,13 @@ with gr.Blocks() as demo:
|
|
45 |
|
46 |
gr.Examples(
|
47 |
examples=[
|
|
|
|
|
48 |
["input/for_debluring.png", ["deblurring"]],
|
|
|
|
|
|
|
|
|
49 |
],
|
50 |
inputs=[input_image, task],
|
51 |
outputs=[output_image],
|
|
|
4 |
from inference_gradio import inference_one_image, model_init
|
5 |
|
6 |
MODEL_PATH = "./checkpoints/docres.pkl"
|
7 |
+
HEADER = """
|
8 |
+
<div align="center">
|
9 |
+
<p>
|
10 |
+
<span style="font-size: 30px; vertical-align: bottom;"> DocRes: A Generalist Model Toward Unifying Document Image Restoration Tasks </span>
|
11 |
+
</p>
|
12 |
+
<p style="margin-top: -15px;">
|
13 |
+
<a href="https://arxiv.org/abs/2405.04408" target="_blank" style="color: grey;">ArXiv Paper</a>
|
14 |
+
|
15 |
+
<a href="https://github.com/ZZZHANG-jx/DocRes" target="_blank" style="color: grey;">GitHub Repository</a>
|
16 |
+
</p>
|
17 |
+
</div>
|
18 |
+
"""
|
19 |
+
|
20 |
|
21 |
possible_tasks = [
|
22 |
"dewarping",
|
|
|
46 |
|
47 |
|
48 |
with gr.Blocks() as demo:
|
49 |
+
gr.Markdown(HEADER)
|
50 |
+
|
51 |
+
task = gr.CheckboxGroup(choices=possible_tasks, label="Tasks", value=["appearance"])
|
52 |
with gr.Row():
|
53 |
+
input_image = gr.Image(label="Raw Image", type="numpy")
|
54 |
+
output_image = gr.Image(label="Enhanced Image", type="numpy")
|
55 |
|
|
|
56 |
button = gr.Button()
|
57 |
button.click(
|
58 |
run_tasks, inputs=[input_image, task], outputs=[output_image]
|
|
|
60 |
|
61 |
gr.Examples(
|
62 |
examples=[
|
63 |
+
["input/218_in.png", ["dewarping", "deshadowing", "appearance"]],
|
64 |
+
["input/151_in.png", ["dewarping", "deshadowing", "appearance"]],
|
65 |
["input/for_debluring.png", ["deblurring"]],
|
66 |
+
["input/for_appearance.png", ["appearance"]],
|
67 |
+
["input/for_deshadowing.png", ["deshadowing"]],
|
68 |
+
["input/for_dewarping.png", ["dewarping"]],
|
69 |
+
["input/for_binarization.png", ["binarization"]],
|
70 |
],
|
71 |
inputs=[input_image, task],
|
72 |
outputs=[output_image],
|