<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) |

Augmentation policies for enhanced image/video preprocessing.

#### AutoAugment Reference:

- AutoAugment Reference: <https://arxiv.org/abs/1805.09501>
- AutoAugment for Object Detection Reference: <https://arxiv.org/abs/1906.11172>

RandAugment Reference: <https://arxiv.org/abs/1909.13719>
RandomErasing Reference: <https://arxiv.org/abs/1708.04896>
MixupAndCutmix:

- Mixup: <https://arxiv.org/abs/1710.09412>
- Cutmix: <https://arxiv.org/abs/1905.04899>

RandomErasing, Mixup and Cutmix are inspired by
<https://github.com/rwightman/pytorch-image-models>

#### SSDRandCrop Reference:

- Liu et al., SSD: Single shot multibox detector: <https://arxiv.org/abs/1512.02325>
- Implementation from TF Object Detection API: <https://github.com/tensorflow/models/>

## Classes

[`class AutoAugment`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/AutoAugment): Applies the AutoAugment policy to images.

[`class ImageAugment`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/ImageAugment): Image augmentation class for applying image distortions.

[`class MixupAndCutmix`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/MixupAndCutmix): Applies Mixup and/or Cutmix to a batch of images.

[`class RandAugment`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/RandAugment): Applies the RandAugment policy to images.

[`class RandomErasing`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/RandomErasing): Applies RandomErasing to a single image.

[`class SSDRandomCrop`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/SSDRandomCrop): Random crop preprocessing as in the SSD paper.

[`class Sequence`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/Sequence): All the operations on a read-only sequence.

## Functions

[`autocontrast(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/autocontrast): Implements Autocontrast function from PIL using TF ops.

[`bbox_wrapper(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/bbox_wrapper): Adds a bboxes function argument to func and returns unchanged bboxes.

[`blend(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/blend): Blend image1 and image2 using 'factor'.

[`brightness(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/brightness): Equivalent of PIL Brightness.

[`color(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/color): Equivalent of PIL Color.

[`contrast(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/contrast): Equivalent of PIL Contrast.

[`crop_normalized_boxes(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/crop_normalized_boxes): Crop normalized boxes.

[`cutout(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/cutout): Apply cutout (<https://arxiv.org/abs/1708.04552>) to image.

[`cutout_video(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/cutout_video): Apply cutout (<https://arxiv.org/abs/1708.04552>) to a video.

[`equalize(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/equalize): Implements Equalize function from PIL using TF ops.

[`filter_boxes_by_ioa(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/filter_boxes_by_ioa): Filter boxes by intersection over area (IOA).

[`from_4d(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/from_4d): Converts a 4D image back to `ndims` rank.

[`gaussian_filter2d(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/gaussian_filter2d): Performs Gaussian blur on image(s).

[`gaussian_noise(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/gaussian_noise): Add Gaussian noise to image(s).

[`grayscale(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/grayscale): Convert image to grayscale.

[`invert(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/invert): Inverts the image pixels.

[`level_to_arg(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/level_to_arg): Creates a dict mapping image operation names to their arguments.

[`posterize(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/posterize): Equivalent of PIL Posterize.

[`rotate(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/rotate): Rotates the image by degrees either clockwise or counterclockwise.

[`rotate_with_bboxes(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/rotate_with_bboxes): Equivalent of PIL Rotate that rotates the image and bbox.

[`select_and_apply_random_policy(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/select_and_apply_random_policy): Select a random policy from `policies` and apply it to `image`.

[`sharpness(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/sharpness): Implements Sharpness function from PIL using TF ops.

[`shear_with_bboxes(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/shear_with_bboxes): Applies Shear Transformation to the image and shifts the bboxes.

[`shear_x(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/shear_x): Equivalent of PIL Shearing in X dimension.

[`shear_y(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/shear_y): Equivalent of PIL Shearing in Y dimension.

[`solarize(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/solarize): Solarize the input image(s).

[`solarize_add(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/solarize_add): Additive solarize the input image(s).

[`to_4d(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/to_4d): Converts an input Tensor to 4 dimensions.

[`transform(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/transform): Transforms an image.

[`translate(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/translate): Translates image(s) by provided vectors.

[`translate_bbox(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/translate_bbox): Equivalent of PIL Translate in X/Y dimension that shifts image and bbox.

[`translate_x(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/translate_x): Equivalent of PIL Translate in X dimension.

[`translate_y(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/translate_y): Equivalent of PIL Translate in Y dimension.

[`translate_y_only_bboxes(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/translate_y_only_bboxes): Apply translate_y to each bbox in the image with probability prob.

[`unwrap(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/unwrap): Unwraps an image produced by wrap.

[`wrap(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/wrap): Returns 'image' with an extra channel set to all 1s.

[`wrapped_rotate(...)`](https://www.tensorflow.org/api_docs/python/tfm/vision/augment/wrapped_rotate): Applies rotation with wrap/unwrap.

<br />

<br />

<br />

| ## Other Members ||
|---|---|
| NAME_TO_FUNC | <br /> { 'AutoContrast': <function autocontrast>, 'Brightness': <function brightness>, 'Color': <function color>, 'Contrast': <function contrast>, 'Cutout': <function cutout>, 'Equalize': <function equalize>, 'Gaussian_Noise': <function gaussian_noise>, 'Grayscale': <function grayscale>, 'Invert': <function invert>, 'Posterize': <function posterize>, 'Rotate': <function wrapped_rotate>, 'Rotate_BBox': <function rotate_with_bboxes>, 'Sharpness': <function sharpness>, 'ShearX': <function shear_x>, 'ShearX_BBox': <function <lambda>>, 'ShearY': <function shear_y>, 'ShearY_BBox': <function <lambda>>, 'Solarize': <function solarize>, 'SolarizeAdd': <function solarize_add>, 'TranslateX': <function translate_x>, 'TranslateX_BBox': <function <lambda>>, 'TranslateY': <function translate_y>, 'TranslateY_BBox': <function <lambda>>, 'TranslateY_Only_BBoxes': <function translate_y_only_bboxes> } <br /> |
| PROB_FUNCS | <br /> { 'TranslateY_Only_BBoxes' } <br /> |
| REPLACE_FUNCS | <br /> { 'Cutout', 'Rotate', 'Rotate_BBox', 'ShearX', 'ShearX_BBox', 'ShearY', 'ShearY_BBox', 'TranslateX', 'TranslateX_BBox', 'TranslateY', 'TranslateY_BBox', 'TranslateY_Only_BBoxes' } <br /> |
| REQUIRE_BOXES_FUNCS | <br /> { 'Rotate_BBox', 'ShearX_BBox', 'ShearY_BBox', 'TranslateX_BBox', 'TranslateY_BBox', 'TranslateY_Only_BBoxes' } <br /> |

<br />