Solved by ptrblck in post #2 
              
              
                Using the Dataset class, you can lazily load your images in the __getitem__ method. 
Here is a small example: 
class TrainDataset(Dataset):
    def __init__(self, image_paths, targets):
        self.image_paths = image_paths
        self.targets = targets

    def __getitem__(self, index):
        i…