DSatishchandra commited on
Commit
e21f2de
·
verified ·
1 Parent(s): 477d455

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -9,8 +9,13 @@ model.eval()
9
 
10
  classes = ["Not LBW", "LBW"]
11
 
12
- def predict(video):
13
- frames = extract_frames(video)
 
 
 
 
 
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(type="filepath"),
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."