Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class Qwen2_5OmniProcessorKwargs(ProcessingKwargs, total=False):
"seconds_per_chunk": 2.0,
"position_id_per_seconds": 25,
"use_audio_in_video": False,
"min_pixels": 128 * 28 * 28,
"max_pixels": 768 * 28 * 28,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, also noticed but didn't want to enforce as it's dynamic in their repo, depending on video length. I agree this is better than nothing and a longer term solution would be to add it in self.video_processor

},
"audio_kwargs": {
"sampling_rate": 16000,
Expand Down Expand Up @@ -147,7 +149,7 @@ def __call__(
seconds_per_chunk = output_kwargs["videos_kwargs"].pop("seconds_per_chunk")
position_id_per_seconds = output_kwargs["videos_kwargs"].pop("position_id_per_seconds")
use_audio_in_video = output_kwargs["videos_kwargs"].pop("use_audio_in_video")
fps = output_kwargs["videos_kwargs"].pop("fps", None)
fps = output_kwargs["videos_kwargs"].pop("fps", 2.0)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, then we can put it in video_kwargs.defaults. Missed this one

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but when I tested I think it was not being properly forwarded to all the places where it's needed. I'll take a quick look, otherwise we can merge this and handle the fps in another PR.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that consistently using the video fps provided by the user, or defaulting to the value in video_kwargs.defaults, merits some additional discussion, I'll open a new PR. We can merge this one meanwhile!

@zucchini-nlp zucchini-nlp Apr 23, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to #37687 as well, users should be able to overwrite the value indeed. And the naming diverged without us noticing 😢


if audio is not None:
output_kwargs["audio_kwargs"]["padding"] = "max_length" # Support "max_length" padding only here
Expand All @@ -174,8 +176,7 @@ def __call__(
if videos is not None:
videos = make_batched_videos(videos)
videos_inputs = self.image_processor(images=None, videos=videos, **output_kwargs["videos_kwargs"])
if fps is None:
fps = [2.0] * len(videos)
fps = [fps] * len(videos)

@pcuenca pcuenca Apr 21, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is technically unrelated, but I don't think the input kwarg is expected as a list in this method.

videos_inputs["video_second_per_grid"] = [
self.image_processor.temporal_patch_size / fps[i] for i in range(len(fps))
]
Expand Down
8 changes: 4 additions & 4 deletions tests/models/qwen2_5_omni/test_processor_qwen2_5_omni.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def test_apply_chat_template_video_frame_sampling(self):
num_frames=num_frames,
)
self.assertTrue(self.videos_input_name in out_dict_with_video)
self.assertEqual(len(out_dict_with_video[self.videos_input_name]), 9568)
self.assertEqual(len(out_dict_with_video[self.videos_input_name]), 5760)

# Load with `video_fps` arg
video_fps = 1
Expand All @@ -445,7 +445,7 @@ def test_apply_chat_template_video_frame_sampling(self):
video_fps=video_fps,
)
self.assertTrue(self.videos_input_name in out_dict_with_video)
self.assertEqual(len(out_dict_with_video[self.videos_input_name]), 23920)
self.assertEqual(len(out_dict_with_video[self.videos_input_name]), 14400)

# Load with `video_fps` and `num_frames` args, should raise an error
with self.assertRaises(ValueError):
Expand All @@ -466,7 +466,7 @@ def test_apply_chat_template_video_frame_sampling(self):
return_dict=True,
)
self.assertTrue(self.videos_input_name in out_dict_with_video)
self.assertEqual(len(out_dict_with_video[self.videos_input_name]), 717600)
self.assertEqual(len(out_dict_with_video[self.videos_input_name]), 432000)

# Load video as a list of frames (i.e. images). NOTE: each frame should have same size
# because we assume they come from one video
Expand All @@ -484,7 +484,7 @@ def test_apply_chat_template_video_frame_sampling(self):
return_dict=True,
)
self.assertTrue(self.videos_input_name in out_dict_with_video)
self.assertEqual(len(out_dict_with_video[self.videos_input_name]), 5704)
self.assertEqual(len(out_dict_with_video[self.videos_input_name]), 2904)

@require_av
def test_apply_chat_template_video_special_processing(self):
Expand Down