tfm.vision.preprocess_ops.random_crop_image_v2

Randomly crop an arbitrary shaped slice from the input image.

This is a faster version of random_crop_image which takes the original image bytes and image size as the inputs, and partially decode the JPEG bytes according to the generated crop.

image_bytes a Tensor of type string representing the raw image bytes.
image_shape a Tensor specifying the shape of the raw image.
aspect_ratio_range a list of floats. The cropped area of the image must have an aspect ratio = width / height within this range.
area_range a list of floats. The cropped reas of the image must contain a fraction of the input image within this range.
max_attempts the number of attempts at generating a cropped region of the image of the specified constraints. After max_attempts failures, return the entire image.
seed the seed of the random generator.

cropped_image a Tensor representing the random cropped image. Can be the original image if max_attempts is exhausted.