Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,52 +1,18 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from
|
|
|
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
|
| 8 |
-
#
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 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()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|