mindspore.dataset.vision.py_transforms.RandomErasing
- class mindspore.dataset.vision.py_transforms.RandomErasing(prob=0.5, scale=(0.02, 0.33), ratio=(0.3, 3.3), value=0, inplace=False, max_attempts=10)[source]
Erase the pixels, within a selected rectangle region, to the given value.
Randomly applied on the input NumPy image array with a given probability.
Zhun Zhong et al. ‘Random Erasing Data Augmentation’ 2017 See https://arxiv.org/pdf/1708.04896.pdf
- Parameters
prob (float, optional) – Probability of applying RandomErasing (default=0.5).
scale (sequence of floats, optional) – Range of the relative erase area to the original image (default=(0.02, 0.33)).
ratio (sequence of floats, optional) – Range of the aspect ratio of the erase area (default=(0.3, 3.3)).
value (Union[int, sequence, string]) – Erasing value (default=0). If value is a single intieger, it is applied to all pixels to be erased. If value is a sequence of length 3, it is applied to R, G, B channels respectively. If value is a string ‘random’, the erase value will be obtained from a standard normal distribution.
inplace (bool, optional) – Apply this transform in-place (default=False).
max_attempts (int, optional) – The maximum number of attempts to propose a valid erase_area (default=10). If exceeded, return the original image.
Examples
>>> import mindspore.dataset.vision.py_transforms as py_vision >>> from mindspore.dataset.transforms.py_transforms import Compose >>> >>> Compose([py_vision.Decode(), >>> py_vision.ToTensor(), >>> py_vision.RandomErasing(value='random')])