Spaces:
Runtime error
Runtime error
Commit
·
61712c2
1
Parent(s):
2a10b61
reorganize the layout and provide examples
Browse files
app.py
CHANGED
|
@@ -3,7 +3,8 @@ import os, requests
|
|
| 3 |
import numpy as np
|
| 4 |
from inference import setup_model, colorize_grayscale, predict_anchors
|
| 5 |
|
| 6 |
-
|
|
|
|
| 7 |
if RUN_MODE != "local":
|
| 8 |
os.system("wget https://huggingface.co/menghanxia/disco/resolve/main/disco-beta.pth.rar")
|
| 9 |
os.rename("disco-beta.pth.rar", "./checkpoints/disco-beta.pth.rar")
|
|
@@ -36,20 +37,21 @@ with demo:
|
|
| 36 |
**Gradio demo for DISCO: Disentangled Image Colorization via Global Anchors**. Check our project page [*Here*](https://menghanxia.github.io/projects/disco.html).
|
| 37 |
""")
|
| 38 |
with gr.Row():
|
| 39 |
-
with gr.Column(
|
| 40 |
-
|
| 41 |
-
|
|
|
|
| 42 |
with gr.Row():
|
| 43 |
Num_anchor = gr.Number(type="int", value=8, label="Num. of anchors (3~14)")
|
| 44 |
Radio_resolution = gr.Radio(type="index", choices=["Low (256x256)", "High (512x512)"], \
|
| 45 |
-
|
| 46 |
-
Ckeckbox_editable = gr.Checkbox(default=False, label='Show editable anchors')
|
| 47 |
with gr.Row():
|
|
|
|
| 48 |
Button_show_anchor = gr.Button(value="Predict anchors", visible=False)
|
| 49 |
-
|
| 50 |
-
with gr.Column(
|
| 51 |
Image_output = gr.Image(type="numpy", label="Output").style(height=480)
|
| 52 |
-
|
| 53 |
Ckeckbox_editable.change(fn=switch_states, inputs=Ckeckbox_editable, outputs=[Image_anchor, Button_show_anchor])
|
| 54 |
Button_show_anchor.click(fn=click_predanchors, inputs=[Image_input, Num_anchor, Radio_resolution, Ckeckbox_editable], outputs=Image_anchor)
|
| 55 |
Button_run.click(fn=click_colorize, inputs=[Image_input, Image_anchor, Num_anchor, Radio_resolution, Ckeckbox_editable], \
|
|
@@ -57,7 +59,7 @@ with demo:
|
|
| 57 |
## guiline
|
| 58 |
gr.Markdown(value="""
|
| 59 |
**Guideline**
|
| 60 |
-
1. upload your image;
|
| 61 |
2. set up the arguments: "Num. of anchors" and "Colorization resolution";
|
| 62 |
3. run the colorization (two modes supported):
|
| 63 |
- *Automatic mode*: click "Colorize" to get the automatically colorized output.
|
|
|
|
| 3 |
import numpy as np
|
| 4 |
from inference import setup_model, colorize_grayscale, predict_anchors
|
| 5 |
|
| 6 |
+
## local | remote
|
| 7 |
+
RUN_MODE = "local"
|
| 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")
|
|
|
|
| 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():
|
| 41 |
+
with gr.Row():
|
| 42 |
+
Image_input = gr.Image(type="numpy", label="Input", interactive=True)
|
| 43 |
+
Image_anchor = gr.Image(type="numpy", label="Anchor", tool="color-sketch", interactive=True, visible=False)
|
| 44 |
with gr.Row():
|
| 45 |
Num_anchor = gr.Number(type="int", value=8, label="Num. of anchors (3~14)")
|
| 46 |
Radio_resolution = gr.Radio(type="index", choices=["Low (256x256)", "High (512x512)"], \
|
| 47 |
+
label="Colorization resolution (Low is more stable)", value="Low (256x256)")
|
|
|
|
| 48 |
with gr.Row():
|
| 49 |
+
Ckeckbox_editable = gr.Checkbox(default=False, label='Show editable anchors')
|
| 50 |
Button_show_anchor = gr.Button(value="Predict anchors", visible=False)
|
| 51 |
+
Button_run = gr.Button(value="Colorize")
|
| 52 |
+
with gr.Column():
|
| 53 |
Image_output = gr.Image(type="numpy", label="Output").style(height=480)
|
| 54 |
+
|
| 55 |
Ckeckbox_editable.change(fn=switch_states, inputs=Ckeckbox_editable, outputs=[Image_anchor, Button_show_anchor])
|
| 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], \
|
|
|
|
| 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.
|