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

Add improved handling of pil #1309

Merged
merged 3 commits into from Nov 16, 2022
Merged

Conversation

patrickvonplaten
Copy link
Contributor

@patrickvonplaten patrickvonplaten commented Nov 16, 2022

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint.

Copy link
Member

@pcuenca pcuenca left a comment

Choose a reason for hiding this comment

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

There are a few changes about latent diffusion that are not related to PIL as far as I can tell, but I'm ok with that :)

@@ -78,7 +78,7 @@
# 1. all dependencies should be listed here with their version requirements if any
# 2. once modified, run: `make deps_table_update` to update src/diffusers/dependency_versions_table.py
_deps = [
"Pillow<10.0", # keep the PIL.Image.Resampling deprecation away
"Pillow", # keep the PIL.Image.Resampling deprecation away
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"Pillow", # keep the PIL.Image.Resampling deprecation away
"Pillow",

Comment on lines +6 to +21
if version.parse(version.parse(PIL.__version__).base_version) >= version.parse("9.1.0"):
PIL_INTERPOLATION = {
"linear": PIL.Image.Resampling.BILINEAR,
"bilinear": PIL.Image.Resampling.BILINEAR,
"bicubic": PIL.Image.Resampling.BICUBIC,
"lanczos": PIL.Image.Resampling.LANCZOS,
"nearest": PIL.Image.Resampling.NEAREST,
}
else:
PIL_INTERPOLATION = {
"linear": PIL.Image.LINEAR,
"bilinear": PIL.Image.BILINEAR,
"bicubic": PIL.Image.BICUBIC,
"lanczos": PIL.Image.LANCZOS,
"nearest": PIL.Image.NEAREST,
}
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer these to be symbols to prevent mistakes and allow autocompletion. Can we use Enums maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, no this will lead to a weird API then because they are functions that are not used to compare anything. I don't want to add if ... comparisons everywhere in the code. Think it's actually fine as is.

E.g. If I do:

class PIL_INTERPOLATION(Enum): 
    LINEAR = PIL.Image.Resampling.BILINEAR

Then one cannot call the function with PIL_INTERPOLATION.LINEAR only with PIL_INTERPOLATION.LINEAR.value which is weird. Actually keen to leave as is here -> we have the same logic in transformers for the activation functions: https://github.com/huggingface/transformers/blob/4fb34de99e800689862f80cd618e6468fcb7b28b/src/transformers/activations.py#L152

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wdyt @pcuenca ?

Copy link
Member

Choose a reason for hiding this comment

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

Oh, that's weird, I thought it would work without .value. That's too bad, let's keep them as strings then.

@@ -39,9 +39,9 @@ The original codebase can be found [here](https://github.com/CompVis/latent-diff


## LDMTextToImagePipeline
[[autodoc]] pipelines.latent_diffusion.pipeline_latent_diffusion.LDMTextToImagePipeline
[[autodoc]] LDMTextToImagePipeline
Copy link
Member

Choose a reason for hiding this comment

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

This is not related to this PR is it? Fine for me either way :)

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.

Looks good!

@patil-suraj
Copy link
Contributor

(Note, the Co-authored-by: should go in the PR commit description when merging the PR)

@patrickvonplaten
Copy link
Contributor Author

(Note, the Co-authored-by: should go in the PR commit description when merging the PR)

Can't find the email addresses now so just an in-official co-authoring 😅 But think that's ok given that none of the PRs were finished

@patrickvonplaten patrickvonplaten merged commit 65d136e into main Nov 16, 2022
@patrickvonplaten patrickvonplaten deleted the add_improved_handling_of_pil branch November 16, 2022 14:58
yoonseokjin pushed a commit to yoonseokjin/diffusers that referenced this pull request Dec 25, 2023
* Better error message for transformers dummy

* [PIL] Better deprecation functionality

* up
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.

None yet

4 participants