lbw_app / app.py
DSatishchandra's picture
Update app.py
dd8029e verified
import gradio as gr
from video_utils import process_video
from lbw_logic import decide_lbw
def analyze_and_decide(video):
if video is None:
return "Please upload or record a video", None, None
prediction_path, replay_path, analysis_data = process_video(video)
decision = decide_lbw(analysis_data)
return decision, prediction_path, replay_path
with gr.Blocks() as demo:
gr.Markdown("## 🏏 LBW Decision System")
with gr.Tab("Upload Video"):
upload_video = gr.Video(label="Upload Delivery Video")
upload_output = gr.Textbox(label="Decision")
upload_pred = gr.Video(label="Predicted Trajectory")
upload_replay = gr.Video(label="Replay Video")
upload_btn = gr.Button("Analyze Uploaded Video")
upload_btn.click(analyze_and_decide, inputs=upload_video,
outputs=[upload_output, upload_pred, upload_replay])
with gr.Tab("Live Capture (Record & Upload)"):
gr.Markdown("πŸŽ₯ Record a video using your webcam and upload it here.")
live_video = gr.Video(label="Record and Upload Live Delivery")
live_output = gr.Textbox(label="Decision")
live_pred = gr.Video(label="Predicted Trajectory")
live_replay = gr.Video(label="Replay Video")
live_btn = gr.Button("Analyze Live Video")
live_btn.click(analyze_and_decide, inputs=live_video,
outputs=[live_output, live_pred, live_replay])
demo.launch()