qubvel-hf HF staff commited on
Commit
97920f6
โ€ข
1 Parent(s): d9a7327
Files changed (2) hide show
  1. .gitignore +1 -0
  2. app.py +9 -7
.gitignore CHANGED
@@ -162,3 +162,4 @@ cython_debug/
162
  #.idea/
163
  .ruff_cache/
164
  /restored*
 
 
162
  #.idea/
163
  .ruff_cache/
164
  /restored*
165
+ /gradio_cached*
app.py CHANGED
@@ -15,6 +15,10 @@ HEADER = """
15
  <a href="https://github.com/ZZZHANG-jx/DocRes" target="_blank" style="color: grey;">GitHub Repository</a>
16
  </p>
17
  </div>
 
 
 
 
18
  """
19
 
20
 
@@ -26,9 +30,9 @@ possible_tasks = [
26
  "binarization",
27
  ]
28
 
29
- @spaces.GPU(duration=90)
30
- def run_tasks(image, tasks):
31
 
 
 
32
  device = "cuda" if torch.cuda.is_available() else "cpu"
33
 
34
  # load model
@@ -54,9 +58,7 @@ with gr.Blocks() as demo:
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]
59
- )
60
 
61
  gr.Examples(
62
  examples=[
@@ -64,7 +66,7 @@ with gr.Blocks() as demo:
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
  ],
@@ -73,5 +75,5 @@ with gr.Blocks() as demo:
73
  fn=run_tasks,
74
  cache_examples="lazy",
75
  )
76
-
77
  demo.launch()
 
15
  <a href="https://github.com/ZZZHANG-jx/DocRes" target="_blank" style="color: grey;">GitHub Repository</a>
16
  </p>
17
  </div>
18
+
19
+ ๐Ÿ–ผ๏ธ Upload an image of a document (or choose one from examples below).
20
+ โœ”๏ธ Choose the tasks you want to perform on the document.
21
+ ๐Ÿš€ Click "Run" and the model will enhance the document according to the selected tasks!
22
  """
23
 
24
 
 
30
  "binarization",
31
  ]
32
 
 
 
33
 
34
+ @spaces.GPU(duration=60)
35
+ def run_tasks(image, tasks):
36
  device = "cuda" if torch.cuda.is_available() else "cpu"
37
 
38
  # load model
 
58
  output_image = gr.Image(label="Enhanced Image", type="numpy")
59
 
60
  button = gr.Button()
61
+ button.click(run_tasks, inputs=[input_image, task], outputs=[output_image])
 
 
62
 
63
  gr.Examples(
64
  examples=[
 
66
  ["input/151_in.png", ["dewarping", "deshadowing", "appearance"]],
67
  ["input/for_debluring.png", ["deblurring"]],
68
  ["input/for_appearance.png", ["appearance"]],
69
+ ["input/for_deshadowing.jpg", ["deshadowing"]],
70
  ["input/for_dewarping.png", ["dewarping"]],
71
  ["input/for_binarization.png", ["binarization"]],
72
  ],
 
75
  fn=run_tasks,
76
  cache_examples="lazy",
77
  )
78
+
79
  demo.launch()