Skip to content

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

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

Closed
wants to merge 1 commit into from
Closed

Conversation

Thomas-MMJ
Copy link

@Thomas-MMJ Thomas-MMJ commented Oct 9, 2022

This fixes PIL.Image Resampler warnings, fixing bug #784

@HuggingFaceDocBuilderDev

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

@Thomas-MMJ Thomas-MMJ changed the title This fixes warnings related to PIL.Image, fixing warnings in the bug report https://github.com/huggingface/diffusers/issues/784 Fix bug https://github.com/huggingface/diffusers/issues/784 Warnings related to PIL.Image samplers Oct 9, 2022
@Thomas-MMJ Thomas-MMJ changed the title Fix bug https://github.com/huggingface/diffusers/issues/784 Warnings related to PIL.Image samplers Fix bug #784 Warnings related to PIL.Image samplers Oct 9, 2022
@Thomas-MMJ Thomas-MMJ changed the title Fix bug #784 Warnings related to PIL.Image samplers Fix bug #784 Warnings related to PIL.Image samplers warnings Oct 9, 2022
@kashif
Copy link
Contributor

kashif commented Oct 10, 2022

@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
Copy link
Contributor

kashif commented Oct 10, 2022

also see #588

@anton-l
Copy link
Member

anton-l commented Oct 10, 2022

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

@patrickvonplaten
Copy link
Contributor

patrickvonplaten commented Oct 10, 2022

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.

@JunnYu
Copy link

JunnYu commented Oct 13, 2022

@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

@kashif
Copy link
Contributor

kashif commented Oct 13, 2022

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

@github-actions
Copy link
Contributor

github-actions bot commented Nov 9, 2022

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 github-actions bot added the stale Issues that haven't received updates label Nov 9, 2022
@patrickvonplaten
Copy link
Contributor

Think this is handled now by #1309 :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Issues that haven't received updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants