imgaug is a Python library for image augmentation in machine learning experiments, particularly for deep neural networks. It supports a wide range of augmentation techniques for images, keypoints/landmarks, bounding boxes, heatmaps, and segmentation maps. The library allows for easy combination of augmenters into sequences, execution in random order or on multiple CPU cores, and provides a powerful stochastic interface. The current stable version is 0.4.0, with releases historically every few months, though the last release was in early 2020.
pip install imgaugVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to define a simple augmentation sequence using `iaa.Sequential` and apply it to an image. It includes common transformations like flipping, blurring, and affine transformations. Images are expected as NumPy arrays (H, W, C) for a single image or (N, H, W, C) for a batch, typically with `uint8` dtype and pixel values in `0-255` range.
Update class names (singular to plural), method calls, and ensure segmentation maps are `int32` arrays. Refer to official documentation for `SegmentationMapsOnImage`.
Ensure image data conforms to the expected NumPy array shape and dtype. For a single image, wrap it in a list: `seq(images=[my_image])`.
If you intend to augment a batch of single-channel images (e.g., masks), use `augment_images()` (plural form) instead of `augment_image()`.
Wrap your keypoints, bounding boxes, etc., in the appropriate `imgaug.augmentables` classes before passing them to the augmenter sequence.
Implement custom logic to clip, drop, or adjust keypoints/bounding boxes that fall outside the image dimensions after augmentation, based on your specific application requirements.