Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,8 +9,13 @@ model.eval()
|
|
| 9 |
|
| 10 |
classes = ["Not LBW", "LBW"]
|
| 11 |
|
| 12 |
-
def predict(
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
with torch.no_grad():
|
| 15 |
output = model(frames)
|
| 16 |
pred = torch.argmax(output, dim=1).item()
|
|
@@ -19,7 +24,7 @@ def predict(video):
|
|
| 19 |
|
| 20 |
iface = gr.Interface(
|
| 21 |
fn=predict,
|
| 22 |
-
inputs=gr.Video(
|
| 23 |
outputs=gr.Text(),
|
| 24 |
title="Smart LBW Classifier",
|
| 25 |
description="Upload a cricket video. The AI model will predict whether it's an LBW or not."
|
|
|
|
| 9 |
|
| 10 |
classes = ["Not LBW", "LBW"]
|
| 11 |
|
| 12 |
+
def predict(video_file):
|
| 13 |
+
if isinstance(video_file, dict) and "name" in video_file:
|
| 14 |
+
video_path = video_file["name"]
|
| 15 |
+
else:
|
| 16 |
+
video_path = video_file # fallback for older Gradio behavior
|
| 17 |
+
|
| 18 |
+
frames = extract_frames(video_path)
|
| 19 |
with torch.no_grad():
|
| 20 |
output = model(frames)
|
| 21 |
pred = torch.argmax(output, dim=1).item()
|
|
|
|
| 24 |
|
| 25 |
iface = gr.Interface(
|
| 26 |
fn=predict,
|
| 27 |
+
inputs=gr.Video(), # No 'type' param in Gradio v4+
|
| 28 |
outputs=gr.Text(),
|
| 29 |
title="Smart LBW Classifier",
|
| 30 |
description="Upload a cricket video. The AI model will predict whether it's an LBW or not."
|