aleju /imgaug

Image augmentation for machine learning experiments.

★ 14,738⑂ 2,444
PythonCreated 2015-07-10imgaug.readthedocs.io
14,738
stars
+4+4+-6
2,444
forks
–
watchers
–
prs
–
issues
–
releases
–
discussions

README

imgaug

This python library helps you with augmenting images for your machine learning projects.
It converts a set of input images into a new, much larger set of slightly altered images.








 
Image
Heatmaps
Seg. Maps
Keypoints
Bounding Boxes,Polygons




Original Input









Gauss. Noise+ Contrast+ Sharpen









Affine









Crop+ Pad









Fliplr+ Perspective










More (strong) example augmentations of one input image:

!64 quokkas


 Table of Contents

1. Features
2. Installation
3. Documentation
4. Recent Changes
5. Example Images
6. Code Examples
7. Citation




 Features

 Many augmentation techniques
   E.g. affine transformations, perspective transformations, contrast changes, gaussian noise, dropout of regions, hue/saturation changes, cropping/padding, blurring, ...
   Optimized for high performance
   Easy to apply augmentations only to some images
   Easy to apply augmentations in random order
 Support for
   Images (full support for uint8, for other dtypes see documentation)
   Heatmaps (float32), Segmentation Maps (int), Masks (bool)
     May be smaller/larger than their corresponding images. No extra lines of code needed for e.g. crop.
   Keypoints/Landmarks (int/float coordinates)
   Bounding Boxes (int/float coordinates)
   Polygons (int/float coordinates)
   Line Strings (int/float coordinates)
 Automatic alignment of sampled random values
   Example: Rotate image and segmentation map on it by the same value sampled from uniform(-10°, 45°). (0 extra lines of code.)
 Probability distributions as parameters
   Example: Rotate images by values sampled from uniform(-10°, 45°).
   Example: Rotate images by values sampled from ABS(N(0, 20.0))(1+B(1.0, 1.0))", where ABS(.) is the absolute function, N(.) the gaussian distribution and B(.) the beta distribution.
 Many helper functions
   Example: Draw heatmaps, segmentation maps, keypoints, bounding boxes, ...
   Example: Scale segmentation maps, average/max pool of images/maps, pad images to aspect
    ratios (e.g. to square them)
   Example: Convert keypoints to distance maps, extract pixels within bounding boxes from images, clip polygon to the image plane, ...
 Support for augmentation on multiple CPU cores




 Installation

The library supports python 2.7 and 3.4+.

 Installation: Anaconda

To install the library in anaconda, perform the following commands:
bash
conda config --add channels conda-forge
conda install imgaug


You can deinstall the library again via conda remove imgaug.

 Installation: pip

Then install imgaug either via pypi (can lag behind the github version):
bash
pip install imgaug


or install the latest version directly from github:
bash
pip install git+https://github.com/aleju/imgaug.git


For more details, see the install guide

To deinstall the library, just execute pip uninstall imgaug.




 Documentation

Example jupyter notebooks:
   Load and Augment an Image
   Multicore Augmentation
   Augment and work with: K

Snapshot: 2026-11-10T09:35:25Z · Data license Apache-2.0 · JSON