Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Support grayscale images in numpy_to_pil #1025

Merged
merged 1 commit into from
Oct 27, 2022
Merged

Support grayscale images in numpy_to_pil #1025

merged 1 commit into from
Oct 27, 2022

Conversation

anton-l
Copy link
Member

@anton-l anton-l commented Oct 27, 2022

This fixes the error when trying to convert single-channel arrays to PIL

images = np.random.rand(2, 32, 32, 1)
numpy_to_pil(images)  

Before:

TypeError: Cannot handle this data type: (1, 1, 1), |u1

After:

[<PIL.Image.Image image mode=L size=32x32 at 0x7FCF8F8FE690>,
<PIL.Image.Image image mode=L size=32x32 at 0x7FCF8F8FE6D0>]

Closes #488

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Oct 27, 2022

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

@pcuenca
Copy link
Member

pcuenca commented Oct 27, 2022

Does this ever come up during regular pipeline use?

@anton-l
Copy link
Member Author

anton-l commented Oct 27, 2022

@pcuenca not in our usual cases, but was brought up in #488

@pcuenca
Copy link
Member

pcuenca commented Oct 27, 2022

Oh, it makes total sense for training, of course.

@anton-l anton-l merged commit fb38bb1 into main Oct 27, 2022
@anton-l anton-l deleted the greyscale-np-pil branch October 27, 2022 20:44
yoonseokjin pushed a commit to yoonseokjin/diffusers that referenced this pull request Dec 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Diffusion Pipeline numpy_to_pil fails for grayscale/single channel images
3 participants