tfm.vision.preprocess_ops.random_horizontal_flip
Stay organized with collections
Save and categorize content based on your preferences.
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].
Args |
image
|
tf.Tensor, the image to apply the random flip, [h, w, channels].
|
normalized_boxes
|
tf.Tensor or None, boxes corresponding to the image.
|
masks
|
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.
|
Returns |
image
|
tf.Tensor, flipped image.
|
boxes
|
tf.Tensor or None, flipped normalized boxes corresponding to the
image.
|
masks
|
tf.Tensor or None, flipped masks corresponding to the image.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2026-11-06 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-11-06 UTC."],[],[]]