Spaces:
Runtime error
Runtime error
Commit
·
ad90eb1
1
Parent(s):
f575d0d
Update app.py
Browse files
app.py
CHANGED
@@ -33,43 +33,47 @@ def switch_states(is_checked):
|
|
33 |
return gr.Image.update(visible=True), gr.Button.update(visible=True)
|
34 |
else:
|
35 |
return gr.Image.update(visible=False), gr.Button.update(visible=False)
|
36 |
-
|
|
|
37 |
with demo:
|
38 |
gr.Markdown(value="""
|
39 |
-
|
40 |
""")
|
41 |
-
|
|
|
42 |
with gr.Column():
|
43 |
with gr.Row():
|
44 |
-
Image_input = gr.Image(type="numpy", label="Input", interactive=True)
|
45 |
-
Image_anchor = gr.Image(type="numpy", label="Anchor", tool="color-sketch", interactive=True, visible=False)
|
46 |
with gr.Row():
|
47 |
-
Num_anchor = gr.Number(type="int", value=8, label="Num. of anchors (3~14)")
|
48 |
-
Radio_resolution = gr.Radio(
|
49 |
-
label="Colorization resolution (Low is more stable)", value="Low (256x256)")
|
50 |
with gr.Row():
|
51 |
-
|
52 |
-
Button_show_anchor = gr.Button(value="Predict anchors", visible=False)
|
53 |
-
Button_run = gr.Button(value="Colorize")
|
|
|
54 |
with gr.Column():
|
55 |
-
Image_output = [gr.Image(type="numpy", label="Output").style(height=480), gr.Image(type="numpy", label="Output").style(height=480)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
-
Ckeckbox_editable.change(fn=switch_states, inputs=Ckeckbox_editable, outputs=[Image_anchor, Button_show_anchor])
|
58 |
-
Button_show_anchor.click(fn=click_predanchors, inputs=[Image_input, Num_anchor, Radio_resolution, Ckeckbox_editable], outputs=Image_anchor)
|
59 |
-
Button_run.click(fn=click_colorize, inputs=[Image_input, Image_anchor, Num_anchor, Radio_resolution, Ckeckbox_editable], \
|
60 |
-
outputs=Image_output)
|
61 |
-
|
62 |
## guiline
|
63 |
-
|
64 |
if RUN_MODE != "local":
|
65 |
-
gr.Examples(examples=[
|
66 |
-
|
67 |
-
|
68 |
-
inputs=[Image_input,Num_anchor,Radio_resolution], outputs=[Image_output], label="Используйте эту фотографию для примера кликнув по ней", cache_examples=False)
|
69 |
-
|
70 |
|
71 |
if RUN_MODE == "local":
|
72 |
-
demo.launch(server_name=
|
73 |
else:
|
74 |
-
demo.queue(default_enabled=True, status_update_rate=5)
|
75 |
demo.launch()
|
|
|
33 |
return gr.Image.update(visible=True), gr.Button.update(visible=True)
|
34 |
else:
|
35 |
return gr.Image.update(visible=False), gr.Button.update(visible=False)
|
36 |
+
|
37 |
+
demo = gr.Interface(title="DISCO")
|
38 |
with demo:
|
39 |
gr.Markdown(value="""
|
40 |
+
Gradio demo for DISCO: Disentangled Image Colorization via Global Anchors. Check our [project page](https://menghanxia.github.io/projects/disco.html) 😛.
|
41 |
""")
|
42 |
+
|
43 |
+
with gr.Row():
|
44 |
with gr.Column():
|
45 |
with gr.Row():
|
46 |
+
Image_input = gr.inputs.Image(type="numpy", label="Input", interactive=True)
|
47 |
+
Image_anchor = gr.inputs.Image(type="numpy", label="Anchor", tool="color-sketch", interactive=True, visible=False)
|
48 |
with gr.Row():
|
49 |
+
Num_anchor = gr.inputs.Number(type="int", value=8, label="Num. of anchors (3~14)")
|
50 |
+
Radio_resolution = gr.inputs.Radio(choices=["Low (256x256)", "High (512x512)"], label="Colorization resolution (Low is more stable)", default="Low (256x256)")
|
|
|
51 |
with gr.Row():
|
52 |
+
Checkbox_editable = gr.inputs.Checkbox(default=False, label='Show editable anchors')
|
53 |
+
Button_show_anchor = gr.inputs.Button(value="Predict anchors", visible=False)
|
54 |
+
Button_run = gr.inputs.Button(value="Colorize")
|
55 |
+
|
56 |
with gr.Column():
|
57 |
+
Image_output = [gr.outputs.Image(type="numpy", label="Output").style(height=480), gr.outputs.Image(type="numpy", label="Output").style(height=480)]
|
58 |
+
|
59 |
+
output_image_anchor, output_button_show_anchor = gr.outputs.Image(), gr.outputs.Button()
|
60 |
+
output_image_output = [gr.outputs.Image(label="Output").style(height=480), gr.outputs.Image(label="Output").style(height=480)]
|
61 |
+
|
62 |
+
gr.Interface.Transforms(
|
63 |
+
output_image_anchor, output_button_show_anchor, func=switch_states, inputs=Checkbox_editable, outputs=[Image_anchor, Button_show_anchor]
|
64 |
+
)
|
65 |
+
|
66 |
+
gr.Interface.Button(Button_show_anchor, func=click_predanchors, inputs=[Image_input, Num_anchor, Radio_resolution, Checkbox_editable], outputs=Image_anchor)
|
67 |
+
|
68 |
+
gr.Interface.Button(Button_run, func=click_colorize, inputs=[Image_input, Image_anchor, Num_anchor, Radio_resolution, Checkbox_editable], outputs=output_image_output)
|
69 |
|
|
|
|
|
|
|
|
|
|
|
70 |
## guiline
|
|
|
71 |
if RUN_MODE != "local":
|
72 |
+
gr.Interface.Examples(examples=[
|
73 |
+
['04.jpg', 8, "Low (256x256)"],
|
74 |
+
], inputs=[Image_input, Num_anchor, Radio_resolution], outputs=output_image_output, title="Используйте эту фотографию для примера кликнув по ней").initialize(auto_close=False, auto_close_timeout=999)
|
|
|
|
|
75 |
|
76 |
if RUN_MODE == "local":
|
77 |
+
demo.launch(server_name="9.134.253.83", server_port=7788)
|
78 |
else:
|
|
|
79 |
demo.launch()
|