diffusers icon indicating copy to clipboard operation
diffusers copied to clipboard

Fix bug #784 Warnings related to PIL.Image samplers warnings

Open Thomas-MMJ opened this issue 3 years ago • 5 comments

This fixes PIL.Image Resampler warnings, fixing bug https://github.com/huggingface/diffusers/issues/784

Thomas-MMJ avatar Oct 09 '22 21:10 Thomas-MMJ

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

kashif avatar Oct 10 '22 08:10 kashif

also see #588

kashif avatar Oct 10 '22 08:10 kashif

Indeed, let's keep this open until future PIL releases.

anton-l avatar Oct 10 '22 10:10 anton-l

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 avatar Oct 10 '22 13:10 patrickvonplaten

@patrickvonplaten @Thomas-MMJ

when PIllow version >= 9.1.0 PIL.Image.Resampling donnot have LINEAR attr image

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

JunnYu avatar Oct 13 '22 03:10 JunnYu

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,
    }

kashif avatar Oct 13 '22 07:10 kashif

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.

github-actions[bot] avatar Nov 09 '22 15:11 github-actions[bot]

Think this is handled now by https://github.com/huggingface/diffusers/pull/1309 :-)

patrickvonplaten avatar Nov 16 '22 17:11 patrickvonplaten