tfm.vision.augment.MixupAndCutmix

Applies Mixup and/or Cutmix to a batch of images.

Implementaion is inspired by https://github.com/rwightman/pytorch-image-models

mixup_alpha (float, optional): For drawing a random lambda (lam) from a beta distribution (for each image). If zero Mixup is deactivated. Defaults to .8. cutmix_alpha (float, optional): For drawing a random lambda (lam) from a beta distribution (for each image). If zero Cutmix is deactivated. Defaults to 1.. prob (float, optional): Of augmenting the batch. Defaults to 1.0. switch_prob (float, optional): Probability of applying Cutmix for the batch. Defaults to 0.5. label_smoothing (float, optional): Constant for label smoothing. Defaults to 0.1. num_classes (int, optional): Number of classes. Defaults to 1001.

Methods

distort

View source

Applies Mixup and/or Cutmix to batch of images and transforms labels.

Args
images (tf.Tensor): Of shape [batch_size,height, width, 3] representing a batch of image. labels (tf.Tensor): Of shape [batch_size, ] representing the class id for each image of the batch.

Returns
Tuple[tf.Tensor, tf.Tensor]: The augmented version of image and labels.

__call__

View source

Call self as a function.