I’m trying to use the transforms ToPILImage and RandomResizedCrop and run into the following errors.
For ToPILImage:
File "/home/usr/anaconda3/lib/python3.6/site-packages/torchvision-0.2.0-py3.6.egg/torchvision/transforms/functional.py", line 139, in to_pil_image
raise TypeError('Input type {} is not supported'.format(npimg.dtype))
TypeError: Input type float32 is not supported
For RandomResizedCrop:
File "/home/usr/anaconda3/lib/python3.6/site-packages/torchvision-0.2.0-py3.6.egg/torchvision/transforms/transforms.py", line 396, in get_params
area = img.size[0] * img.size[1]
TypeError: 'int' object is not subscriptable
Thanks, that does explain why it ToPILImage didn’t work. Unfortunately I’m dealing with Radar data for the Iceberg challenge hence, so neither can I convert it to a 3 channel image nor have uint8 format.
Did you find why RandomResizedCrop throws an error?
You can directly transform Radar data into torch tensor, but you need to perform operations (e.g. resize) beforehand (i.e. implement your operations manually).
I could not reproduce the error with RandomResizedCrop.
I also faced this problem, in my case I read image from cv2, then I used transforms.RandomResziedCro()p. I solved this by adding transforms.ToPILImage() before transforms.RandomResziedCrop().