How to load image using DataLoader with a list of image file names?

I have a list containing a set of image file names and their corresponding labels.
These images are stored in a folder with some other images.
How can I load these images with DataLoader()?

1 Like

torchvision.datasets.ImageFolder(root, transform=None, target_transform=None, loader=)。this maybe help you.

May I ask what is inside ‘loader’?
Is it a list class containing a set of image file names represented by str class?

I am not sure what you meant, but loader is a function to load files/images.

make_dataset() is where you define the list of files you are going to randomly select and pass to loader. By checking the code inside make_dataset(), you will get a better idea of what “list of files” will be collected.