tf.keras.layers.Solarization

Applies (max_value - pixel + min_value) for each pixel in the image.

Inherits From: Layer, Operation

When created without threshold parameter, the layer performs solarization to all values. When created with specified threshold the layer only augments pixels that are above the threshold value.

addition_factor (Optional) A tuple of two floats or a single float, between 0 and 1. For each augmented image a value is sampled from the provided range. If a float is passed, the range is interpreted as (0, addition_factor). If specified, this value (times the value range of input images, e.g. 255), is added to each pixel before solarization and thresholding. Defaults to 0.0.
threshold_factor (Optional) A tuple of two floats or a single float. For each augmented image a value is sampled from the provided range. If a float is passed, the range is interpreted as (0, threshold_factor). If specified, only pixel values above this threshold will be solarized.
value_range a tuple or a list of two elements. The first value represents the lower bound for values in input images, the second represents the upper bound. Images passed to the layer should have values within value_range. Typical values to pass are (0, 255) (RGB image) or (0., 1.) (scaled image).
seed Integer. Used to create a random seed.
**kwargs Base layer keyword arguments, such as name and dtype.

Example:

(images, labels), _ = keras.datasets.cifar10.load_data()
print(images[0, 0, 0])
# [59 62 63]
# Note that images are Tensor with values in the range [0, 255]
solarization = Solarization(value_range=(0, 255))
images = solarization(images)
print(images[0, 0, 0])
# [196, 193, 192]

input Retrieves the input tensor(s) of a symbolic operation.

Only returns the tensor(s) corresponding to the first time the operation was called.

output Retrieves the output tensor(s) of a layer.

Only returns the tensor(s) corresponding to the first time the operation was called.

Methods

convert_weight

View source

Convert the weight if it is from the a different backend.

from_config

View source

Creates an operation from its config.

This method is the reverse of get_config, capable of instantiating the same operation from the config dictionary.

if "dtype" in config and isinstance(config["dtype"], dict):
    policy = dtype_policies.deserialize(config["dtype"])

Args
config A Python dictionary, typically the output of get_config.

Returns
An operation instance.

get_random_transformation

View source

transform_bounding_boxes

View source

transform_images

View source

transform_labels

View source

transform_segmentation_masks

View source

transform_single_bounding_box

View source

transform_single_image

View source

transform_single_label

View source

transform_single_segmentation_mask

View source