Skip to content
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

torchvision transforms broken by Pillow 7.0 release #1714

Closed
felix-ht opened this issue Jan 2, 2020 · 9 comments
Closed

torchvision transforms broken by Pillow 7.0 release #1714

felix-ht opened this issue Jan 2, 2020 · 9 comments

Comments

@felix-ht
Copy link

felix-ht commented Jan 2, 2020

🐛 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

@rhristov
Copy link

rhristov commented Jan 2, 2020

@sachinparyani
Copy link

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

@jsmodic
Copy link

jsmodic commented Jan 3, 2020

It seems like it was fixed here a few months ago: b8ef532

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

@hugovk
Copy link

hugovk commented Jan 3, 2020

Duplicate of #1712:

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

@fmassa
Copy link
Member

fmassa commented Jan 3, 2020

As @hugovk mentioned in #1714 (comment), we will be releasing a new version of torchvision early next week, so I believe this can be closed.

Thanks for the reports!

@MichaelX99
Copy link

@fmassa thank you for being so responsive!

@sachinparyani
Copy link

Thank you!

@DB11051998
Copy link

DB11051998 commented Apr 4, 2021

i am still getting the error, cannot import the Compose. i need a help!


Screenshot (131)

@fmassa
Copy link
Member

fmassa commented Aug 12, 2021

@DB11051998 FYI you need to import it via from torchvision.transforms import Compose

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants