sleap.nn.data.augmentation

Transformers for applying data augmentation.

class sleap.nn.data.augmentation.ImgaugAugmenter(augmenter: imgaug.augmenters.meta.Sequential)[source]

Data transformer based on the imgaug library.

This class can generate a tf.data.Dataset from an existing one that generates image and instance data. Element of the output dataset will have a set of augmentation transformations applied.

augmenter

An instance of imgaug.augmenters.Sequential that will be applied to each element of the input dataset.

classmethod from_config(config: sleap.nn.config.optimization.AugmentationConfig)sleap.nn.data.augmentation.ImgaugAugmenter[source]

Create an augmenter from a set of configuration parameters.

Parameters

config – An AugmentationConfig instance with the desired parameters.

Returns

An instance of this class with the specified augmentation configuration.

property input_keys

Return the keys that incoming elements are expected to have.

property output_keys

Return the keys that outgoing elements will have.

transform_dataset(input_ds: tensorflow.python.data.ops.dataset_ops.DatasetV2) → tensorflow.python.data.ops.dataset_ops.DatasetV2[source]

Create a tf.data.Dataset with elements containing augmented data.

Parameters

input_ds – A dataset with elements that contain the keys “image” and “instances”. This is typically raw data from a data provider.

Returns

A tf.data.Dataset with the same keys as the input, but with images and instance points updated with the applied augmentations.

Notes

The “scale” key in examples are not modified when scaling augmentation is applied.