How to load images from a folder whose names are stored in a csv file

Hi,

I am not sure about your code, but there is easier ways to handle it. You can define your custom Dataset class and have all data in each iteration just by setting batch_size=len(data) and you no longer have to change your code for different purposes. And also, you have to implement __len__ function too.

Here is conventional implementation of custom dataset class:

After creating such a Dataset, you can use it for different purposes like this:

train_dataset = PlacesDataset(txt_path=args.txt,
                              img_dir=args.img,
                              transform=custom_transforms)

train_loader = DataLoader(dataset=train_dataset,
                          batch_size=args.bs,
                          shuffle=True,
                          num_workers=args.nw,
                          pin_memory=pin_memory)

bests