Augmentation engines and custom transforms for LDF samples.
This package provides the augmentation interface used by LuxonisLoader.
The default implementation is AlbumentationsEngine, which adapts LDF labels
to Albumentations targets before transformation and converts them back after
transformation.
Augmentation configuration is a list of records. Each record contains a
name identifying an Albumentations transform or a transform registered in
TRANSFORMATIONS, optional params, optional use_for_resizing, and
optional stage filtering through apply_on_stages. When
apply_on_stages is omitted, the transform applies to "train".
[
{"name": "HorizontalFlip", "params": {"p": 0.5}},
{
"name": "Mosaic4",
"params": {"height": 640, "width": 640, "p": 1.0},
},
]The engine groups transforms by behavior rather than preserving the exact input order:
Resize handling is part of the engine. A transform marked with
use_for_resizing is used as the resize stage; otherwise the engine falls
back to a regular resize or LetterboxResize, depending on the loader's
aspect-ratio setting. If the selected resize transform has probability
p < 1, it stays in the resize stage and the remaining probability mass is
filled by the default resize in an always-on OneOf. The resize stage is
applied before pixel-only transforms when downscaling saves work, and after
pixel-only transforms when upscaling or preserving size.
Standard Albumentations flip transforms such as HorizontalFlip,
VerticalFlip, and Transpose flip keypoint coordinates but do not swap
semantic left/right keypoint labels. For symmetric keypoint structures, use the
Luxonis custom transforms HorizontalSymmetricKeypointsFlip,
VerticalSymmetricKeypointsFlip, and TransposeSymmetricKeypoints.
Batch transforms multiply the number of source samples required by the loader.
For example, a pipeline that contains MixUp and Mosaic4 requires
8β=β2β
4 samples for each augmented output.
Custom augmentation engines can be added by subclassing AugmentationEngine.
Subclasses are automatically registered in AUGMENTATION_ENGINES.
Custom Transforms
Custom transforms follow Albumentations conventions. Subclass an appropriate
base class such as DualTransform or ImageOnlyTransform, implement the
target methods needed by your labels, register the class in
luxonis_ml.data.augmentations.custom.TRANSFORMATIONS, and reference the
class name in loader configuration.
from albumentations import DualTransform from luxonis_ml.data.augmentations.custom import TRANSFORMATIONS class CustomTransform(DualTransform): def apply(self, image, **kwargs): return image def apply_to_mask(self, mask, **kwargs): return mask def apply_to_bboxes(self, bboxes, **kwargs): return bboxes def apply_to_keypoints(self, keypoints, **kwargs): return keypoints TRANSFORMATIONS.register(module=CustomTransform) augmentation_config = [ {"name": "CustomTransform", "params": {"p": 1.0}}, ]
Engine Interface
A custom engine should subclass AugmentationEngine and implement:
- __init__ to consume output size, class count, configuration, aspect-ratio behavior, pipeline stage, and target metadata;
- apply to transform a batch of images and labels and return the transformed values;
- batch_size to tell
LuxonisLoaderhow many source samples are needed per augmented output.
| Module | albumentations |
No module docstring; 0/2 type alias, 1/1 class documented |
| Module | base |
Undocumented |
| Module | batch |
Undocumented |
| Module | batch |
Undocumented |
| Package | custom |
Built-in custom Albumentations transforms. |
| Module | utils |
Utilities for adapting LDF annotations to Albumentations. |
From __init__.py:
| Class | |
Augmentation engine backed by Albumentations. |
| Class | |
No class docstring; 1/1 property, 2/2 methods documented |
| Class | |
Compose batch-aware Albumentations transforms. |
| Class | |
Base class for transforms that combine multiple samples. |
| Constant | AUGMENTATION |
Registry for augmentation engines. |