mmcv, geometry.py not compatible with latest Pillow 9.1.0 (and possibly earlier versions)
See original GitHub issueHello,
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:
- Created a year ago
- Comments:6 (6 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@imabackstabber Sure, I can try to do a PR. I assume we still need to be backwards compatible with the older versions of pillow?
@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!