zea.data.layers¶
Keras layers for data preprocessing.
Classes
|
Pad layer for padding tensors to a specified shape which can be used in tf.data pipelines. |
|
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:
PadPad 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
Noneto 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 underkeywhile producing a new key for downstream operations.cache_inputs (bool) – When
True, values stored viaset_input_cache()are merged into every call.Falsemeans the cache is empty by default. Selective per-key caching is not supported; useset_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()withjit()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
Falsefor 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-levelADD_OUTPUT_KEYSlist.
- __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.
- class zea.data.layers.Resizer(image_size, resize_type, resize_axes=None, seed=None, **resize_kwargs)[source]¶
Bases:
DataLayerResize 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:
image_size (
tuple) – The target size of the images.resize_type (
str) – The type of resizing to apply. Supported types are [‘center_crop’](https://keras.io/api/layers/preprocessing_layers/image_preprocessing/center_crop/), [‘random_crop’](https://keras.io/api/layers/preprocessing_layers/image_augmentation/random_crop/), [‘resize’](https://keras.io/api/layers/preprocessing_layers/image_preprocessing/resizing/), ‘crop_or_pad’: resizes an image to a target width and height by either centrally cropping the image, padding it evenly with zeros or a combination of both.resize_axes (
tuple|None) – The axes along which to resize. Must be of length 2. Defaults to None. In that case, can only process default tensors of shape (batch, height, width, channels), where the resize axes are (1, 2), i.e. height and width. If processing higher dimensional tensors, you must specify the resize axes.seed (
int|None) – Random seed for reproducibility. Defaults to None.**resize_kwargs – Additional keyword arguments for the resizing operation.
- Raises:
ValueError – If an unsupported resize type is provided.
AssertionError – If resize_axes is not of length 2.