Train with some Image path from csv not present in Image directory: Dataloader

Hello everyone,

I would like to remove some images from my Image directory, and I was wonder if the PyTorch Dataloader is able to train on custom dataset by reading image path from csv then if the image is not found, juste pass to another image.

Is the PyTorch Dataloader can handle this or I have to remove these images from the csv file ?

Thank you all,


If you are fine with some repeated images, you could check in the __getitem__ method of your Dataset, if the current file exists, and if not just sample a new random index.
This approach will repeat as many valid images as there are missing ones.

Would that work for you?

Thanks @ptrblck, interesting but unfortunately I prefer not to have repeated images. Is there a way to juste pass to the next iteration if the image is not present ?