Could you post the entire error message as I’m currently unsure how your DataLoader would work.
It seems you might be passing a list of lists containing file paths, which the DataLoader should not be able to handle. If train_files contains paths to the actual data, you would need to load and process each sample in a Dataset first before passing it to the DataLoader.
train_files does contains paths to the actual data. When you say load and process each sample, what do you exactly mean - would I need to pass each sample into say an open_img function which loads each individual image?
I don’t know how you’ve defined your custom Dataset but based on the error message a transformation fails as you are passing a dict to it instead of a PIL.Image or numpy array as seen here:
transform = transforms.ToTensor()
# fails
transform(dict())
# TypeError: pic should be PIL Image or ndarray. Got <class 'dict'>
# works
x = np.random.randint(0, 256, (224, 224, 3)).astype(np.uint8)
out = transform(x)
I don’t know where the dict is created and why the error is raised.
However, you should transform the PIL.Image to a tensor before returning it in the __getitem__ method.