AjaykumarPilla commited on
Commit
6394329
·
verified ·
1 Parent(s): 4bea7c9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -47
app.py CHANGED
@@ -1,51 +1,22 @@
1
  import streamlit as st
2
- import os
3
- import logging
4
- from gully_drs_core.ball_detection import process_video
5
 
6
- # Set up logging
7
- logging.basicConfig(level=logging.INFO)
8
- logger = logging.getLogger(__name__)
9
 
10
- # Streamlit configuration
11
- st.set_page_config(page_title="GullyDRS", layout="wide")
12
- st.title("GullyDRS - AI-Powered Decision Review System")
 
 
13
 
14
- # Directories for uploads and outputs
15
- UPLOAD_DIR = "uploads"
16
- OUTPUT_DIR = "outputs"
17
- os.makedirs(UPLOAD_DIR, exist_ok=True)
18
- os.makedirs(OUTPUT_DIR, exist_ok=True)
19
-
20
- def main():
21
- st.header("Upload Match Video for DRS Analysis")
22
- uploaded_file = st.file_uploader("Choose a video file (MP4, AVI)", type=["mp4", "avi"])
23
-
24
- if uploaded_file is not None:
25
- try:
26
- # Save uploaded video
27
- video_path = os.path.join(UPLOAD_DIR, uploaded_file.name)
28
- with open(video_path, "wb") as f:
29
- f.write(uploaded_file.getbuffer())
30
- st.success(f"Video '{uploaded_file.name}' uploaded successfully!")
31
-
32
- # Process video
33
- with st.spinner("Processing video for DRS analysis..."):
34
- result = process_video(video_path)
35
- if result["status"] == "success":
36
- # Display replay video (live preview)
37
- st.subheader("Replay Video")
38
- st.video(result["replay_path"])
39
- st.write(f"**LBW Decision**: {result['decision']}")
40
- st.write(f"**Ball Speed**: {result['speed_kmh']:.2f} km/h")
41
- # External test frame (local file access for testing)
42
- st.subheader("External Replay (Test Frame)")
43
- st.markdown(f'<video width="640" height="360" controls><source src="file://{result["replay_path"]}" type="video/mp4"></video>', unsafe_allow_html=True)
44
- else:
45
- st.error(f"Error: {result['error']}")
46
- except Exception as e:
47
- logger.error(f"Error processing video: {str(e)}")
48
- st.error(f"Failed to process video: {str(e)}")
49
-
50
- if __name__ == "__main__":
51
- main()
 
1
  import streamlit as st
2
+ import tempfile
3
+ from gully_drs_core import ball_detection, replay_utils
 
4
 
5
+ st.title("🏏 GullyDRS LBW Review System")
 
 
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
+ if st.button("Analyze Video"):
14
+ with st.spinner("Processing..."):
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
+ st.success("Replay generated!")
22
+ st.video(replay_path)