root/dog/xxx.png
root/dog/xxy.png
root/dog/[...]/xxz.png
root/cat/123.png
root/cat/nsdf3.png
root/cat/[...]/asd932_.png
This class inherits from DatasetFolder so
the same methods can be overridden to customize the dataset.
- Parameters:
root (str or pathlib.Path) – Root directory path.
transform (callable, optional) – A function/transform that takes in a PIL image or torch.Tensor, depends on the given loader,
and returns a transformed version. E.g, transforms.RandomCrop
target_transform (callable, optional) – A function/transform that takes in the
target and transforms it.
loader (callable, optional) – A function to load an image given its path.
is_valid_file (callable, optional) – A function that takes path of an Image file
and check if the file is a valid file (used to check of corrupt files)
allow_empty – If True, empty folders are considered to be valid classes.
An error is raised on empty folders if False (default).