Issues using torchvision.transforms.Resize/Scale (ValueError: unknown resampling filter)

Hi, all,
I am having some problems running the Resize/Scale functions from the torchvision package. Hope someone can help :). Not sure if I am using this correctly, e.g., in my code I use it in a custom transformer:

custom_transform = transforms.Compose([transforms.Grayscale(),
                                       transforms.Scale(112, 112), ### <---- Here!
                                       transforms.ToTensor()])
    
train_dataset = CelebaDataset(txt_path='../../celeba_dpm_data/train_partition_balanced.csv',
                              img_dir='../../celeba_dpm_data/images-dpmcrop',
                              transform=custom_transform)

I tried both Scale (now deprecated) and Resize and get a similar error in both cases

/mnt/home/raschkas/miniconda3/lib/python3.6/site-packages/torchvision-0.2.0-py3.6.egg/torchvision/transforms/transforms.py:156: UserWarning: The use of the transforms.Scale transform is deprecated, please use transforms.Resize instead.
Traceback (most recent call last):
  File "autoencoder_30.py", line 293, in <module>
    for batch_idx, (features, targets) in enumerate(train_loader):
  File "/mnt/home/raschkas/miniconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 210, in __next__
    return self._process_next_batch(batch)
  File "/mnt/home/raschkas/miniconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 230, in _process_next_batch
    raise batch.exc_type(batch.exc_msg)
ValueError: Traceback (most recent call last):
  File "/mnt/home/raschkas/miniconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 42, in _worker_loop
    samples = collate_fn([dataset[i] for i in batch_indices])
  File "/mnt/home/raschkas/miniconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 42, in <listcomp>
    samples = collate_fn([dataset[i] for i in batch_indices])
  File "autoencoder_30.py", line 47, in __getitem__
    img = self.transform(img)
  File "/mnt/home/raschkas/miniconda3/lib/python3.6/site-packages/torchvision-0.2.0-py3.6.egg/torchvision/transforms/transforms.py", line 42, in __call__
    img = t(img)
  File "/mnt/home/raschkas/miniconda3/lib/python3.6/site-packages/torchvision-0.2.0-py3.6.egg/torchvision/transforms/transforms.py", line 147, in __call__
    return F.resize(img, self.size, self.interpolation)
  File "/mnt/home/raschkas/miniconda3/lib/python3.6/site-packages/torchvision-0.2.0-py3.6.egg/torchvision/transforms/functional.py", line 197, in resize
    return img.resize((ow, oh), interpolation)
  File "/mnt/home/raschkas/miniconda3/lib/python3.6/site-packages/PIL/Image.py", line 1722, in resize
    raise ValueError("unknown resampling filter")
ValueError: unknown resampling filter

Before filing an issue, I think chances are likely that I might be using incorrectly, so I wanted to ask if someone know’s what could be going on here :P.

I think it needs to be a tuple, i.e. transforms.Resize((112, 112))

EDIT:

Yep, went to my old code where I used Resize and changed it to your version and it threw the same error.

Thanks!!! Arg, I didn’t see the forest for the trees here, was so focussed on the error message “unknown resampling filter” that it didn’t even occur to me. :smiley: