RandomErasing¶
- class paddle.vision.transforms. RandomErasing ( prob=0.5, scale=(0.02, 0.33), ratio=(0.3, 3.3), value=0, inplace=False, keys=None ) [source]
-
Erase the pixels in a rectangle region selected randomly.
- Parameters
-
prob (float, optional) – Probability of the input data being erased. Default: 0.5.
scale (sequence, optional) – The proportional range of the erased area to the input image. Default: (0.02, 0.33).
ratio (sequence, optional) – Aspect ratio range of the erased area. Default: (0.3, 3.3).
value (int|float|sequence|str, optional) – The value each pixel in erased area will be replaced with. If value is a single number, all pixels will be erased with this value. If value is a sequence with length 3, the R, G, B channels will be ereased respectively. If value is set to “random”, each pixel will be erased with random values. Default: 0.
inplace (bool, optional) – Whether this transform is inplace. Default: False.
keys (list[str]|tuple[str], optional) – Same as
BaseTransform
. Default: None.
- Shape:
-
-
- img(paddle.Tensor | np.array | PIL.Image): The input image. For Tensor input, the shape should be (C, H, W).
-
For np.array input, the shape should be (H, W, C).
output(paddle.Tensor | np.array | PIL.Image): A random erased image.
-
- Returns
-
A callable object of RandomErasing.
Examples
import paddle fake_img = paddle.randn((3, 10, 10)).astype(paddle.float32) transform = paddle.vision.transforms.RandomErasing() result = transform(fake_img) print(result)