File size: 1,639 Bytes
06f8492
 
 
 
 
 
 
 
d1214df
06f8492
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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()