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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error with PIL 8.3.0: __array__() takes 1 positional argument but 2 were given #4146
Comments
Thanks for the report, I can reproduce. The issue seems to come from the PIL version. This passes with PIL 8.2, but fails with PIL 8.3. import numpy as np
from PIL import Image
img = Image.fromarray(np.random.randint(0, 256, (10, 10, 3), dtype=np.uint8))
np.array(img, np.int16) As a temporary workaround for you, downgrade PIL to 8.2. However it would be nice to get this fixed. Would you mind checking if a similar issue was raised in the PIL repo, and if not, submit one and ping me there? Thanks!! |
Hi Nicolas, nice to hear that you can reproduce the issue. Let's see how they proceed in the PIL repo. Cheers, Basti |
@NicolasHug We should change Line 70 in 993325d
to |
It's up to PIL to release a bugfix release, not us :) 8.3 was released 8 hours ago and they're already working on a fix python-pillow/Pillow#5572 which should be in soon. |
True, but we know that our stuff will not work with |
Is this a common practice? I've never seen it. |
I've seen it a few times, for example here
If we know that there are Pillow versions that will break our code, than yes, we should explicitly exclude them. Most of the time Pillow bugs will only degrade our quality. |
thanks for the details, that sounds good then. I opened #4148 |
The alternatives are:
|
I don't know for sure, but the extra stuff suggests that we need to do that: vision/torchvision/transforms/functional.py Lines 126 to 130 in 993325d
If pillow publishes a release with your patch before we do, this would be irrelevant. I imagine they will release a small patch a lot sooner than we do. |
Just ran in to this with adjust_hue
|
Re-opening temporarily as other users might bump into this issue, this will hopefully help avoid duplicated entries like #4152 |
Pillow 8.3.1 should now be released with a fix for this. |
We can close this now. Unless someone explicitly specifies |
馃悰 Bug
The
torchvision.transformer
functionToTensor
raise aTypeError
when receiving a image loaded withPIL
.The error origins from a call to
np.array
and contains the message:__array__() takes 1 positional argument but 2 were given
To Reproduce
Steps to reproduce the behavior:
Pip Freeze Log:
Full Traceback:
Expected behavior
I expect that the conversion works and I reveive a torch.Tensor with shape (200, 200, 3)
Environment
conda
,pip
, source):pip
Additional context
n/A
The text was updated successfully, but these errors were encountered: