For anyone who stumbles upon this later, I made a convenient little gist for this:

  
      gist.github.com
  
  
    https://gist.github.com/andrewjong/6b02ff237533b3b2c554701fb53d5c4d 2.8k
pytorch_image_folder_with_file_paths.py
import torch
from torchvision import datasets

class ImageFolderWithPaths(datasets.ImageFolder):
    """Custom dataset that includes image paths. Extends
    torchvision.datasets.ImageFolder
    """

    # override the __getitem__ method that dataloader calls
    def __getitem__(self, index):
This file has been truncated. show original