Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Update CLIPFeatureExtractor to convert PIL image to RGB #17101

Merged

Conversation

hengkuanwee
Copy link
Contributor

Currently PIL images with RGBA format throws an error when being processed by CLIPFeatureExtractor.

CLIPFeatureExtractor.normalize() throws the following error:
.../sentence-transformer/lib/python3.9/site-packages/transformers/image_utils.py", line 185, in normalize return (image - mean) / std ValueError: operands could not be broadcast together with shapes (4,224,224) (3,)

The original clip model preprocesses PIL Images by converting all PIL images into RGB format.

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented May 5, 2022

The documentation is not available anymore as the PR was closed or merged.

@hengkuanwee
Copy link
Contributor Author

hi @patil-suraj, re-created the PR as discussed 😄

Copy link
Contributor

@patil-suraj patil-suraj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks a lot for the PR!

@patil-suraj patil-suraj merged commit 6bc6797 into huggingface:main May 11, 2022
Narsil pushed a commit to Narsil/transformers that referenced this pull request May 12, 2022
Co-authored-by: kuanwee.heng <kuanwee.heng@aaqua.live>
ArthurZucker pushed a commit to ArthurZucker/transformers that referenced this pull request May 12, 2022
Co-authored-by: kuanwee.heng <kuanwee.heng@aaqua.live>
elusenji pushed a commit to elusenji/transformers that referenced this pull request Jun 12, 2022
Co-authored-by: kuanwee.heng <kuanwee.heng@aaqua.live>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants