Solved by ptrblck in post #8 
              
              
                You should find plenty of custom Datasets in this discussion board. 
Here is an example: 
class MyLazyDataset(Dataset):
    def __init__(self, image_paths, targets, transform=None):
        self.image_paths = image_paths
        self.targets = targets
        self.transform = transform
        
    …