ariG23498 HF Staff commited on
Commit
026fdb5
·
verified ·
1 Parent(s): dac054c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -22,12 +22,14 @@ labels = list(id2label.values())
22
  def classify_video(video_path):
23
  # Decode and sample frames
24
  decoder = VideoDecoder(video_path)
25
- clip = clips_at_random_indices(
26
- decoder,
27
- num_clips=1,
28
- num_frames_per_clip=model.config.frames_per_clip,
29
- num_indices_between_frames=3,
30
- ).data
 
 
31
 
32
  # Preprocess & move to the same device as the model
33
  crop = v2.CenterCrop((processor.crop_size["height"], processor.crop_size["width"]))
 
22
  def classify_video(video_path):
23
  # Decode and sample frames
24
  decoder = VideoDecoder(video_path)
25
+ frame_idx = np.arange(0, model.config.frames_per_clip, 2) # you can define more complex sampling strategy
26
+ clip = vr.get_frames_at(indices=frame_idx).data
27
+ # clip = clips_at_random_indices(
28
+ # decoder,
29
+ # num_clips=1,
30
+ # num_frames_per_clip=model.config.frames_per_clip,
31
+ # num_indices_between_frames=3,
32
+ # ).data
33
 
34
  # Preprocess & move to the same device as the model
35
  crop = v2.CenterCrop((processor.crop_size["height"], processor.crop_size["width"]))