Spaces:
Runtime error
Runtime error
Update core/input_handler.py
Browse files- core/input_handler.py +8 -13
core/input_handler.py
CHANGED
|
@@ -123,30 +123,25 @@ def validate_video(path):
|
|
| 123 |
def show_preview_from_upload(files):
|
| 124 |
if not files or len(files) == 0:
|
| 125 |
return gr.update(visible=False), gr.update(visible=False)
|
| 126 |
-
|
| 127 |
file = files[0]
|
| 128 |
file_path = file.name.lower()
|
| 129 |
-
|
| 130 |
-
# Handle Image Preview via PIL
|
| 131 |
if file_path.endswith((".png", ".jpg", ".jpeg", ".webp")):
|
| 132 |
pil_image = Image.open(file).convert("RGB")
|
| 133 |
return gr.update(value=pil_image, visible=True), gr.update(visible=False)
|
| 134 |
-
|
| 135 |
-
# Handle Video Preview via .name
|
| 136 |
elif file_path.endswith((".mp4", ".mov", ".avi")):
|
| 137 |
return gr.update(visible=False), gr.update(value=file.name, visible=True)
|
| 138 |
-
|
| 139 |
return gr.update(visible=False), gr.update(visible=False)
|
| 140 |
|
| 141 |
-
def show_preview_from_url(
|
| 142 |
-
if not
|
| 143 |
return gr.update(visible=False), gr.update(visible=False)
|
| 144 |
-
|
| 145 |
-
if
|
| 146 |
-
return gr.update(value=
|
| 147 |
-
elif
|
| 148 |
-
return gr.update(visible=False), gr.update(value=
|
| 149 |
return gr.update(visible=False), gr.update(visible=False)
|
|
|
|
| 150 |
|
| 151 |
# Input Resolution
|
| 152 |
def resolve_input(mode, media_upload, url):
|
|
|
|
| 123 |
def show_preview_from_upload(files):
|
| 124 |
if not files or len(files) == 0:
|
| 125 |
return gr.update(visible=False), gr.update(visible=False)
|
|
|
|
| 126 |
file = files[0]
|
| 127 |
file_path = file.name.lower()
|
|
|
|
|
|
|
| 128 |
if file_path.endswith((".png", ".jpg", ".jpeg", ".webp")):
|
| 129 |
pil_image = Image.open(file).convert("RGB")
|
| 130 |
return gr.update(value=pil_image, visible=True), gr.update(visible=False)
|
|
|
|
|
|
|
| 131 |
elif file_path.endswith((".mp4", ".mov", ".avi")):
|
| 132 |
return gr.update(visible=False), gr.update(value=file.name, visible=True)
|
|
|
|
| 133 |
return gr.update(visible=False), gr.update(visible=False)
|
| 134 |
|
| 135 |
+
def show_preview_from_url(url_input):
|
| 136 |
+
if not url_input:
|
| 137 |
return gr.update(visible=False), gr.update(visible=False)
|
| 138 |
+
url_lower = url_input.strip().lower()
|
| 139 |
+
if url_lower.endswith((".png", ".jpg", ".jpeg", ".webp")):
|
| 140 |
+
return gr.update(value=url_input, visible=True), gr.update(visible=False)
|
| 141 |
+
elif url_lower.endswith((".mp4", ".mov", ".avi")):
|
| 142 |
+
return gr.update(visible=False), gr.update(value=url_input, visible=True)
|
| 143 |
return gr.update(visible=False), gr.update(visible=False)
|
| 144 |
+
|
| 145 |
|
| 146 |
# Input Resolution
|
| 147 |
def resolve_input(mode, media_upload, url):
|