Spaces:
Runtime error
Runtime error
Updated visibility change callbacks
Browse files
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import os
|
|
|
|
| 2 |
|
| 3 |
import torch
|
| 4 |
import gradio as gr
|
|
@@ -207,11 +208,12 @@ class ImageEditor(object):
|
|
| 207 |
|
| 208 |
editor = ImageEditor()
|
| 209 |
|
| 210 |
-
def change_component_visibility(
|
| 211 |
-
return component.update(visible=visible)
|
| 212 |
|
| 213 |
-
def
|
| 214 |
-
|
|
|
|
|
|
|
| 215 |
|
| 216 |
blocks = gr.Blocks()
|
| 217 |
|
|
@@ -241,10 +243,10 @@ with blocks:
|
|
| 241 |
img_output = gr.outputs.Image(type="file")
|
| 242 |
vid_output = gr.outputs.Video()
|
| 243 |
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
|
| 249 |
img_button.click(fn=editor.predict, inputs=[input_img, style_choice, video_choice, edit_choice, vid_format_choice], outputs=img_output)
|
| 250 |
vid_button.click(fn=editor.predict, inputs=[input_img, style_choice, video_choice, edit_choice, vid_format_choice], outputs=vid_output)
|
|
|
|
| 1 |
import os
|
| 2 |
+
from posixpath import basename
|
| 3 |
|
| 4 |
import torch
|
| 5 |
import gradio as gr
|
|
|
|
| 208 |
|
| 209 |
editor = ImageEditor()
|
| 210 |
|
| 211 |
+
def change_component_visibility(component_types, invert_choices):
|
|
|
|
| 212 |
|
| 213 |
+
def visibility_impl(visible):
|
| 214 |
+
return [component_types[idx].update(visible ^ invert_choices[idx]) for idx in range(len(component_types))]
|
| 215 |
+
|
| 216 |
+
return visibility_impl
|
| 217 |
|
| 218 |
blocks = gr.Blocks()
|
| 219 |
|
|
|
|
| 243 |
img_output = gr.outputs.Image(type="file")
|
| 244 |
vid_output = gr.outputs.Video()
|
| 245 |
|
| 246 |
+
visibility_fn = change_component_visibility(component_types=[gr.Checkbox, gr.Radio, gr.Video, gr.Button, gr.Image, gr.Button],
|
| 247 |
+
invert_choices=[False, False, False, False, True, True])
|
| 248 |
+
|
| 249 |
+
video_choice.change(fn=visibility_fn, inputs=video_choice, outputs=[edit_choice, vid_format_choice, vid_output, vid_button, img_output, img_button])
|
| 250 |
|
| 251 |
img_button.click(fn=editor.predict, inputs=[input_img, style_choice, video_choice, edit_choice, vid_format_choice], outputs=img_output)
|
| 252 |
vid_button.click(fn=editor.predict, inputs=[input_img, style_choice, video_choice, edit_choice, vid_format_choice], outputs=vid_output)
|