<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/models/blob/v2.20.0/official/vision/ops/augment.py#L2498-L2615) |

Applies RandomErasing to a single image.

Inherits From: [`ImageAugment`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/ImageAugment)

    tfm.vision.augment.RandomErasing(
        probability: float = 0.25,
        min_area: float = 0.02,
        max_area: float = (1 / 3),
        min_aspect: float = 0.3,
        max_aspect: Optional[float] = None,
        min_count=1,
        max_count=1,
        trials=10
    )

Reference: <https://arxiv.org/abs/1708.04896>

Implementation is inspired by
<https://github.com/rwightman/pytorch-image-models>

<br />

<br />

<br />

| ## Args ||
|---|---|
| `probability` | Probability of augmenting the image. Defaults to `0.25`. |
| `min_area` | Minimum area of the random erasing rectangle. Defaults to `0.02`. |
| `max_area` | Maximum area of the random erasing rectangle. Defaults to `1/3`. |
| `min_aspect` | Minimum aspect rate of the random erasing rectangle. Defaults to `0.3`. |
| `max_aspect` | Maximum aspect rate of the random erasing rectangle. Defaults to `None`. |
| `min_count` | Minimum number of erased rectangles. Defaults to `1`. |
| `max_count` | Maximum number of erased rectangles. Defaults to `1`. |
| `trials` | Maximum number of trials to randomly sample a rectangle that fulfills constraint. Defaults to `10`. |

<br />

## Methods

### `distort`

[View source](https://github.com/tensorflow/models/blob/v2.20.0/official/vision/ops/augment.py#L2541-L2553)

    distort(
        image: tf.Tensor
    ) -> tf.Tensor

Applies RandomErasing to single `image`.

<br />

<br />

<br />

| Args ||
|---|---|
| `image` | [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) <br /> Of shape \[height, width, 3\] representing an image. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) | The augmented version of `image`. |

<br />

### `distort_with_boxes`

[View source](https://github.com/tensorflow/models/blob/v2.20.0/official/vision/ops/augment.py#L1901-L1919)

    distort_with_boxes(
        image: tf.Tensor, bboxes: tf.Tensor
    ) -> Tuple[tf.Tensor, tf.Tensor]

Distorts the image and bounding boxes.

Expect the image tensor values are in the range \[0, 255\].

<br />

<br />

<br />

| Args ||
|---|---|
| `image` | `Tensor` of shape \[height, width, 3\] or \[num_frames, height, width, 3\] representing an image or image sequence. |
| `bboxes` | `Tensor` of shape \[num_boxes, 4\] or \[num_frames, num_boxes, 4\] representing bounding boxes for an image or image sequence. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| The augmented version of `image` and `bboxes`. ||

<br />