Fix: img size mismatch caused by incorrect unpadding in LLaVA-Next#34522
Merged
LysandreJik merged 1 commit intohuggingface:mainfrom Oct 31, 2024
Merged
Fix: img size mismatch caused by incorrect unpadding in LLaVA-Next#34522LysandreJik merged 1 commit intohuggingface:mainfrom
LysandreJik merged 1 commit intohuggingface:mainfrom
Conversation
zucchini-nlp
approved these changes
Oct 31, 2024
Member
zucchini-nlp
left a comment
There was a problem hiding this comment.
Thanks!
Makes sense since we use the math.ceil op when padding. Let's use math.ceil for unpadding also to make sure the calculations are done identically
For core maintainers: I don't think this needs a test as it is not something that can be broken again. We have had some issues before with unpadding (that is why image_sizes are cast to list) but still some numerical precision errors seem to be left
|
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. |
Member
|
Pinging actual core maintainer @LysandreJik! |
BernardZach
pushed a commit
to BernardZach/transformers
that referenced
this pull request
Dec 5, 2024
…uggingface#34522) Fix: unpadding img mismatch
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
When calculating
new_heightandnew_width, applyingint()to values like 59.999999 (which should be treated as 60) results in 59. This leads to incorrect unpadding and consequently causes the img_size mismatch error.Fixed the issue by adding round to
int(original_width * scale_factor)likeint(round(original_width * scale_factor, 7)).It works fine in my environment for now, but I think we should look into this more carefully.
What do you all think?
bug reproduction code
This code requires the issue #34447 to be resolved first before running.
Therefore, it is recommended to resolve this issue by installing the following code before execution:
pip install git+https://github.com/jp1924/transformers.git@Fix--Llava_img_mismatchenv
transformersversion: 4.47.0.dev0Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@zucchini-nlp