RandomErasing

class torchaug.transforms.RandomErasing(p=0.5, scale=(0.02, 0.33), ratio=(0.3, 3.3), value=0.0, inplace=False, batch_inplace=False, num_chunks=1, permute_chunks=False, batch_transform=False)[source]

Randomly select a rectangle region in the input image or video and erase its pixels.

‘Random Erasing Data Augmentation’ by Zhong et al. See https://arxiv.org/abs/1708.04896

Parameters:
  • p (float, optional) – probability that the random erasing operation will be performed. Default: 0.5

  • scale (Tuple[float, float], optional) – range of proportion of erased area against input image. Default: (0.02, 0.33)

  • ratio (Tuple[float, float], optional) – range of aspect ratio of erased area. Default: (0.3, 3.3)

  • value (float, optional) – erasing value. If a single int, it is used to erase all pixels. If a tuple of length 3, it is used to erase R, G, B channels respectively. If a str of ‘random’, erasing each pixel with random values. Default: 0.0

  • batch_inplace (bool, optional) – whether to apply the batch transform in-place. Does not prevent functionals to make copy but can reduce time and memory consumption. Default: False

  • num_chunks (int, optional) – number of chunks to split the batched input into. Default: 1

  • permute_chunks (bool, optional) – whether to permute the chunks. Default: False

  • batch_transform (bool, optional) – whether to apply the transform in batch mode. Default: False