Spaces:
Sleeping
Sleeping
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.") |