Hi,
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

The code to reproduce this error for ToPILImage:
import numpy as np
import torch
from torchvision import transforms
from torch.utils.data import DataLoader, Dataset

class given_data(Dataset):

    def __init__(self,images,labels, transform = None):
        self.images = images
        self.labels = labels
        self.transform = transform
    
    def __len__(self):
        return len(self.labels)
    
    def __getitem__(self,indx):
        imgs = self.images[indx]
        labls = self.labels[indx]
        
        if self.transform:
            imgs = self.transform(np.float32(imgs))
        return (imgs,labls)
    
X_inp = np.random.rand(100,75,75,2)
Y_inp = np.random.rand(100)


txfm = transforms.Compose([transforms.ToPILImage()])

transformed_dataset = given_data(X_inp,Y_inp,transform= txfm)

print(transformed_dataset[2])

For RandomResizedCrop simply replace the following line:
txfm = transforms.Compose([transforms.RandomResizedCrop((80,80),ratio=(1,1))])


I’ve installed torchvision from source.
Can someone please help me out?