minhdang commited on
Commit
3f9c93c
1 Parent(s): 765a078

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -0
app.py CHANGED
@@ -108,7 +108,20 @@ def inference_video(video):
108
  prediction = F.softmax(prediction, dim=1).flatten()
109
 
110
  return {kinetics_id_to_classname[str(i)]: float(prediction[i]) for i in range(400)}
 
 
 
 
 
 
 
 
111
 
 
 
 
 
 
112
 
113
  @spaces.GPU
114
  def inference_image(img):
 
108
  prediction = F.softmax(prediction, dim=1).flatten()
109
 
110
  return {kinetics_id_to_classname[str(i)]: float(prediction[i]) for i in range(400)}
111
+ @spaces.GPU
112
+ def ultra_inference_video(vid):
113
+ os.system('nvidia-smi')
114
+ # vid = load_video(video)
115
+
116
+ # The model expects inputs of shape: B x C x H x W
117
+ TC, H, W = vid.shape
118
+ inputs = vid.reshape(1, TC//3, 3, H, W).permute(0, 2, 1, 3, 4)
119
 
120
+ with torch.no_grad():
121
+ prediction = model_video(inputs.to(device))
122
+ prediction = F.softmax(prediction, dim=1).flatten()
123
+
124
+ return {kinetics_id_to_classname[str(i)]: float(prediction[i]) for i in range(400)}
125
 
126
  @spaces.GPU
127
  def inference_image(img):