Skip to content

DeprecationWarning from Pillow (with Pillow ≥ 9.1.0) #19569

@tasercake

Description

@tasercake

System Info

transformers: 4.22.2
pillow: 9.2.0
Python 3.9.9

Who can help?

@NielsRogge @amyeroberts (tagged based on changes to image_utils.py in #18520, but the issue seems to span most of the repo)

Reproduction

Pillow 9.1.0 deprecated a bunch of constants such as PIL.Image.BILINEAR, leading to the following warning when importing the CLIP model

Note: I ran python with warnings enabled (python -W always)

>>> from transformers import CLIPFeatureExtractor

.../transformers/image_utils.py:239: DeprecationWarning: BILINEAR is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.BILINEAR instead.
  def resize(self, image, size, resample=PIL.Image.BILINEAR, default_to_square=True, max_size=None):

Caused by this line in image_utils.py (though there's other instances where deprecated PIL constants are used)

These constants are pending removal in Pillow 10 (July 2023).

Action required

Noticed that transformers doesn't currently enforce a Pillow version constraint in setup.py, so I've opened this issue to check if any action is required – either enforce Pillow < 10, or migrate to using the new Pillow constants


Additional info: discovered this warning when importing https://github.com/huggingface/diffusers – simply running import diffusers on a fresh install (version 0.4.1) triggers this warning for me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions