Skip to content

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 :)

# 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.


## 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.

5 participants