Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -161,9 +161,11 @@ def create_pitch_map(pitch_x, pitch_y):
|
|
| 161 |
|
| 162 |
# Main Gradio function
|
| 163 |
def drs_analysis(video):
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
|
|
|
|
|
|
| 167 |
|
| 168 |
positions, frame_numbers, bounce_point, frame_rate, frame_width, frame_height = process_video(video_path)
|
| 169 |
if not positions:
|
|
@@ -182,7 +184,8 @@ def drs_analysis(video):
|
|
| 182 |
|
| 183 |
fig_pitch = create_pitch_map(pitch_x, pitch_y)
|
| 184 |
|
| 185 |
-
|
|
|
|
| 186 |
|
| 187 |
return fig_traj, fig_pitch, f"LBW Decision: {lbw_decision}\nSpeed: {speed_kmh:.2f} km/h", video_path
|
| 188 |
|
|
|
|
| 161 |
|
| 162 |
# Main Gradio function
|
| 163 |
def drs_analysis(video):
|
| 164 |
+
# Video is a file path (string) in Hugging Face Spaces
|
| 165 |
+
video_path = video if isinstance(video, str) else "temp_video.mp4"
|
| 166 |
+
if not isinstance(video, str):
|
| 167 |
+
with open(video_path, "wb") as f:
|
| 168 |
+
f.write(video.read())
|
| 169 |
|
| 170 |
positions, frame_numbers, bounce_point, frame_rate, frame_width, frame_height = process_video(video_path)
|
| 171 |
if not positions:
|
|
|
|
| 184 |
|
| 185 |
fig_pitch = create_pitch_map(pitch_x, pitch_y)
|
| 186 |
|
| 187 |
+
if not isinstance(video, str):
|
| 188 |
+
os.remove(video_path)
|
| 189 |
|
| 190 |
return fig_traj, fig_pitch, f"LBW Decision: {lbw_decision}\nSpeed: {speed_kmh:.2f} km/h", video_path
|
| 191 |
|