Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,34 +1,35 @@
|
|
1 |
import streamlit as st
|
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 |
-
|
11 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
replay_path = replay_utils.generate_replay(
|
33 |
frames=result["frames"],
|
34 |
ball_path=result["trajectory"],
|
@@ -36,15 +37,12 @@ if video_file:
|
|
36 |
impact_point=result["impact_point"],
|
37 |
decision=result["decision"],
|
38 |
stump_zone=result["stump_zone"],
|
|
|
39 |
fps=result["fps"]
|
40 |
)
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
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']}")
|
|
|
1 |
import streamlit as st
|
2 |
import tempfile
|
3 |
+
import os
|
4 |
from gully_drs_core import ball_detection, replay_utils
|
5 |
|
6 |
st.set_page_config(page_title="GullyDRS β LBW Review", layout="centered")
|
7 |
st.title("π GullyDRS β LBW Decision Review System")
|
8 |
|
9 |
+
st.markdown("""
|
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 |
video_file = st.file_uploader("π₯ Upload your match video", type=["mp4", "avi"])
|
15 |
|
16 |
if video_file:
|
|
|
17 |
tfile = tempfile.NamedTemporaryFile(delete=False)
|
18 |
tfile.write(video_file.read())
|
|
|
|
|
19 |
st.video(video_file)
|
20 |
|
|
|
21 |
if st.button("π§ Analyze Video"):
|
22 |
with st.spinner("Analyzing with AI..."):
|
23 |
result = ball_detection.analyze_video(tfile.name)
|
24 |
|
25 |
+
st.write(f"π Trajectory points: {len(result['trajectory'])}")
|
26 |
+
st.write(f"π Final Decision: **{result['decision']}**")
|
27 |
+
st.write(f"π Ball Speed: **{result['speed_kmh']} km/h**")
|
28 |
+
if result["bounce_point"]:
|
29 |
+
st.info(f"π Bounce detected at: {result['bounce_point']}")
|
30 |
+
if result["impact_point"]:
|
31 |
+
st.info(f"π― Impact point: {result['impact_point']}")
|
32 |
+
|
33 |
replay_path = replay_utils.generate_replay(
|
34 |
frames=result["frames"],
|
35 |
ball_path=result["trajectory"],
|
|
|
37 |
impact_point=result["impact_point"],
|
38 |
decision=result["decision"],
|
39 |
stump_zone=result["stump_zone"],
|
40 |
+
speed_kmh=result["speed_kmh"],
|
41 |
fps=result["fps"]
|
42 |
)
|
43 |
|
44 |
+
if replay_path and os.path.exists(replay_path):
|
45 |
+
st.success("β
Replay generated successfully!")
|
46 |
+
st.video(replay_path)
|
47 |
+
else:
|
48 |
+
st.error("β οΈ Replay generation failed or produced no video.")
|
|
|
|
|
|
|
|