zea.data.layers

Keras layers for data preprocessing.

Classes

Pad(target_shape[, uniform, axis, ...])

Pad layer for padding tensors to a specified shape which can be used in tf.data pipelines.

Resizer(image_size, resize_type[, ...])

Resize layer for resizing images.

class zea.data.layers.Pad(target_shape, uniform=True, axis=None, fail_on_bigger_shape=True, pad_kwargs=None, **kwargs)[source]

Bases: Pad

Pad layer for padding tensors to a specified shape which can be used in tf.data pipelines.

Parameters:
  • input_data_type (DataTypes) – The data type of the input data

  • output_data_type (DataTypes) – The data type of the output data

  • key – The key for the input data (operation will operate on this key) Defaults to “data”.

  • output_key – The key for the output data (operation will output to this key) Defaults to the same as the input key. If you want to store intermediate results, you can set this to a different key. But make sure to update the input key of the next operation to match the output key of this operation.

  • cache_inputs – A list of input keys to cache or True to cache all inputs

  • cache_outputs – A list of output keys to cache or True to cache all outputs

  • jit_compile – Whether to JIT compile the ‘call’ method for faster execution

  • with_batch_dim – Whether operations should expect a batch dimension in the input

  • jit_kwargs – Additional keyword arguments for the JIT compiler

  • jittable – Whether the operation can be JIT compiled

  • additional_output_keys – A list of additional output keys produced by the operation. These are used to track if all keys are available for downstream operations. If the operation has a conditional output, it is best to add all possible output keys here.

__call__(inputs, **kwargs)

Process the input keyword arguments and return the processed results.

Parameters:

kwargs – Keyword arguments to be processed.

Returns:

Combined input and output as kwargs.

call(inputs)[source]

Pad the input tensor.

class zea.data.layers.Resizer(image_size, resize_type, resize_axes=None, seed=None, **resize_kwargs)[source]

Bases: DataLayer

Resize layer for resizing images. Can deal with N-dimensional images. Can do resize, center_crop, random_crop and crop_or_pad.

Can be used in tf.data pipelines.

Initializes the data loader with the specified parameters.

Parameters:
Raises:
  • ValueError – If an unsupported resize type is provided.

  • AssertionError – If resize_axes is not of length 2.

call(inputs)[source]

Resize the input tensor.