TypeError in DataLoader worker process 0 (Due to my transforms?)

Hi, I’m re-training an inception_v3 using a remote GPU with CUDA device.
I used these transforms for my dataset

train_set = datasets.ImageFolder(
root = “liG”,
transform = transforms.Compose([transforms.ToTensor(),
transforms.RandomRotation(20),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
transforms.Resize(299)]
))
data_loader= torch.utils.data.DataLoader(train_set,
batch_size=5,
shuffle=True,
num_workers=2)
Below is the cell that raises the error:
for X, y in data_loader:
print("Shape of X [N, C, H, W]: ", X.shape)
print("Shape of y: ", y.shape, y.dtype)
break

The error I’m getting is:

TypeError: Caught TypeError in DataLoader worker process 0.
Original Traceback (most recent call last):
File “/opt/conda/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py”, line 202, in _worker_loop
data = fetcher.fetch(index)
File “/opt/conda/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py”, line 44, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File “/opt/conda/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py”, line 44, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File “/opt/conda/lib/python3.8/site-packages/torchvision/datasets/folder.py”, line 171, in getitem
sample = self.transform(sample)
File “/opt/conda/lib/python3.8/site-packages/torchvision/transforms/transforms.py”, line 60, in call
img = t(img)
File “/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py”, line 881, in _call_impl
result = self.forward(*input, **kwargs)
File “/opt/conda/lib/python3.8/site-packages/torchvision/transforms/transforms.py”, line 1236, in forward
fill = [float(f) for f in fill]
TypeError: ‘NoneType’ object is not iterable

Based on the error message it seems that fill is set to None in this line of code, which shouldn’t be the case, as it’s checked here.

I also cannot reproduce the issue using this code snippet:

transform = transforms.Compose([
    transforms.ToTensor(),
    transforms.RandomRotation(20),
    transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
    transforms.Resize(299)
])

img = transforms.ToPILImage()(torch.randn(3, 224, 224))
out = transform(img)

Which PyTorch and torchvision versions are you using and are you seeing the same issue using my code?