![]() |
Applies Mixup and/or Cutmix to a batch of images.
tfm.vision.augment.MixupAndCutmix(
mixup_alpha: float = 0.8,
cutmix_alpha: float = 1.0,
prob: float = 1.0,
switch_prob: float = 0.5,
label_smoothing: float = 0.1,
num_classes: int = 1001
)
- Mixup: https://arxiv.org/abs/1710.09412
- Cutmix: https://arxiv.org/abs/1905.04899
Implementaion is inspired by https://github.com/rwightman/pytorch-image-models
Args | |
---|---|
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
distort(
images: tf.Tensor, labels: tf.Tensor
) -> Tuple[tf.Tensor, tf.Tensor]
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, or [batch_size, time, height, width, 3] representing a batch of video. 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__
__call__(
images: tf.Tensor, labels: tf.Tensor
) -> Tuple[tf.Tensor, tf.Tensor]
Call self as a function.