diffusers
diffusers copied to clipboard
Fix bug #784 Warnings related to PIL.Image samplers warnings
This fixes PIL.Image Resampler warnings, fixing bug https://github.com/huggingface/diffusers/issues/784
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint.
@Thomas-MMJ so these enums were added in version 9.1.0 and thus were potentially deemed too new to add as many places have older versions of PIL installed... you would also need to add the >= 9.1.0 requirements too in the PR
also see #588
Indeed, let's keep this open until future PIL releases.
What we usually do here is to do version dependent imports. Could we do the same here @Thomas-MMJ. E.g. could you add the following logic:
import PIL
if version.parse(version.parse(PIL.__version__).base_version) >= version.parse("9.1.0"):
self.interpolation = {
"linear": PIL.Image.Resampling.LINEAR,
"bilinear": PIL.Image.Resampling.BILINEAR,
"bicubic": PIL.Image.Resampling.BICUBIC,
"lanczos": PIL.Image.Resampling.LANCZOS,
}
else:
self.interpolation = {
"linear": PIL.Image.LINEAR,
"bilinear": PIL.Image.BILINEAR,
"bicubic": PIL.Image.BICUBIC,
"lanczos": PIL.Image.LANCZOS,
}
and could you use the same approach to all the other occurrences? This way we are safe for both PIL versions smaller than 9.1.0 and higher than 9.1.0.
@patrickvonplaten @Thomas-MMJ
when PIllow version >= 9.1.0 PIL.Image.Resampling donnot have LINEAR attr

PIL.Image.LINEAR == PIL.Image.BILINEAR == PIL.Image.Resampling.BILINEAR

you can try:
if version.parse(version.parse(PIL.__version__).base_version) >= version.parse("9.1.0"):
self.interpolation = {
"linear": PIL.Image.Resampling.BILINEAR,
"bilinear": PIL.Image.Resampling.BILINEAR,
"bicubic": PIL.Image.Resampling.BICUBIC,
"lanczos": PIL.Image.Resampling.LANCZOS,
}
else:
self.interpolation = {
"linear": PIL.Image.LINEAR,
"bilinear": PIL.Image.BILINEAR,
"bicubic": PIL.Image.BICUBIC,
"lanczos": PIL.Image.LANCZOS,
}
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.
Please note that issues that do not follow the contributing guidelines are likely to be ignored.
Think this is handled now by https://github.com/huggingface/diffusers/pull/1309 :-)