tfm.vision.preprocess_ops.resize_and_crop_image_v2
Resizes the input image to output size (Faster R-CNN style).
tfm.vision.preprocess_ops.resize_and_crop_image_v2(
image,
short_side,
long_side,
padded_size,
aug_scale_min=1.0,
aug_scale_max=1.0,
seed=1,
method=tf.image.ResizeMethod.BILINEAR
)
Resize and pad images given the specified short / long side length and the
stride size.
Here are the preprocessing steps.
- For a given image, keep its aspect ratio and first try to rescale the short
side of the original image to
short_side
.
- If the scaled image after 1 has a long side that exceeds
long_side
, keep
the aspect ratio and rescale the long side of the image to long_side
.
- (Optional) Apply random jittering according to
aug_scale_min
and
aug_scale_max
. By default this step is skipped.
- Pad the rescaled image to the padded_size.
Args |
image
|
a Tensor of shape [height, width, 3] representing an image.
|
short_side
|
a scalar Tensor or int representing the desired short side
to be rescaled to.
|
long_side
|
a scalar Tensor or int representing the desired long side to
be rescaled to.
|
padded_size
|
a Tensor or int list/tuple of two elements representing
[height, width] of the padded output image size.
|
aug_scale_min
|
a float with range between [0, 1.0] representing minimum
random scale applied for training scale jittering.
|
aug_scale_max
|
a float with range between [1.0, inf] representing maximum
random scale applied for training scale jittering.
|
seed
|
seed for random scale jittering.
|
method
|
function to resize input image to scaled image.
|
Returns |
output_image
|
Tensor of shape [height, width, 3] where [height, width]
equals to output_size .
|
image_info
|
a 2D Tensor that encodes the information of the image and the
applied preprocessing. It is in the format of
[[original_height, original_width], [desired_height, desired_width],
[y_scale, x_scale], [y_offset, x_offset]], where [desired_height,
desired_width] is the actual scaled image size, and [y_scale, x_scale] is
the scaling factor, which is the ratio of
scaled dimension / original dimension.
|
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 2024-02-02 UTC.
[null,null,["Last updated 2024-02-02 UTC."],[],[]]