Skip to content

Commit

Permalink
ADLR/megatron-lm!2587 - Add safeguard to fail if video is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthieu Le authored and jaredcasper committed Jan 28, 2025
1 parent 2167226 commit 0689058
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions examples/multimodal/dataset_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,8 @@ def encode_llava_sft(self, sample: SimilarityInterleavedSample):
# Grab the selected frames of the video as a tensor with shape
# fhwc: (num_frames, num_channels, height, width).
video_fchw = sample.images.frames
if video_fchw.shape[0] == 0:
raise ValueError(f"Video {sample.__key__} {sample.__restore_key__} {sample.texts} has no frames.")
selected_frames = torch.linspace(
0, video_fchw.shape[0] - 1, self.args.num_frames).long()
video_fchw = video_fchw[selected_frames]
Expand Down
2 changes: 1 addition & 1 deletion examples/multimodal/run_text_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ def get_conversation(task, question):

conversation = [
{"role": "system", "content": "Answer the questions."},
{"role": "user", "content": f"{IMAGE_TOKEN}\n{question}"},
{"role": "user", "content": f"{IMAGE_TOKEN}\n{q}"},
]

return conversation
Expand Down

0 comments on commit 0689058

Please sign in to comment.