question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

mmcv, geometry.py not compatible with latest Pillow 9.1.0 (and possibly earlier versions)

See original GitHub issue

Hello,

I am using MMDeploy to generate an optimized model trained by MMDetection.

It looks like there is an incompatibility with latest Pillow. I get the following error when executing MMDeploy tools/deploy.py. The error occurs in mmcv geometric.py

Traceback (most recent call last):
  File "tools/deploy.py", line 7, in <module>
    import mmcv
  File "/home/nvidia/git/project/venv-mmdet/lib/python3.6/site-packages/mmcv/__init__.py", line 5, in <module>
    from .image import *
  File "/home/nvidia/git/project/venv-mmdet/lib/python3.6/site-packages/mmcv/image/__init__.py", line 5, in <module>
    from .geometric import (cutout, imcrop, imflip, imflip_, impad,
  File "/home/nvidia/git/project/venv-mmdet/lib/python3.6/site-packages/mmcv/image/geometric.py", line 42, in <module>
    'nearest': Image.NEAREST,
AttributeError: module 'PIL.Image' has no attribute 'NEAREST'

This error does not occur on an earlier version of Pillow (7.0.0) but it occurs on 9.1.0. I can replicate the issue by calling Python3 directly:

  • Pillow 7.0.0
>>> from PIL import Image
>>> Image.NEAREST
0
  • Pillow 9.1.0
from PIL import Image
>>> Image.NEAREST
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'PIL.Image' has no attribute 'NEAREST'

Solution: It looks like the NEAREST… variables has been moved into PIL.Image.Resampling: PIL.Image.Resampling.NEAREST

Alternatively, the deprecated filters can be accessed using the following names:

PIL.Image.NONE = Resampling.NEAREST
PIL.Image.LINEAR = Resampling.BILINEAR
PIL.Image.CUBIC = Resampling.BICUBIC
PIL.Image.ANTIALIAS = Resampling.LANCZOS

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
tehkillerbeecommented, Apr 20, 2022

@imabackstabber Sure, I can try to do a PR. I assume we still need to be backwards compatible with the older versions of pillow?

0reactions
imabackstabbercommented, Apr 29, 2022

@tehkillerbee Thanks for prompted reply! And Also, feel free to let us know if there’s any problem when updating and we’re always ready for help contributing!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pillow 9.1.0 - PyPI
The Python Imaging Library adds image processing capabilities to your Python interpreter. This library provides extensive file format support, an efficient ...
Read more >
Unable to install Pillow on the Macbook Pro 13 M1 Silicon
Pillow installation causing error continuously, the error is mentioned below. What are your OS, Python, and Pillow versions?
Read more >
Installation - Pillow (PIL Fork) 9.3.0 documentation
We provide binaries for macOS for each of the supported Python versions ... Pillow does not support the earlier 1.5 series which ships...
Read more >
python - Pip can't install pillow - Stack Overflow
I solved this by explicitly deleting the version numbering inside of the requirements.txt file That way pip fetched the latest pillow ...
Read more >
Bug listing with status RESOLVED with resolution TEST ...
Bug:233 - "Emacs segfaults when merged through the sandbox." status:RESOLVED resolution:TEST-REQUEST severity:critical · Bug:3888 - "yenta_socket module not ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found