import gradio as gr from video_processor import process_video from lbw_detector import detect_lbw_event from trajectory_predictor import predict_trajectory from visualizer import generate_output_video import tempfile import os def handle_upload(video_file): # Step 1: Extract frames and data video_path = video_file.name frames, metadata = process_video(video_path) # Step 2: Object detection and impact analysis detections = detect_lbw_event(frames) # Step 3: Trajectory prediction trajectory_result = predict_trajectory(detections) # Step 4: Visualization and decision video result_video_path, decision = generate_output_video( frames, detections, trajectory_result ) return result_video_path, f"Decision: {decision}" def handle_live_simulation(): return "Live stream analysis is under development. Coming soon!" with gr.Blocks() as app: gr.Markdown("# 🏏 LBW DRS System\nUpload a video or simulate a live appeal.") with gr.Tabs(): with gr.TabItem("📤 Upload Video"): video_input = gr.Video(label="Upload LBW Video") run_button = gr.Button("Analyze") output_video = gr.Video(label="Replay with AI Overlays") decision_text = gr.Textbox(label="Final Decision") run_button.click( fn=handle_upload, inputs=[video_input], outputs=[output_video, decision_text] ) with gr.TabItem("📺 Live Stream"): live_info = gr.Textbox(value=handle_live_simulation(), label="Live System Status", interactive=False) app.launch()