DSatishchandra commited on
Commit
5c87a2c
·
verified ·
1 Parent(s): cf923d4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -48
app.py CHANGED
@@ -1,52 +1,18 @@
1
  import gradio as gr
2
- from gully_drs_core import ball_detection, replay_utils
 
3
 
4
- def record_or_upload_video(video_input, pitch_position):
5
- # Handle video input (either upload or recording)
6
- video_path = video_input.name if hasattr(video_input, 'name') else video_input
7
 
8
- # Pass the video path and pitch position to the LBW detection logic
9
- result_clip_path, decision = ball_detection.process_lbw_detection(video_path, pitch_position)
 
 
 
 
10
 
11
- return result_clip_path, decision
12
-
13
- def process_lbw_detection(uploaded_video_file):
14
- try:
15
- # Process the uploaded video for LBW detection
16
- result_clip_path, decision = ball_detection.process_lbw_detection(uploaded_video_file)
17
- return result_clip_path, decision
18
- except Exception as e:
19
- return None, f"Error during LBW detection: {e}"
20
-
21
- def create_lbw_ui():
22
- with gr.Blocks() as demo:
23
- gr.Markdown("### 🏏 GullyDRS - AI Powered Gully Cricket Review System")
24
-
25
- # Video input: either upload a video or record a video
26
- with gr.Row():
27
- video_input = gr.Video(label="Upload or Record a Match Video", type="filepath", interactive=True)
28
-
29
- # Slider for wickets pitch setup
30
- pitch_position = gr.Slider(minimum=0, maximum=100, label="Set Wickets Pitch", value=50) # Example range
31
-
32
- # Button to process the video and make LBW decision
33
- process_btn = gr.Button("🚨 Start LBW Detection")
34
-
35
- # Result output (replay video and decision)
36
- with gr.Row():
37
- result_clip = gr.Video(label="Replay with LBW Decision", elem_id="result_video")
38
- decision_output = gr.Textbox(label="LBW Decision", interactive=False)
39
-
40
- # Trigger video processing and analysis when the button is clicked
41
- process_btn.click(
42
- fn=record_or_upload_video,
43
- inputs=[video_input, pitch_position],
44
- outputs=[result_clip, decision_output]
45
- )
46
-
47
- return demo
48
-
49
-
50
- # Launch the Gradio UI for LBW review
51
- demo = create_lbw_ui()
52
- demo.launch(share=True) # Using share=True to allow public URL
 
1
  import gradio as gr
2
+ from pages.live_match import create_lbw_ui
3
+ from pages.upload_analysis import create_analysis_ui
4
 
5
+ # Define the Gradio interface with tabs
6
+ with gr.Blocks(title="Gully DRS - Decision Review System") as app:
7
+ gr.Markdown("# Gully DRS - Decision Review System")
8
 
9
+ # Create tabs for Live Match and Pose Analysis
10
+ with gr.Tabs():
11
+ with gr.TabItem("Live Match LBW Review"):
12
+ create_lbw_ui()
13
+ with gr.TabItem("Pose-Based Practice Analysis"):
14
+ create_analysis_ui()
15
 
16
+ # Launch the app
17
+ if __name__ == "__main__":
18
+ app.launch()