参考博客:https://blog.youkuaiyun.com/TH_NUM/article/details/80877435
用于从文件夹中读取数据,源码链接:https://github.com/pytorch/vision/blob/master/torchvision/datasets/folder.py
ImageFolder是DatasetFolder的子类,有以下属性:
Attributes:
classes (list): List of the class names.
class_to_idx (dict): Dict with items (class_name, class_index).
samples (list): List of (sample path, class_index) tuples
targets (list): The class_index value for each image in the dataset
self.classes, self.class_to_idx是由方法find_classes得到,self.samples, self.targets由方法make_dataset得到:
classes, class_to_idx = self._find_classes(self.root)
samples = make_dataset(self.root, class_to_idx, extensions, is_valid_file)