"No such file or directory"- ImageFolder, but there is

Hi i’m trying to load my data using:

trainset = datasets.ImageFolder(root=traindir, transform=train_transform)
trainloader = torch.utils.data.DataLoader(trainset,

testset = datasets.ImageFolder(root=testdir, transform=transform)
testloader = torch.utils.data.DataLoader(testset,

And I’m getting this error:

FileNotFoundError: [Errno 2] No such file or directory: ‘data/cinic10-trainlarge/train/ship/n03859170_1073.png’

The error sounds pretty clear, the loader can’t find this file… but when I’m looking for this file he is there:

Any idea what am I missing?

Are you sure the file is there and it’s not a broken symbolic link?
Could you please run ll data/... and check the output?

I shared the ls, now I’ll do the ll

forgive me for my ignorance, I have no idea what this arrow represent

The arrow means, that the file name on the left is in fact a symbolic link, which points to the file on the right.
You could see it as a shortcut to the “real” file.
However, since the link is red, it indicates that the real file is missing and the link thus broken.
If you check the right file name via ls or ll you should get an error.

But the link I’m looking for is the left one, the left one also doesn’t exists?

The symbolic link on the left exists, but points to a non-existing file.
Note that the left file does not contain the image. It’s just a link to the real file, which is missing.

1 Like

Ok got it, I’ll fix it.