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

Pillow Version 7.0.0 ValueError image is wrong mode #1846

Closed
clkotnik opened this issue Feb 2, 2020 · 3 comments
Closed

Pillow Version 7.0.0 ValueError image is wrong mode #1846

clkotnik opened this issue Feb 2, 2020 · 3 comments

Comments

@clkotnik
Copy link

clkotnik commented Feb 2, 2020

I had a program running for awhile that used Image.resize(size) with defaults for other parms. I installed the program on a new system with Pillow installed as default version 7.0.0. The resize failed with Value Error image is wrong mode.

I removed Pillow and forced version 6.2.1 to install and the program works as before.

@pmeier
Copy link
Collaborator

pmeier commented Feb 3, 2020

What version of torchvision are you using? The release of pillow==7.0.0 broke torchvision==0.4.2 (#1714), but it should be fine for the latest release (torchvision==0.5.0). If that is not the case, please post a small example how to reproduce your error.

@clkotnik
Copy link
Author

clkotnik commented Feb 3, 2020

I do not use torchvision.

Here is a simplified example:

import numpy as np
from PIL import Image
imgdata = np.array( [[484, 451, 481, 465, 488, 442],
[823, 897, 971, 920, 855, 908],
[758, 919, 854, 920, 850, 854],
[840, 873, 950, 893, 872, 881],
[937, 940, 835, 879, 895, 774],
[841, 914, 867, 886, 922, 952]]).astype(np.uint16)

pimg = Image.fromarray(imgdata)
scale_factor = 0.5
size = tuple((np.array(pimg.size) * scale_factor).astype(int))
newim = pimg.resize(size)

ValueError Traceback (most recent call last)
in
12 scale_factor = 0.5
13 size = tuple((np.array(pimg.size) * scale_factor).astype(int))
---> 14 newim = pimg.resize(size)

e:\program files\python37\lib\site-packages\PIL\Image.py in resize(self, size, resample, box, reducing_gap)
1871 )
1872
-> 1873 return self._new(self.im.resize(size, resample, box))
1874
1875 def reduce(self, factor, box=None):

ValueError: image has wrong mode

@clkotnik
Copy link
Author

clkotnik commented Feb 3, 2020

Sorry, I seem to have drifted from Pillow to pytorch within github. Please disregards, I posted this to Pillow.

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

No branches or pull requests

3 participants