Vision: torchvision transforms broken by Pillow 7.0 release

Created on 2 Jan 2020  路  7Comments  路  Source: pytorch/vision

馃悰 Bug

Pillow just released 7.0.0. This breaks torchvision.transforms as the import fails:

Traceback (most recent call last):
  File "examples/mnist.py", line 5, in <module>
    from torchvision.transforms import (
  File "/home/felix/.local/share/virtualenvs/repro-Cd9xy9KO/lib/python3.6/site-packages/torchvision/__init__.py", line 4, in <module>
    from torchvision import datasets
  File "/home/felix/.local/share/virtualenvs/repro-Cd9xy9KO/lib/python3.6/site-packages/torchvision/datasets/__init__.py", line 9, in <module>
    from .fakedata import FakeData
  File "/home/felix/.local/share/virtualenvs/repro-Cd9xy9KO/lib/python3.6/site-packages/torchvision/datasets/fakedata.py", line 3, in <module>
    from .. import transforms
  File "/home/felix/.local/share/virtualenvs/repro-Cd9xy9KO/lib/python3.6/site-packages/torchvision/transforms/__init__.py", line 1, in <module>
    from .transforms import *
  File "/home/felix/.local/share/virtualenvs/repro-Cd9xy9KO/lib/python3.6/site-packages/torchvision/transforms/transforms.py", line 17, in <module>
    from . import functional as F
  File "/home/felix/.local/share/virtualenvs/repro-Cd9xy9KO/lib/python3.6/site-packages/torchvision/transforms/functional.py", line 5, in <module>
    from PIL import Image, ImageOps, ImageEnhance, PILLOW_VERSION
ImportError: cannot import name 'PILLOW_VERSION'

https://github.com/python-pillow/Pillow/releases

To Reproduce

run
from torchvision.transforms import Compose

Environment

torch==1.3.1
torchvision==0.4.2
torchvision==7.0.0

Fix

I pinned pillow to version 6.2.2. After this the import works again

bug transforms

Most helpful comment

As @hugovk mentioned in https://github.com/pytorch/vision/issues/1714#issuecomment-570536493, we will be releasing a new version of torchvision early next week, so I believe this can be closed.

Thanks for the reports!

All 7 comments

I still get version 7.0.0 when I install using the following command

pip3 install torch===1.3.1 torchvision===0.4.2 -f https://download.pytorch.org/whl/torch_stable.html

or even using the following command

pip3 install torch===1.3.1 torchvision===0.4.2 -f https://download.pytorch.org/whl/torch_stable.html

It seems like it was fixed here a few months ago: https://github.com/pytorch/vision/commit/b8ef5322b5aea611a6aca2c876578d012b9a890a

But there hasn't been a release that includes it.

Duplicate of https://github.com/pytorch/vision/issues/1712:

We will be releasing a new version of PyTorch and torchvision early next week, so this should be soon fixed.

As @hugovk mentioned in https://github.com/pytorch/vision/issues/1714#issuecomment-570536493, we will be releasing a new version of torchvision early next week, so I believe this can be closed.

Thanks for the reports!

@fmassa thank you for being so responsive!

Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Wadaboa picture Wadaboa  路  3Comments

varagrawal picture varagrawal  路  3Comments

martinarjovsky picture martinarjovsky  路  4Comments

bodokaiser picture bodokaiser  路  3Comments

datumbox picture datumbox  路  3Comments