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 or None) – Expected data type of the input tensor. Used for pipeline data-type validation; pass None to skip.

  • output_data_type (DataTypes or None) – Data type produced by this operation.

  • key (str or None) – Dict key the operation reads from (and writes to by default). Defaults to "data".

  • output_key (str or None) – Dict key the operation writes its result to. Defaults to key. Set to a different value to preserve the original input under key while producing a new key for downstream operations.

  • cache_inputs (bool) – When True, values stored via set_input_cache() are merged into every call. False means the cache is empty by default. Selective per-key caching is not supported; use set_input_cache() directly to control which keys are stored.

  • cache_outputs (bool) – Memoize outputs keyed by a hash of the merged inputs.

  • jit_compile (bool) – Wrap call() with jit() for faster execution. Disable for easier interactive debugging.

  • with_batch_dim (bool) – Whether inputs carry a leading batch dimension. Affects default axis selection in filter-type operations.

  • jit_kwargs (dict or None) – Extra keyword arguments forwarded to the JIT compiler.

  • jittable (bool) – Mark the operation as JIT-compilable. Set to False for operations that use Python control flow incompatible with tracing.

  • additional_output_keys (list of str or None) – Extra dict keys this operation may produce beyond output_key. Used for pipeline key-availability validation. Defaults to the class-level ADD_OUTPUT_KEYS list.

__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 and grain 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.