augmentations

Features that augment images

Augmentations are features that can resolve more than one image without calling .resolve() on the parent feature. Specifically, they create updates_per_reload images, while calling their parent feature load_size times.

Classes

Augmentation

Base abstract augmentation class.

PreLoad

Simple storage with no augmentation.

FlipLR

Flips images left-right.

FlipUD

Flips images up-down.

FlipDiagonal

Flips images diagonally.

Module classes

Augmentation

class deeptrack.augmentations.Augmentation(feature: deeptrack.features.Feature, load_size: int = 1, updates_per_reload: int = inf, update_properties: Callable = None, **kwargs)

Base abstract augmentation class.

Augmentations are features that can resolve more than one image without calling .resolve() on the parent feature. Specifically, they create updates_per_reload images, while calling their parent feature load_size times. They achieve this by resolving load_size results from the parent feature at once, and randomly drawing one of these results as input to the method .get(). A new input is chosen every time .update() is called. Once .update() has been called updated_per_reload times, a new batch of load_size results are resolved from the parent feature.

The method .get() of implementations of this class may accept the property number_of_updates as an argument. This number represents the number of times the .update() method has been called since the last time the parent feature was resolved.

Parameters
  • feature (Feature) – The parent feature.

  • load_size (int) – Number of results to resolve from the parent feature.

  • updates_per_reload (int) – Number of times .update() is called before resolving new results from the parent feature.

  • update_properties (Callable or None) – Function called on the output of the method .get(). Overrides the default behaviour, allowing full control over how to update the properties of the output to account for the augmentation.

Crop

class deeptrack.augmentations.Crop(*args, corner='random', crop_size=(64, 64), **kwargs)

Crops a regions of an image.

Parameters
  • feature (feature or list of features) – Feature(s) to augment.

  • corner (tuple of ints or Callable[Image] or "random") – Top left corner of the cropped region. Can be a tuple of ints,

get(image, corner, crop_size, **kwargs)

Method for altering an image Abstract method that define how the feature transforms the input. The current value of all properties will be passed as keyword arguments.

Parameters
  • image (Image or List[Image]) – The Image or list of images to transform

  • **kwargs – The current value of all properties in properties as well as any global arguments.

Returns

The transformed image or list of images

Return type

Image or List[Image]

FlipDiagonal

class deeptrack.augmentations.FlipDiagonal(*args, **kwargs)

Flips images along the main diagonal.

Updates all properties called “position” by swapping the first and second index.

get(image, number_of_updates, axes=(1, 0, 2), **kwargs)

Method for altering an image Abstract method that define how the feature transforms the input. The current value of all properties will be passed as keyword arguments.

Parameters
  • image (Image or List[Image]) – The Image or list of images to transform

  • **kwargs – The current value of all properties in properties as well as any global arguments.

Returns

The transformed image or list of images

Return type

Image or List[Image]

FlipLR

class deeptrack.augmentations.FlipLR(*args, **kwargs)

Flips images left-right.

Updates all properties called “position” to flip the second index.

get(image, number_of_updates, **kwargs)

Method for altering an image Abstract method that define how the feature transforms the input. The current value of all properties will be passed as keyword arguments.

Parameters
  • image (Image or List[Image]) – The Image or list of images to transform

  • **kwargs – The current value of all properties in properties as well as any global arguments.

Returns

The transformed image or list of images

Return type

Image or List[Image]

FlipUD

class deeptrack.augmentations.FlipUD(*args, **kwargs)

Flips images up-down.

Updates all properties called “position” by flipping the first index.

get(image, number_of_updates=0, **kwargs)

Method for altering an image Abstract method that define how the feature transforms the input. The current value of all properties will be passed as keyword arguments.

Parameters
  • image (Image or List[Image]) – The Image or list of images to transform

  • **kwargs – The current value of all properties in properties as well as any global arguments.

Returns

The transformed image or list of images

Return type

Image or List[Image]

PreLoad

class deeptrack.augmentations.PreLoad(feature: deeptrack.features.Feature, load_size: int = 1, updates_per_reload: int = inf, update_properties: Callable = None, **kwargs)

Simple storage with no augmentation.

get(image, **kwargs)

Method for altering an image Abstract method that define how the feature transforms the input. The current value of all properties will be passed as keyword arguments.

Parameters
  • image (Image or List[Image]) – The Image or list of images to transform

  • **kwargs – The current value of all properties in properties as well as any global arguments.

Returns

The transformed image or list of images

Return type

Image or List[Image]