<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/preprocess_ops.py#L798-L840) |

Randomly flips input image and bounding boxes and/or masks horizontally.

    tfm.vision.preprocess_ops.random_horizontal_flip(
        image, normalized_boxes=None, masks=None, seed=1, prob=0.5
    )

Expects input tensors without the batch dimension; i.e. for RGB image assume
rank-3 input like \[h, w, c\], for masks assume either \[h, w, 1\] or \[1, h, w\].

<br />

<br />

<br />

| ## Args ||
|---|---|
| `image` | [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor), the image to apply the random flip, \[h, w, channels\]. |
| `normalized_boxes` | [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) or `None`, boxes corresponding to the image. |
| `masks` | [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) or `None`, masks corresponding to the image, \[h, w, 1\] or \[1, h, w\]. |
| `seed` | Seed for Tensorflow's random number generator. |
| `prob` | A float from 0 to 1 indicating the probability of flipping the input horizontally. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| `image` | [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor), flipped image. |
| `boxes` | [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) or `None`, flipped normalized boxes corresponding to the image. |
| `masks` | [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) or `None`, flipped masks corresponding to the image. |

<br />