import gradio as gr import mimetypes def process_video(video, visualize_features): if video is None: return None, "Error: No video uploaded." # Validate video format mime_type, _ = mimetypes.guess_type(video) if not mime_type or not mime_type.startswith("video"): return None, "Error: Unsupported file format. Please upload a valid video file." try: # Placeholder: In a real app, process the video and visualize features if requested msg = "Feature visualization enabled." if visualize_features else "Feature visualization disabled." return video, msg except Exception as e: return None, f"Error: {str(e)}" with gr.Blocks(theme=gr.themes.Base(), css=".gradio-container {background: #111827; color: #d1d5db;}" ) as demo: gr.Markdown( """ # DINOv3 Video Tracking In-browser video tracking powered by Transformers.js """, elem_id="title" ) with gr.Row(): video_input = gr.Video(label="Select a video or drag and drop") with gr.Row(): visualize = gr.Checkbox(label="Visualize Dense Features", value=False) with gr.Row(): video_output = gr.Video(label="Preview") msg_output = gr.Textbox(label="Status", interactive=False) gr.Button("Run").click( process_video, inputs=[video_input, visualize], outputs=[video_output, msg_output] ) if __name__ == "__main__": demo.launch()