API - Utilsο
Augmentationο
- augmentation.blend(images_2, factors, value_range=None)ο
Blend image1 and image2 using βfactorsβ. Can be batched inputs.
Factor can be above
0.0. A value of0.0means only image1 is used. A value of1.0means only image2 is used. A value between0.0and1.0means we linearly interpolate the pixel values between the two images. A value greater than1.0βextrapolatesβ the difference between the two pixel values. Ifvalue_rangeis set, the results will be clipped intovalue_range- Parameters:
image1 (tf.Tensor) β First image(s).
image2 (tf.Tensor) β Second image(s).
factor (float|tf.Tensor) β The blend factor(s).
value_range (Sequence[int|float], optional) β The value range of the results. Defaults to
None.
References
- augmentation.rgb_to_grayscale()ο
Converts images from RGB to Grayscale.
Compared to
tf.image.rgb_to_grayscale, this function replacestf.tensordotwithtf.math.multiplyandtf.math.addto reduce memory usage.- Parameters:
images (tf.Tensor) β The RGB tensor to convert. The last dimension must have size 3 and should contain RGB values.
References
- augmentation.get_rotation_matrix(image_height, image_width, to_square=False, name=None)ο
Returns projective transforms for the given angles.
- Parameters:
angles (tf.Tensor) β a vector with the angles to rotate each image in the batch.
image_height (tf.Tensor) β Height of the images to be transformed.
image_width (tf.Tensor) β Width of the images to be transformed.
to_square (bool, optional) β Whether to append ones to last dimension and reshape to
(batch_size, 3, 3). Defaults toFalse.name (str, optional) β The name of the op. Defaults to
None.
References
- augmentation.get_translation_matrix(image_height, image_width, to_square=False, name=None)ο
Returns projective transforms for the given translations.
- Parameters:
translations (tf.Tensor) β A matrix of 2-element lists representing
[dx, dy]to translate for a batch of images.image_height (tf.Tensor) β Height of the images to be transformed.
image_width (tf.Tensor) β Width of the images to be transformed.
to_square (bool, optional) β Whether to append ones to last dimension and reshape to
(batch_size, 3, 3). Defaults toFalse.name (str, optional) β The name of the op. Defaults to
None.
References
- augmentation.get_zoom_matrix(image_height, image_width, to_square=False, name=None)ο
Returns projective transforms for the given zooms.
- Parameters:
zooms (tf.Tensor) β A matrix of 2-element lists representing
[zx, zy]to zoom for a batch of images.image_height (tf.Tensor) β Height of the images to be transformed.
image_width (tf.Tensor) β Width of the images to be transformed.
to_square (bool, optional) β Whether to append ones to last dimension and reshape to
(batch_size, 3, 3). Defaults toFalse.name (str, optional) β The name of the op. Defaults to
None.
References
- augmentation.get_shear_matrix(to_square=False, name=None)ο
Returns projective transforms for the given shears.
- Parameters:
shears (tf.Tensor) β A matrix of 2-element lists representing [sx, sy] to shear for a batch of images.
to_square (bool, optional) β Whether to append ones to last dimension and reshape to
(batch_size, 3, 3). Defaults toFalse.name (str, optional) β The name of the op. Defaults to
None.
References
- augmentation.is_factor_working(not_working_value=0.0)ο
Check whether
factoris working or not.- Parameters:
factor (int|float|Sequence[int|float]|keras_aug.FactorSampler) β The factor to check whether it is working or not.
not_working_value (float, optional) β The value indicating not working status. Defaults to
0.0.
- augmentation.get_images_shape(dtype=tf.int32)ο
Get
heightsandwidthsof the input images.Input images can be
tf.Tensorortf.RaggedTensorwith the shape of [B, H|None, W|None, C].- Parameters:
images (tf.Tensor|tf.RaggedTensor) β The input images.
dtype (tf.dtypes.DType, optional) β The dtype of the outputs. Defaults to
tf.int32.
Bounding Boxο
- bounding_box.sanitize_bounding_boxes(min_size=None, min_area_ratio=None, max_aspect_ratio=None, bounding_box_format=None, reference_bounding_boxes=None, images=None, reference_images=None)ο
Sanitize bounding boxes by min_size, min_area_ratio and max_aspect_ratio.
- Parameters:
bounding_boxes (dict[str, tf.Tensor]) β The bounding boxes to sanitize.
min_size (float, optional) β The minimum size of the bounding boxes.
min_area_ratio (float, optional) β The minimum area ratio of original bounding boxes to bounding boxes for sanitizing. Defaults to
None.max_aspect_ratio (float, optional) β The maximum aspect ratio of bounding boxes for sanitizing. Defaults to
None.bounding_box_format (str, optional) β The format of bounding boxes of input dataset. Refer https://github.com/keras-team/keras-cv/blob/master/keras_cv/bounding_box/converters.py for more details on supported bounding box formats.
reference_bounding_boxes (dict[str, tf.Tensor], optional) β The reference bounding boxes when apply sanitizing with min_area_ratio enabled. Defaults to
None.images (tf.Tensor, optional) β The images for bounding boxes format conversion.
reference_images (tf.Tensor, optional) β The reference images for reference bounding boxes format conversion.
References