Spaces:
Sleeping
Sleeping
223111524
commited on
Commit
·
fffeff1
1
Parent(s):
4cd47e5
Add video format validation
Browse files
app.py
CHANGED
|
@@ -1,8 +1,15 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
def process_video(video, visualize_features):
|
| 4 |
if video is None:
|
| 5 |
return None, "Error: No video uploaded."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
try:
|
| 7 |
# Placeholder: In a real app, process the video and visualize features if requested
|
| 8 |
msg = "Feature visualization enabled." if visualize_features else "Feature visualization disabled."
|
|
@@ -10,7 +17,7 @@ def process_video(video, visualize_features):
|
|
| 10 |
except Exception as e:
|
| 11 |
return None, f"Error: {str(e)}"
|
| 12 |
|
| 13 |
-
with gr.Blocks(theme=gr.themes.Base(), css=".gradio-container {background: #111827; color: #d1d5db;}") as demo:
|
| 14 |
gr.Markdown(
|
| 15 |
"""
|
| 16 |
# <span style="background: linear-gradient(to right, #2dd4bf, #06b6d4); -webkit-background-clip: text; color: transparent;">DINOv3 Video Tracking</span>
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import mimetypes
|
| 3 |
|
| 4 |
def process_video(video, visualize_features):
|
| 5 |
if video is None:
|
| 6 |
return None, "Error: No video uploaded."
|
| 7 |
+
|
| 8 |
+
# Validate video format
|
| 9 |
+
mime_type, _ = mimetypes.guess_type(video)
|
| 10 |
+
if not mime_type or not mime_type.startswith("video"):
|
| 11 |
+
return None, "Error: Unsupported file format. Please upload a valid video file."
|
| 12 |
+
|
| 13 |
try:
|
| 14 |
# Placeholder: In a real app, process the video and visualize features if requested
|
| 15 |
msg = "Feature visualization enabled." if visualize_features else "Feature visualization disabled."
|
|
|
|
| 17 |
except Exception as e:
|
| 18 |
return None, f"Error: {str(e)}"
|
| 19 |
|
| 20 |
+
with gr.Blocks(theme=gr.themes.Base(), css=".gradio-container {background: #111827; color: #d1d5db;}" ) as demo:
|
| 21 |
gr.Markdown(
|
| 22 |
"""
|
| 23 |
# <span style="background: linear-gradient(to right, #2dd4bf, #06b6d4); -webkit-background-clip: text; color: transparent;">DINOv3 Video Tracking</span>
|