Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,21 +2,49 @@ import streamlit as st
|
|
2 |
import tempfile
|
3 |
from gully_drs_core import ball_detection, replay_utils
|
4 |
|
5 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
-
video_file = st.file_uploader("Upload a cricket match video", type=["mp4", "avi"])
|
8 |
if video_file:
|
|
|
9 |
tfile = tempfile.NamedTemporaryFile(delete=False)
|
10 |
tfile.write(video_file.read())
|
|
|
|
|
11 |
st.video(video_file)
|
12 |
|
13 |
-
|
14 |
-
|
|
|
15 |
result = ball_detection.analyze_video(tfile.name)
|
|
|
|
|
16 |
replay_path = replay_utils.generate_replay(
|
17 |
-
result["frames"],
|
18 |
-
result["trajectory"],
|
|
|
|
|
|
|
|
|
19 |
fps=result["fps"]
|
20 |
)
|
21 |
-
|
|
|
|
|
22 |
st.video(replay_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
import tempfile
|
3 |
from gully_drs_core import ball_detection, replay_utils
|
4 |
|
5 |
+
st.set_page_config(page_title="GullyDRS β LBW Review", layout="centered")
|
6 |
+
st.title("π GullyDRS β LBW Decision Review System")
|
7 |
+
|
8 |
+
st.markdown(
|
9 |
+
"""
|
10 |
+
Upload a cricket match video and let AI analyze whether it's **OUT** or **NOT OUT**
|
11 |
+
based on ball trajectory, bounce point, and stump zone detection.
|
12 |
+
"""
|
13 |
+
)
|
14 |
+
|
15 |
+
# Upload video file
|
16 |
+
video_file = st.file_uploader("π₯ Upload your match video", type=["mp4", "avi"])
|
17 |
|
|
|
18 |
if video_file:
|
19 |
+
# Store video temporarily
|
20 |
tfile = tempfile.NamedTemporaryFile(delete=False)
|
21 |
tfile.write(video_file.read())
|
22 |
+
|
23 |
+
# Preview uploaded video
|
24 |
st.video(video_file)
|
25 |
|
26 |
+
# Trigger analysis
|
27 |
+
if st.button("π§ Analyze Video"):
|
28 |
+
with st.spinner("Analyzing with AI..."):
|
29 |
result = ball_detection.analyze_video(tfile.name)
|
30 |
+
|
31 |
+
# Generate replay with overlays
|
32 |
replay_path = replay_utils.generate_replay(
|
33 |
+
frames=result["frames"],
|
34 |
+
ball_path=result["trajectory"],
|
35 |
+
bounce_point=result["bounce_point"],
|
36 |
+
impact_point=result["impact_point"],
|
37 |
+
decision=result["decision"],
|
38 |
+
stump_zone=result["stump_zone"],
|
39 |
fps=result["fps"]
|
40 |
)
|
41 |
+
|
42 |
+
# Show decision and replay
|
43 |
+
st.success(f"π Final Decision: **{result['decision']}**")
|
44 |
st.video(replay_path)
|
45 |
+
|
46 |
+
# Show extra info
|
47 |
+
if result["bounce_point"]:
|
48 |
+
st.info(f"π Bounce detected at: {result['bounce_point']}")
|
49 |
+
if result["impact_point"]:
|
50 |
+
st.info(f"π― Impact point: {result['impact_point']}")
|