Image augmentation that drags your bounding boxes along for the ride
It bulk-generates training variations by distorting images while keeping bounding boxes, heatmaps, and segmentation masks geometrically synchronized.

What it does
imgaug is a Python library that applies geometric and photometric distortions to images for machine learning training. It handles not just raw pixels but also the annotations that live on top of them—bounding boxes, keypoints, polygons, line strings, heatmaps, and segmentation maps—so a random rotation or crop does not silently invalidate your labels. The library is built around a batchwise pipeline that can distribute work across multiple CPU cores.
The interesting bit
The real workhorse is the automatic alignment of random sampling: when you apply an affine transform or a crop, the image and every associated mask or coordinate set are warped by the exact same sampled parameters without extra bookkeeping code. You can also pass probability distributions directly as arguments, so a single call might rotate images by values drawn from a clipped Gaussian or Beta distribution rather than a fixed range.
Key highlights
- Supports images, heatmaps, segmentation maps, masks, keypoints, bounding boxes, polygons, and line strings in the same pipeline.
- Associated data like heatmaps can be smaller or larger than the base image and still stay synchronized during crops or resizes.
- Augmentation parameters accept probability distributions (e.g.,
uniform,N(0, 20.0),Beta) instead of just scalar constants. - Includes utility functions for drawing annotations, clipping polygons to the image plane, extracting pixels inside bounding boxes, and padding to square aspect ratios.
- Runs augmentation across multiple CPU cores.
Caveats
- Full dtype support is only guaranteed for
uint8images; other dtypes require checking the documentation.
Verdict
Computer-vision practitioners building object-detection, segmentation, or keypoint models should look here if they need heavy augmentation without writing coordinate-transformation glue code. If you only need simple flips and brightness jitter for classification, lighter frameworks may be less overhead.
Frequently asked
- What is aleju/imgaug?
- It bulk-generates training variations by distorting images while keeping bounding boxes, heatmaps, and segmentation masks geometrically synchronized.
- Is imgaug open source?
- Yes — aleju/imgaug is open source, released under the MIT license.
- What language is imgaug written in?
- aleju/imgaug is primarily written in Python.
- How popular is imgaug?
- aleju/imgaug has 14.7k stars on GitHub.
- Where can I find imgaug?
- aleju/imgaug is on GitHub at https://github.com/aleju/imgaug.