Skip to content

Instantly share code, notes, and snippets.

View JessicaDuFirst's full-sized avatar

Wenju Du JessicaDuFirst

  • Yangzhou, China
View GitHub Profile
@JessicaDuFirst
JessicaDuFirst / pytorch_image_folder_with_file_paths.py
Created October 24, 2019 13:10 — forked from andrewjong/pytorch_image_folder_with_file_paths.py
PyTorch Image File Paths With Dataset Dataloader
import torch
from torchvision import datasets
class ImageFolderWithPaths(datasets.ImageFolder):
"""Custom dataset that includes image file paths. Extends
torchvision.datasets.ImageFolder
"""
# override the __getitem__ method. this is the method that dataloader calls
def __getitem__(self, index):