Open soldier828 opened 5 years ago
Hi @soldier828 could you paste your env here, like python version and how to repro? The script runs for me, and putpalette
does take sequence. https://pillow.readthedocs.io/en/4.1.x/reference/Image.html#PIL.Image.Image.putpalette
Hi @soldier828 could you paste your env here, like python version and how to repro? The script runs for me, and
putpalette
does take sequence. https://pillow.readthedocs.io/en/4.1.x/reference/Image.html#PIL.Image.Image.putpalette
I follow the code refer to https://pytorch.org/hub/pytorch_vision_deeplabv3_resnet101/. Except one change as below, namely import deeplabv3 model. Did this lead to the r.putpalette error?
model = torchvision.models.segmentation.deeplabv3_resnet101(pretrained=True)
model.eval()
When I use the raw code for import model, I got this Cannot find callable deeplabv3_resnet101 in hubconf
, so I change the code to the torchvision.models.segmentation.deeplabv3_resnet101
My env: Python 2.7.11 torch 1.1.0 torchvision 0.3.0 Pillow 4.1.1
CentOS release 6.3
All bug info
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-12-083f663418f9> in <module>()
6 # plot the semantic segmentation predictions of 21 classes in each color
7 r = Image.fromarray(output_predictions.byte().cpu().numpy()).resize(input_image.size)
----> 8 r.putpalette(colors)
9
10 # import matplotlib.pyplot as plt
/home/users/project/standalone_torch041_cuda90/mms-hpc-devel/lib/python2.7/site-packages/PIL/Image.pyc in putpalette(self, data, rawmode)
1491 if not isinstance(data, bytes):
1492 if bytes is str:
-> 1493 data = "".join(chr(x) for x in data)
1494 else:
1495 data = bytes(data)
/home/users/project/standalone_torch041_cuda90/mms-hpc-devel/lib/python2.7/site-packages/PIL/Image.pyc in <genexpr>((x,))
1491 if not isinstance(data, bytes):
1492 if bytes is str:
-> 1493 data = "".join(chr(x) for x in data)
1494 else:
1495 data = bytes(data)
TypeError: only size-1 arrays can be converted to Python scalars
@soldier828 please give this a try again with the latest pytorch. it works in the CI environment it looks like.
The above code will raise TypeError: only size-1 arrays can be converted to Python scalars. The code
r.putpalette(colors)
requires single color not colors. How to fix this code?