dschandra commited on
Commit
06f8492
·
verified ·
1 Parent(s): 6676f4f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -0
app.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from video_processor import process_video
3
+ from lbw_detector import detect_lbw_event
4
+ from trajectory_predictor import predict_trajectory
5
+ from visualizer import generate_output_video
6
+ import tempfile
7
+ import os
8
+
9
+ def handle_upload(video_file):
10
+ # Step 1: Extract frames and data
11
+ video_path = video_file.name
12
+ frames, metadata = process_video(video_path)
13
+
14
+ # Step 2: Object detection and impact analysis
15
+ detections = detect_lbw_event(frames)
16
+
17
+ # Step 3: Trajectory prediction
18
+ trajectory_result = predict_trajectory(detections)
19
+
20
+ # Step 4: Visualization and decision video
21
+ result_video_path, decision = generate_output_video(
22
+ frames, detections, trajectory_result
23
+ )
24
+
25
+ return result_video_path, f"Decision: {decision}"
26
+
27
+ def handle_live_simulation():
28
+ return "Live stream analysis is under development. Coming soon!"
29
+
30
+ with gr.Blocks() as app:
31
+ gr.Markdown("# 🏏 LBW DRS System\nUpload a video or simulate a live appeal.")
32
+
33
+ with gr.Tabs():
34
+ with gr.TabItem("📤 Upload Video"):
35
+ video_input = gr.Video(label="Upload LBW Video")
36
+ run_button = gr.Button("Analyze")
37
+ output_video = gr.Video(label="Replay with AI Overlays")
38
+ decision_text = gr.Textbox(label="Final Decision")
39
+
40
+ run_button.click(
41
+ fn=handle_upload,
42
+ inputs=[video_input],
43
+ outputs=[output_video, decision_text]
44
+ )
45
+
46
+ with gr.TabItem("📺 Live Stream"):
47
+ live_info = gr.Textbox(value=handle_live_simulation(), label="Live System Status", interactive=False)
48
+
49
+ app.launch()