ImageFolder¶
- class ImageFolder(root, check_valid_func=None, class_name=False)[source]¶
ImageFolder is a class for loading image data and labels from a organized folder.
The folder is expected to be organized as followed: root/cls/xxx.img_ext
Labels are indices of sorted classes in the root directory.
- Parameters
root (
str
) – root directory of an image folder.loader – a function used to load image from path, if
None
, default function that loads images with PIL will be called.check_valid_func – a function used to check if files in folder are expected image files, if
None
, default function that checks file extensions will be called.class_name (
bool
) – ifTrue
, return class name instead of class index.