Fix: img size mismatch caused by incorrect unpadding in LLaVA-Next #34522
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