Class SampleDistortedBoundingBox<T extends TNumber>
- All Implemented Interfaces:
Op
image_size,
bounding_boxes and a series of constraints.
The output of this Op is a single bounding box that may be used to crop the
original image. The output is returned as 3 tensors: begin, size and
bboxes. The first 2 tensors can be fed directly into tf.slice to crop the
image. The latter may be supplied to tf.image.draw_bounding_boxes to visualize
what the bounding box looks like.
Bounding boxes are supplied and returned as [y_min, x_min, y_max, x_max]. The
bounding box coordinates are floats in [0.0, 1.0] relative to the width and
height of the underlying image.
For example,
# Generate a single distorted bounding box.
begin, size, bbox_for_draw = tf.image.sample_distorted_bounding_box(
tf.shape(image),
bounding_boxes=bounding_boxes)
# Draw the bounding box in an image summary.
image_with_box = tf.image.draw_bounding_boxes(tf.expand_dims(image, 0),
bbox_for_draw)
tf.summary.image('images_with_box', image_with_box)
# Employ the bounding box to distort the image.
distorted_image = tf.slice(image, begin, size)
Note that if no bounding box information is available, setting
use_image_if_no_bounding_boxes = true will assume there is a single implicit
bounding box covering the whole image. If use_image_if_no_bounding_boxes is
false and no bounding boxes are supplied, an error is raised.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSampleDistortedBoundingBox.Inputs<T extends TNumber>static classOptional attributes forSampleDistortedBoundingBox -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe name of this op, as known by TensorFlow core engine -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSets the areaRange option.Sets the areaRange option.aspectRatioRange(Float... aspectRatioRange) Sets the aspectRatioRange option.aspectRatioRange(List<Float> aspectRatioRange) Sets the aspectRatioRange option.bboxes()Gets bboxes. 3-D with shape[1, 1, 4]containing the distorted bounding box.begin()Gets begin. 1-D, containing[offset_height, offset_width, 0].static <T extends TNumber>
SampleDistortedBoundingBox<T> create(Scope scope, Operand<T> imageSize, Operand<TFloat32> boundingBoxes, Operand<TFloat32> minObjectCovered, SampleDistortedBoundingBox.Options... options) Factory method to create a class wrapping a new SampleDistortedBoundingBoxV2 operation.maxAttempts(Long maxAttempts) Sets the maxAttempts option.Sets the seed option.Sets the seed2 option.Gets sizeOutput. 1-D, containing[target_height, target_width, -1].useImageIfNoBoundingBoxes(Boolean useImageIfNoBoundingBoxes) Sets the useImageIfNoBoundingBoxes option.
-
Field Details
-
OP_NAME
The name of this op, as known by TensorFlow core engine- See Also:
-
-
Constructor Details
-
SampleDistortedBoundingBox
-
-
Method Details
-
create
@Endpoint(describeByClass=true) public static <T extends TNumber> SampleDistortedBoundingBox<T> create(Scope scope, Operand<T> imageSize, Operand<TFloat32> boundingBoxes, Operand<TFloat32> minObjectCovered, SampleDistortedBoundingBox.Options... options) Factory method to create a class wrapping a new SampleDistortedBoundingBoxV2 operation.- Type Parameters:
T- data type forSampleDistortedBoundingBoxV2output and operands- Parameters:
scope- current scopeimageSize- 1-D, containing[height, width, channels].boundingBoxes- 3-D with shape[batch, N, 4]describing the N bounding boxes associated with the image.minObjectCovered- The cropped area of the image must contain at least this fraction of any bounding box supplied. The value of this parameter should be non-negative. In the case of 0, the cropped area does not need to overlap any of the bounding boxes supplied.options- carries optional attribute values- Returns:
- a new instance of SampleDistortedBoundingBox
-
seed
Sets the seed option.- Parameters:
seed- If eitherseedorseed2are set to non-zero, the random number generator is seeded by the givenseed. Otherwise, it is seeded by a random seed.- Returns:
- this Options instance.
-
seed2
Sets the seed2 option.- Parameters:
seed2- A second seed to avoid seed collision.- Returns:
- this Options instance.
-
aspectRatioRange
Sets the aspectRatioRange option.- Parameters:
aspectRatioRange- The cropped area of the image must have an aspect ratio = width / height within this range.- Returns:
- this Options instance.
-
aspectRatioRange
Sets the aspectRatioRange option.- Parameters:
aspectRatioRange- The cropped area of the image must have an aspect ratio = width / height within this range.- Returns:
- this Options instance.
-
areaRange
Sets the areaRange option.- Parameters:
areaRange- The cropped area of the image must contain a fraction of the supplied image within this range.- Returns:
- this Options instance.
-
areaRange
Sets the areaRange option.- Parameters:
areaRange- The cropped area of the image must contain a fraction of the supplied image within this range.- Returns:
- this Options instance.
-
maxAttempts
Sets the maxAttempts option.- Parameters:
maxAttempts- Number of attempts at generating a cropped region of the image of the specified constraints. Aftermax_attemptsfailures, return the entire image.- Returns:
- this Options instance.
-
useImageIfNoBoundingBoxes
public static SampleDistortedBoundingBox.Options useImageIfNoBoundingBoxes(Boolean useImageIfNoBoundingBoxes) Sets the useImageIfNoBoundingBoxes option.- Parameters:
useImageIfNoBoundingBoxes- Controls behavior if no bounding boxes supplied. If true, assume an implicit bounding box covering the whole input. If false, raise an error.- Returns:
- this Options instance.
-
begin
-
sizeOutput
-
bboxes
-