vision.pytorch.input.classification package#
Submodules#
vision.pytorch.input.classification.dataset_factory module#
- class vision.pytorch.input.classification.dataset_factory.VisionSubset[source]#
Bases:
torch.utils.data.Subset
- set_transforms(transforms=None, transform=None, target_transform=None)[source]#
- transforms (callable, optional): A function/transforms that takes in
an image and a label and returns the transformed versions of both.
- transform (callable, optional): A function/transform that takes in an PIL image
and returns a transformed version. E.g,
transforms.RandomCrop
- target_transform (callable, optional): A function/transform that takes in the
target and transforms it.
vision.pytorch.input.classification.mixup module#
Mixup and CutMix
This is borrowed from the PyTorch repo: https://github.com/pytorch/vision/blob/main/references/classification/transforms.py
- class vision.pytorch.input.classification.mixup.RandomCutmix[source]#
Bases:
torch.nn.Module
Randomly apply Cutmix to the provided batch and targets. The class implements the data augmentations as described in the paper “CutMix: Regularization Strategy to Train Strong Classifiers with Localizable Features”. :param num_classes: number of classes used for one-hot encoding. :type num_classes: int :param p: probability of the batch being transformed. Default value is 0.5. :type p: float :param alpha: hyperparameter of the Beta distribution used for cutmix.
Default value is 1.0.
- Parameters
inplace (bool) – boolean to make this transform inplace. Default set to False.
- class vision.pytorch.input.classification.mixup.RandomMixup[source]#
Bases:
torch.nn.Module
Randomly apply Mixup to the provided batch and targets. The class implements the data augmentations as described in the paper “mixup: Beyond Empirical Risk Minimization”. :param num_classes: number of classes used for one-hot encoding. :type num_classes: int :param p: probability of the batch being transformed. Default value is 0.5. :type p: float :param alpha: hyperparameter of the Beta distribution used for mixup.
Default value is 1.0.
- Parameters
inplace (bool) – boolean to make this transform inplace. Default set to False.
vision.pytorch.input.classification.preprocessing module#
vision.pytorch.input.classification.sampler module#
- class vision.pytorch.input.classification.sampler.RepeatedAugSampler[source]#
Bases:
torch.utils.data.Sampler
Sampler that restricts data loading to a subset of the dataset for distributed, with repeated augmentation. It ensures that different each augmented version of a sample will be visible to a different process (GPU). Heavily based on ‘torch.utils.data.DistributedSampler’.
This is borrowed from the DeiT Repo: https://github.com/facebookresearch/deit/blob/main/samplers.py