Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -190,9 +190,7 @@ with gr.Blocks() as demo:
|
|
190 |
]
|
191 |
|
192 |
mode.change(toggle_inputs, inputs=mode, outputs=[media_upload, url])
|
193 |
-
|
194 |
-
url.submit(show_preview_from_url, inputs=url, outputs=[img_out, vid_out])
|
195 |
-
|
196 |
# Visibility logic function
|
197 |
def toggle_visibility(checked):
|
198 |
return gr.update(visible=checked)
|
@@ -253,8 +251,19 @@ with gr.Blocks() as demo:
|
|
253 |
json_out = gr.JSON(label="Scene JSON")
|
254 |
zip_out = gr.File(label="Download Results")
|
255 |
|
256 |
-
|
257 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
258 |
|
259 |
# # Output Tabs
|
260 |
# with gr.Tab("Scene JSON"):
|
|
|
190 |
]
|
191 |
|
192 |
mode.change(toggle_inputs, inputs=mode, outputs=[media_upload, url])
|
193 |
+
|
|
|
|
|
194 |
# Visibility logic function
|
195 |
def toggle_visibility(checked):
|
196 |
return gr.update(visible=checked)
|
|
|
251 |
json_out = gr.JSON(label="Scene JSON")
|
252 |
zip_out = gr.File(label="Download Results")
|
253 |
|
254 |
+
media_upload.change(show_preview_from_upload, inputs=media_upload, outputs=[img_out, vid_out])
|
255 |
+
url.submit(show_preview_from_url, inputs=url, outputs=[img_out, vid_out])
|
256 |
+
|
257 |
+
# Unified run click → switch visibility based on image or video output
|
258 |
+
def route_output(image_output, json_output, zip_file):
|
259 |
+
# Show img_out if image was returned, else show video
|
260 |
+
if isinstance(image_output, Image.Image):
|
261 |
+
return gr.update(value=image_output, visible=True), gr.update(visible=False), json_output, zip_file
|
262 |
+
elif isinstance(zip_file, str) and zip_file.endswith(".mp4"):
|
263 |
+
return gr.update(visible=False), gr.update(value=zip_file, visible=True), json_output, zip_file
|
264 |
+
else:
|
265 |
+
return gr.update(visible=False), gr.update(visible=False), json_output, zip_file
|
266 |
+
|
267 |
|
268 |
# # Output Tabs
|
269 |
# with gr.Tab("Scene JSON"):
|