[Bugfix] Missing thumbnail from NVLM-D processor #14633
Open
+1
−1
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.
If num_patches evaluate to 1 for the input image prompt, the existing code does not generate any image token leading to the error "Unable to allocate 256 multimodal tokens to 0 placeholders". For images of particular dimensions eg. 220x229 or 200x229, I received this error.
The code currently breaks the input image prompt into multiple images by cropping certain parts of the image. It then appends all these cropped images plus a thumbnail image which is the resized version of the original image into a list. The number of elements in this list is dependent on the num_patches variable which is calculated based on the size of the original image.
If the num_patches variable is 1, then the code currently does not crop the image and also doesn't add the thumbnail image, therefore adding 0 image placeholders. Therefore, to consider the thumbnail image, which is the original image when num_patches==1 we need to remove the condition num_patches != 1.
To reproduce the bug you can try giving a prompt with this image (https://github.com/user-attachments/assets/7cd2df26-c765-43d8-bab2-9783d33c792f).