Fix: PIL image load in Processing utils apply_chat_template#40622
Fix: PIL image load in Processing utils apply_chat_template#40622zucchini-nlp merged 1 commit intohuggingface:mainfrom
Conversation
zucchini-nlp
left a comment
There was a problem hiding this comment.
It will not work unfortunately, because each image can be either an empty list or an ImageInput. We will never get any None inputs at this point
The idea is to not pass images if it is an empty list of empty lists. If it has at least one ImageInput, then we pass it further
|
@zucchini-nlp Thanks for reply. In [5]: batch_images = [[], [], ["test.png"]]
...: any((im is not None) for im_list in batch_images for im in im_list)
Out[5]: True
In [6]: batch_images = [[], [], [Image.new("RGB", (100, 100), (0, 0, 0))]]
...: any((im is not None) for im_list in batch_images for im in im_list)
Out[6]: True
In [7]: batch_images = [[], [], ["http://test.com"]]
...: any((im is not None) for im_list in batch_images for im in im_list)
Out[7]: True
In [8]: batch_images = [[], [], []]
...: any((im is not None) for im_list in batch_images for im in im_list)
Out[8]: False |
|
Oh yeah, my bad, didn't notice we are iterating per single image and not batched sublist. |
zucchini-nlp
left a comment
There was a problem hiding this comment.
Will merge when CI turns green, it has been a bit flaky lately
|
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. |
What does this PR do?
This PR #36682 introduced the batch size for images, everything is working correctly but the check for image existence don't support the PPIL images. The
len()function could work with path or other things. So I converted it to checkis not Noneit works for both PIL images and paths or URLsNote: I made the same fix for videos also
Fixes #40603
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
@zucchini-nlp