Skip to content

Commit 0aaff1d

Browse files
authored
Merge pull request #789 from EvolvingLMMs-Lab/fix/frames
fix(qwen2_5_vl): Ensure unique frame indices for videos with few frames
2 parents c480217 + 87979cc commit 0aaff1d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lmms_eval/models/simple/qwen2_5_vl.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,12 @@ def _collate(x):
287287
if video_inputs is not None:
288288
total_frames = video_inputs[0].shape[0]
289289
indices = np.linspace(0, total_frames - 1, self.max_num_frames, dtype=int)
290+
# Ensure unique indices if linspace produces duplicates for few frames
291+
indices = np.unique(indices)
290292
# Append the last frame index if not already included
291293
if total_frames - 1 not in indices:
292294
indices = np.append(indices, total_frames - 1)
295+
indices = np.unique(indices) # Ensure uniqueness again
293296
video_inputs[0] = video_inputs[0][indices]
294297
inputs = self.processor(text=texts, images=image_inputs, videos=video_inputs, padding=True, return_tensors="pt")
295298

0 commit comments

Comments
 (0)