-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Add improved handling of pil #1309
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| "accelerate>=0.11.0", | ||||||
| "black==22.8", | ||||||
| "datasets", | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import PIL.Image | ||
| import PIL.ImageOps | ||
| from packaging import version | ||
|
|
||
|
|
||
| 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, | ||
| } | ||
|
Comment on lines
+6
to
+21
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense!
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 E.g. If I do: class PIL_INTERPOLATION(Enum):
LINEAR = PIL.Image.Resampling.BILINEARThen 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wdyt @pcuenca ?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, that's weird, I thought it would work without |
||
There was a problem hiding this comment.
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 :)