Skip to content

fix: load_image should support PIL Image #6904

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

Merged
merged 2 commits into from
Feb 8, 2024
Merged

Conversation

Laisky
Copy link
Contributor

@Laisky Laisky commented Feb 8, 2024

What does this PR do?

load_image should support PIL.Image.

Fixes #6479 (comment)

Before submitting

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.

@Laisky Laisky mentioned this pull request Feb 8, 2024
6 tasks
Comment on lines +35 to +36
elif isinstance(image, PIL.Image.Image):
image = image
Copy link
Member

Choose a reason for hiding this comment

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

Wonder why would someone call load_image() on an already properly loaded image, though.

Copy link
Contributor Author

@Laisky Laisky Feb 8, 2024

Choose a reason for hiding this comment

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

Many tutorials are written like this😁, Perhaps to ensure things like RGB, or to ensure the consistency of types

@sayakpaul
Copy link
Member

Hmm as per the method signature, it seems like load_image() should support a PIL image but the code below currently doesn't work:

from diffusers.utils import load_image 

image = load_image(image)

where image is a PIL image. I'd be in favor of this. @yiyixuxu WDYT?

@yiyixuxu
Copy link
Collaborator

yiyixuxu commented Feb 8, 2024

@sayakpaul
yes we should add it back
I think this is in the original implementation anyway

@sayakpaul
Copy link
Member

Alright. Feel free to merge once the CI is green.

@HuggingFaceDocBuilderDev

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.

@yiyixuxu yiyixuxu merged commit 1824d00 into huggingface:main Feb 8, 2024
AmericanPresidentJimmyCarter pushed a commit to AmericanPresidentJimmyCarter/diffusers that referenced this pull request Apr 26, 2024
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
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.

4 participants