Torchvision.transforms.functional.normalize throws Error: img should be PIL Image. Got <class 'torch.Tensor'>

Hi there,

I am trying to transform my input data. I have images of shape [6, height, width] and want to reshape them to [6, 112, 112]. Since I have 6 channels, I can’t use PILImage. Therefore I coose to use torchvision.transforms.functional.resize() because it is supposed to take torch.Tensors as input aswell.
I tried:

            img = torch.tensor(img)
            img = transforms.functional.resize(img, size =(112,112))
            img = transforms.functional.normalize(img, (0.5,0.5,0.5,0.5,0.5,0.5), (0.25,0.25,0.25,0.25,0.25,0.25))

But I get the following error:

TypeError: img should be PIL Image. Got <class 'torch.Tensor'>

Can somebody tell me what I can do to transform my 6 channel images?

Thanks =)

You might need to update to the latest torchvision version, as the tensor input functionality was just recently added. :wink: