RandomErasing¶
- class mmpretrain.datasets.transforms.RandomErasing(erase_prob=0.5, min_area_ratio=0.02, max_area_ratio=0.4, aspect_range=(0.3, 3.3333333333333335), mode='const', fill_color=(128, 128, 128), fill_std=None)[source]¶
Randomly selects a rectangle region in an image and erase pixels.
Required Keys:
img
Modified Keys:
img
- Parameters:
erase_prob (float) – Probability that image will be randomly erased. Default: 0.5
min_area_ratio (float) – Minimum erased area / input image area Default: 0.02
max_area_ratio (float) – Maximum erased area / input image area Default: 0.4
aspect_range (sequence | float) – Aspect ratio range of erased area. if float, it will be converted to (aspect_ratio, 1/aspect_ratio) Default: (3/10, 10/3)
mode (str) –
Fill method in erased area, can be:
const (default): All pixels are assign with the same value.
rand: each pixel is assigned with a random value in [0, 255]
fill_color (sequence | Number) – Base color filled in erased area. Defaults to (128, 128, 128).
fill_std (sequence | Number, optional) – If set and
mode
is ‘rand’, fill erased area with random color from normal distribution (mean=fill_color, std=fill_std); If not set, fill erased area with random color from uniform distribution (0~255). Defaults to None.
Note
See Random Erasing Data Augmentation
This paper provided 4 modes: RE-R, RE-M, RE-0, RE-255, and use RE-M as default. The config of these 4 modes are:
RE-R: RandomErasing(mode=’rand’)
RE-M: RandomErasing(mode=’const’, fill_color=(123.67, 116.3, 103.5))
RE-0: RandomErasing(mode=’const’, fill_color=0)
RE-255: RandomErasing(mode=’const’, fill_color=255)