dschandra commited on
Commit
333da55
Β·
verified Β·
1 Parent(s): 3dbd75e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -49
app.py CHANGED
@@ -1,50 +1,29 @@
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
-
10
- def handle_upload(video_file):
11
- # Step 1: Extract frames and data
12
- video_path = video_file
13
- frames, metadata = process_video(video_path)
14
-
15
- # Step 2: Object detection and impact analysis
16
- detections = detect_lbw_event(frames)
17
-
18
- # Step 3: Trajectory prediction
19
- trajectory_result = predict_trajectory(detections)
20
-
21
- # Step 4: Visualization and decision video
22
- result_video_path, decision = generate_output_video(
23
- frames, detections, trajectory_result
24
- )
25
-
26
- return result_video_path, f"Decision: {decision}"
27
-
28
- def handle_live_simulation():
29
- return "Live stream analysis is under development. Coming soon!"
30
-
31
- with gr.Blocks() as app:
32
- gr.Markdown("# 🏏 LBW DRS System\nUpload a video or simulate a live appeal.")
33
-
34
- with gr.Tabs():
35
- with gr.TabItem("πŸ“€ Upload Video"):
36
- video_input = gr.Video(label="Upload LBW Video")
37
- run_button = gr.Button("Analyze")
38
- output_video = gr.Video(label="Replay with AI Overlays")
39
- decision_text = gr.Textbox(label="Final Decision")
40
-
41
- run_button.click(
42
- fn=handle_upload,
43
- inputs=[video_input],
44
- outputs=[output_video, decision_text]
45
- )
46
-
47
- with gr.TabItem("πŸ“Ί Live Stream"):
48
- live_info = gr.Textbox(value=handle_live_simulation(), label="Live System Status", interactive=False)
49
-
50
- app.launch()
 
1
  import gradio as gr
2
+ from video_processor import process_live_video, process_uploaded_video
3
+
4
+ def analyze_live_video():
5
+ result_path, decision = process_live_video()
6
+ return result_path, decision
7
+
8
+ def analyze_uploaded_video(video):
9
+ result_path, decision = process_uploaded_video(video)
10
+ return result_path, decision
11
+
12
+ with gr.Blocks(title="Smart LBW DRS System") as demo:
13
+ gr.Markdown("# 🏏 Smart LBW DRS System")
14
+ with gr.Tab("πŸ“‘ Live Match Review"):
15
+ gr.Markdown("Automatically captures last 10 seconds on LBW appeal and analyzes it.")
16
+ live_btn = gr.Button("Analyze Last 10s")
17
+ live_video = gr.Video(label="AI Annotated Replay")
18
+ live_text = gr.Textbox(label="Decision", interactive=False)
19
+ live_btn.click(fn=analyze_live_video, outputs=[live_video, live_text])
20
+
21
+ with gr.Tab("πŸ“€ Upload Review Clip"):
22
+ gr.Markdown("Upload a short clip with an LBW appeal.")
23
+ upload_input = gr.Video(label="Input Video")
24
+ upload_btn = gr.Button("Analyze Upload")
25
+ upload_output = gr.Video(label="AI Annotated Replay")
26
+ upload_text = gr.Textbox(label="Decision", interactive=False)
27
+ upload_btn.click(fn=analyze_uploaded_video, inputs=[upload_input], outputs=[upload_output, upload_text])
28
+
29
+ demo.launch()