Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,7 +19,7 @@ import spaces
|
|
| 19 |
from registry import get_model
|
| 20 |
from core.describe_scene import describe_scene
|
| 21 |
from core.process import process_image
|
| 22 |
-
from core.input_handler import resolve_input, validate_video, validate_image
|
| 23 |
from utils.helpers import format_error, generate_session_id
|
| 24 |
from huggingface_hub import hf_hub_download
|
| 25 |
|
|
@@ -131,21 +131,30 @@ with gr.Blocks() as demo:
|
|
| 131 |
# URL input
|
| 132 |
url = gr.Textbox(label="URL (Image/Video)", visible=False)
|
| 133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
# Toggle visibility
|
| 135 |
def toggle_inputs(selected_mode):
|
| 136 |
return [
|
| 137 |
gr.update(visible=(selected_mode == "Upload")), # media_upload
|
| 138 |
-
gr.update(visible=(selected_mode == "URL")) # url
|
|
|
|
|
|
|
|
|
|
| 139 |
]
|
| 140 |
|
| 141 |
mode.change(toggle_inputs, inputs=mode, outputs=[media_upload, url])
|
| 142 |
-
|
|
|
|
|
|
|
| 143 |
# Visibility logic function
|
| 144 |
def toggle_visibility(checked):
|
| 145 |
return gr.update(visible=checked)
|
| 146 |
|
| 147 |
-
def toggle_det_visibility(checked):
|
| 148 |
-
|
| 149 |
|
| 150 |
run_det = gr.Checkbox(label="Object Detection")
|
| 151 |
run_seg = gr.Checkbox(label="Semantic Segmentation")
|
|
|
|
| 19 |
from registry import get_model
|
| 20 |
from core.describe_scene import describe_scene
|
| 21 |
from core.process import process_image
|
| 22 |
+
from core.input_handler import resolve_input, validate_video, validate_image, show_preview_from_upload, show_preview_from_url
|
| 23 |
from utils.helpers import format_error, generate_session_id
|
| 24 |
from huggingface_hub import hf_hub_download
|
| 25 |
|
|
|
|
| 131 |
# URL input
|
| 132 |
url = gr.Textbox(label="URL (Image/Video)", visible=False)
|
| 133 |
|
| 134 |
+
# Preview uploaded media
|
| 135 |
+
preview_image = gr.Image(label="Preview Image", visible=False)
|
| 136 |
+
preview_video = gr.Video(label="Preview Video", visible=False)
|
| 137 |
+
|
| 138 |
# Toggle visibility
|
| 139 |
def toggle_inputs(selected_mode):
|
| 140 |
return [
|
| 141 |
gr.update(visible=(selected_mode == "Upload")), # media_upload
|
| 142 |
+
gr.update(visible=(selected_mode == "URL")), # url
|
| 143 |
+
gr.update(visible=False), # preview_image
|
| 144 |
+
gr.update(visible=False) # preview_video
|
| 145 |
+
|
| 146 |
]
|
| 147 |
|
| 148 |
mode.change(toggle_inputs, inputs=mode, outputs=[media_upload, url])
|
| 149 |
+
media_upload.change(show_preview_from_upload, inputs=media_upload, outputs=[preview_image, preview_video])
|
| 150 |
+
url.submit(show_preview_from_url, inputs=url, outputs=[preview_image, preview_video])
|
| 151 |
+
|
| 152 |
# Visibility logic function
|
| 153 |
def toggle_visibility(checked):
|
| 154 |
return gr.update(visible=checked)
|
| 155 |
|
| 156 |
+
# def toggle_det_visibility(checked):
|
| 157 |
+
# return [gr.update(visible=checked), gr.update(visible=checked)]
|
| 158 |
|
| 159 |
run_det = gr.Checkbox(label="Object Detection")
|
| 160 |
run_seg = gr.Checkbox(label="Semantic Segmentation")
|