GullyDRS / app.py
AjaykumarPilla's picture
Update app.py
95e8809 verified
import streamlit as st
import tempfile
import os
from gully_drs_core import ball_detection, replay_utils
st.set_page_config(page_title="GullyDRS – LBW Review", layout="centered")
st.title("🏏 GullyDRS – LBW Decision Review System")
st.markdown("""
Upload a cricket match video and let AI analyze whether it's **OUT** or **NOT OUT**
based on ball trajectory, bounce point, and stump zone detection.
""")
video_file = st.file_uploader("πŸŽ₯ Upload your match video", type=["mp4", "avi"])
if video_file:
tfile = tempfile.NamedTemporaryFile(delete=False)
tfile.write(video_file.read())
st.video(video_file)
if st.button("🧠 Analyze Video"):
with st.spinner("Analyzing with AI..."):
result = ball_detection.analyze_video(tfile.name)
st.write(f"πŸ” Trajectory points: {len(result['trajectory'])}")
st.write(f"🏁 Final Decision: **{result['decision']}**")
st.write(f"πŸš€ Ball Speed: **{result['speed_kmh']} km/h**")
if result["bounce_point"]:
st.info(f"πŸ“ Bounce detected at: {result['bounce_point']}")
if result["impact_point"]:
st.info(f"🎯 Impact point: {result['impact_point']}")
replay_path = replay_utils.generate_replay(
frames=result["frames"],
ball_path=result["trajectory"],
bounce_point=result["bounce_point"],
impact_point=result["impact_point"],
decision=result["decision"],
stump_zone=result["stump_zone"],
speed_kmh=result["speed_kmh"],
fps=result["fps"]
)
if replay_path and os.path.exists(replay_path):
st.success("βœ… Replay generated successfully!")
st.video(replay_path)
else:
st.error("⚠️ Replay generation failed or produced no video.")