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) – 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.
- 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 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.