AjaykumarPilla commited on
Commit
016496d
Β·
verified Β·
1 Parent(s): 8f2145c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -21
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
- 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"],
@@ -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
- # 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']}")
 
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.")