menghanxia commited on
Commit
be9102f
1 Parent(s): b346de0

use gradio examples

Browse files
Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -8,6 +8,11 @@ RUN_MODE = "remote"
8
  if RUN_MODE != "local":
9
  os.system("wget https://huggingface.co/menghanxia/disco/resolve/main/disco-beta.pth.rar")
10
  os.rename("disco-beta.pth.rar", "./checkpoints/disco-beta.pth.rar")
 
 
 
 
 
11
 
12
  ## step 1: set up model
13
  device = "cpu"
@@ -34,7 +39,7 @@ def switch_states(is_checked):
34
  demo = gr.Blocks(title="DISCO")
35
  with demo:
36
  gr.Markdown(value="""
37
- **Gradio demo for DISCO: Disentangled Image Colorization via Global Anchors**. Check our project page [*Here*](https://menghanxia.github.io/projects/disco.html).
38
  """)
39
  with gr.Row():
40
  with gr.Column():
@@ -56,15 +61,23 @@ with demo:
56
  Button_show_anchor.click(fn=click_predanchors, inputs=[Image_input, Num_anchor, Radio_resolution, Ckeckbox_editable], outputs=Image_anchor)
57
  Button_run.click(fn=click_colorize, inputs=[Image_input, Image_anchor, Num_anchor, Radio_resolution, Ckeckbox_editable], \
58
  outputs=Image_output)
 
59
  ## guiline
60
  gr.Markdown(value="""
61
  **Guideline**
62
- 1. upload your image;   [*example images*](https://1drv.ms/u/s!Al07CQ4AbykHkmk2dFpNPA8VObk4?e=1C7D3R)😛
63
  2. set up the arguments: "Num. of anchors" and "Colorization resolution";
64
  3. run the colorization (two modes supported):
65
  - *Automatic mode*: click "Colorize" to get the automatically colorized output.
66
  - *Editable mode*: check ""Show editable anchors" and click "Predict anchors". Then, modify the colors of the predicted anchors (only anchor region will be used). Finally, click "Colorize" to get the result.
67
  """)
 
 
 
 
 
 
 
68
  gr.HTML(value="""
69
  <p style="text-align:center; color:orange"><a href='https://menghanxia.github.io/projects/disco.html' target='_blank'>DISCO Project Page</a> | <a href='https://github.com/MenghanXia/DisentangledColorization' target='_blank'>Github Repo</a></p>
70
  """)
 
8
  if RUN_MODE != "local":
9
  os.system("wget https://huggingface.co/menghanxia/disco/resolve/main/disco-beta.pth.rar")
10
  os.rename("disco-beta.pth.rar", "./checkpoints/disco-beta.pth.rar")
11
+ ## examples
12
+ os.system("wget https://huggingface.co/menghanxia/disco/resolve/main/01.jpg")
13
+ os.system("wget https://huggingface.co/menghanxia/disco/resolve/main/02.jpg")
14
+ os.system("wget https://huggingface.co/menghanxia/disco/resolve/main/03.jpg")
15
+ os.system("wget https://huggingface.co/menghanxia/disco/resolve/main/04.jpg")
16
 
17
  ## step 1: set up model
18
  device = "cpu"
 
39
  demo = gr.Blocks(title="DISCO")
40
  with demo:
41
  gr.Markdown(value="""
42
+ **Gradio demo for DISCO: Disentangled Image Colorization via Global Anchors**. Check our [project page](https://menghanxia.github.io/projects/disco.html).
43
  """)
44
  with gr.Row():
45
  with gr.Column():
 
61
  Button_show_anchor.click(fn=click_predanchors, inputs=[Image_input, Num_anchor, Radio_resolution, Ckeckbox_editable], outputs=Image_anchor)
62
  Button_run.click(fn=click_colorize, inputs=[Image_input, Image_anchor, Num_anchor, Radio_resolution, Ckeckbox_editable], \
63
  outputs=Image_output)
64
+
65
  ## guiline
66
  gr.Markdown(value="""
67
  **Guideline**
68
+ 1. upload your image or select one from the examples😛;
69
  2. set up the arguments: "Num. of anchors" and "Colorization resolution";
70
  3. run the colorization (two modes supported):
71
  - *Automatic mode*: click "Colorize" to get the automatically colorized output.
72
  - *Editable mode*: check ""Show editable anchors" and click "Predict anchors". Then, modify the colors of the predicted anchors (only anchor region will be used). Finally, click "Colorize" to get the result.
73
  """)
74
+ gr.Examples(examples=[
75
+ ['01.jpg', 8, "Low (256x256)"],
76
+ ['02.jpg', 8, "Low (256x256)"],
77
+ ['03.jpg', 8, "Low (256x256)"],
78
+ ['04.jpg', 8, "Low (256x256)"],
79
+ ],
80
+ inputs=[Image_input,Num_anchor,Radio_resolution], outputs=[Image_output], label="Examples")
81
  gr.HTML(value="""
82
  <p style="text-align:center; color:orange"><a href='https://menghanxia.github.io/projects/disco.html' target='_blank'>DISCO Project Page</a> | <a href='https://github.com/MenghanXia/DisentangledColorization' target='_blank'>Github Repo</a></p>
83
  """)