-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Fix temporal padding in Qwen2VLImageProcessor when the number of frames is not divisible by temporal_patch_size #38076
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix temporal padding in Qwen2VLImageProcessor when the number of frames is not divisible by temporal_patch_size #38076
Conversation
|
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the |
|
@zucchini-nlp Could you please review this PR? |
…e not divisible by temporal_patch_size
f876f69 to
9bd3e16
Compare
zucchini-nlp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
|
|
||
| # Check the shape after padding | ||
| expected_output_video_shape = (102900, 1176) # Adjusted based on padding | ||
| self.assertEqual(tuple(encoded_video.shape), expected_output_video_shape) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ultra nit: asserting ListEqual can give more informative error output when tests fail :)
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
…es is not divisible by temporal_patch_size (huggingface#38076) Qwen2VL: Fix temporal padding in Qwen2VLImageProcessor when frames are not divisible by temporal_patch_size
|
qwen3vl_video_processor has same problem....
|
|
@yaogang2060 can you submit a PR and tag me pls? |
This PR fixes an issue in Qwen2VLImageProcessor where the current implementation does not correctly handle cases when the number of video frames is not divisible by
temporal_patch_size.Problem:
The existing logic repeats the last frame
temporal_patch_size- 1 times. This works correctly whentemporal_patch_sizeequals 2 but fails when the size is greater.Solution:
The fix replaces:
repeats = np.repeat(patches[-1][np.newaxis], temporal_patch_size - 1, axis=0)with:
repeats = np.repeat(patches[-1][np.newaxis], temporal_patch_size - (patches.shape[0] % temporal_patch_size), axis=0)This ensures that the correct number of padding frames are added when the frame count is not divisible by the
temporal_patch_size.Additional Changes:
Added a unit test to verify the padding logic for edge cases where the number of frames is not divisible by the patch size.
Issue Reference:
Fixes #38003