draugr.torch_utilities.datasets.supervised.vision_datasets.dict_dataset.SplitDictDatasetFolder

class draugr.torch_utilities.datasets.supervised.vision_datasets.dict_dataset.SplitDictDatasetFolder(root: ~pathlib.Path, loader: ~torch.utils.data.dataloader.DataLoader, extensions: ~typing.Optional[~typing.Iterable] = None, transform: ~typing.Optional[callable] = None, target_transform: ~typing.Optional[callable] = None, split: ~draugr.numpy_utilities.datasets.splitting.SplitEnum = SplitEnum.training, valid_percentage: float = 15, test_percentage: float = 0, is_valid_file: callable = <function has_file_allowed_extension>)[source]

Bases: VisionDataset

A generic data loader where the samples are arranged in this way:

root/class_x/xxx.ext root/class_x/xxy.ext root/class_x/xxz.ext

root/class_y/123.ext root/class_y/nsdf3.ext root/class_y/asd932_.ext

Args: root (string): Root directory path. loader (callable): A function to load a sample given its path. extensions (tuple[string]): A list of allowed extensions.

both extensions and is_valid_file should not be passed.

transform (callable, optional): A function/transform that takes in

a sample and returns a transformed version. E.g, transforms.RandomCrop for images.

target_transform (callable, optional): A function/transform that takes

in the target and transforms it.

is_valid_file (callable, optional): A function that takes path of a file

and check if the file is a valid file (used to check of corrupt files) both extensions and is_valid_file should not be passed.

Attributes: _categories (list): List of the class names sorted alphabetically. _data_categories (list): List of (sample path, class_index) tuples

__init__(root: ~pathlib.Path, loader: ~torch.utils.data.dataloader.DataLoader, extensions: ~typing.Optional[~typing.Iterable] = None, transform: ~typing.Optional[callable] = None, target_transform: ~typing.Optional[callable] = None, split: ~draugr.numpy_utilities.datasets.splitting.SplitEnum = SplitEnum.training, valid_percentage: float = 15, test_percentage: float = 0, is_valid_file: callable = <function has_file_allowed_extension>)[source]

Methods

__init__(root, loader[, extensions, ...])

extra_repr()

sample(target, index)

description

sample(target, index) Tuple[source]

description