tfm.vision.preprocess_ops.random_crop_image_v2
Stay organized with collections
Save and categorize content based on your preferences.
Randomly crop an arbitrary shaped slice from the input image.
tfm.vision.preprocess_ops.random_crop_image_v2(
image_bytes,
image_shape,
aspect_ratio_range=(3.0 / 4.0, 4.0 / 3.0),
area_range=(0.08, 1.0),
max_attempts=10,
seed=1
)
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.
Args |
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.
|
Returns |
cropped_image
|
a Tensor representing the random cropped image. Can be the
original image if max_attempts is exhausted.
|
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.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
{"lastModified": "Last updated 2024-02-02 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 2024-02-02 UTC."],[],[]]