How to resize an image when using torchvision.transforms.Scale

hi,
i have questions when using torchvision.transforms.Scale to resize the training images
i want to resize all images to 32 * 128 pixels , what is the correct way ?

mine was :
transform = transforms.Compose(
[transforms.Scale((32,128)),
transforms.ToTensor(),
transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])

but it turned out to be wrong

thanks

1 Like

I too am looking for this!

@John_Zhang What turned out to be wrong? Did you get some kind of error message?

Found a solution. Basically, go into the data loader and change the function which is loading the image. It’s written in PIL so you can add a line there which resizes images using PIL’s resize.

I am confused with this problem too.
I have found that the torchvision package installed by “conda install pytorch torchvision cuda80 -c soumith” is different from the source code on github (https://github.com/pytorch/vision/blob/master/torchvision/transforms/transforms.py).
In the source code on github, there is a function calld “resize” in transforms.py, however there is no such function in the torchvision package installed by conda command.

You are looking at the code from the master branch. You are probably using an older version of torchvision when installing in conda.
You could wait for the next release or just build it from source.

1 Like

Thanks very much for your help. I tried to install from source code with ‘pip’ command and it worked!