batchgenerators
Data augmentation toolkit
What it is and what it does
batchgenerators is a data augmentation framework developed by the Medical Image Computing division at DKFZ for preparing training data in deep learning pipelines. It specializes in augmentations that work uniformly on both 2D and 3D image data—a capability the documentation notes was missing in most competing frameworks. The package provides spatial transforms (mirroring, elastic deformation, rotation, scaling, resampling), color adjustments (brightness, contrast, gamma), noise injection (Gaussian, Rician), and cropping operations, plus specialized augmentations for medical imaging such as anatomy-informed deformations and multi-modal misalignment simulation.
The typical workflow involves subclassing a DataLoaderBase, implementing a generate_train_batch method to stack transforms using the Compose utility, and then feeding the result into MultiThreadedAugmenter for parallel augmentation across multiple processes. Data flows through the pipeline as a simple Python dictionary with required 'data' and optional 'seg' keys; spatial transforms automatically apply to segmentation masks when present. The package depends on numpy, scipy, scikit-image, scikit-learn, pillow, and pandas for its core operations.
Use it for:
- Augment 3D medical imaging datasets for segmentation tasks while ensuring spatial transforms apply to both images and segmentation masks.
- Build training pipelines that apply per-sample augmentation decisions with configurable probabilities rather than batch-wide decisions.
- Preprocess multi-modal medical images with controlled misalignments between channels to improve model robustness.
- Combine spatial and color augmentations in a composable pipeline and execute them in parallel across multiple worker processes.
- Simulate soft-tissue deformations in medical imaging workflows using anatomy-informed augmentation for realistic training data.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
batchgenerators provides data augmentation transforms for 2D and 3D images, including spatial transformations, color adjustments, noise injection, and cropping, designed for medical image analysis and deep learning pipelines.
Yes. batchgenerators is actively maintained, has no known vulnerabilities, and installs with low friction. It is well-suited for medical image analysis and deep learning projects that need 2D/3D augmentation with per-sample control and multithreaded execution. The Apache 2.0 license is permissive. Use it if you need specialized augmentation for medical or scientific imaging.
Install
batchgenerators on PyPI
pip
pip install batchgeneratorsuv
uv add batchgeneratorspoetry
poetry add batchgeneratorsInstalling batchgenerators
Before you install
Low install friction with a pure Python wheel and stable maintenance. Last release 59 days ago, active repository with 1172 stars, and no known vulnerabilities.
License in practice
Apache License 2.0 is permissive; you may use, modify, and distribute batchgenerators freely in commercial and private projects, provided you include the license and attribute the original authors.
Quickstart
pip install batchgenerators
from batchgenerators.transforms.color_transforms import ContrastAugmentationTransform
from batchgenerators.dataloading.multi_threaded_augmenter import MultiThreadedAugmenter
# Stack transforms and pass to MultiThreadedAugmenter for multithreaded augmentation
Windows requires guarding code with `if __name__ == '__main__'` and calling `multiprocessing.freeze_support()` due to multiprocessing differences; Linux has no such requirement.
Verify before relying
- Whether anatomy-informed and misalignment augmentations (added in 0.23.1 and 0.23.2) are production-ready or still experimental.
- Specific Python version compatibility (requires_python is unspecified in metadata).
- Performance characteristics and memory overhead when processing large 3D datasets.
Package facts
| License | Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for… (full text in the JSON record) (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 9 — pillow, numpy, scipy, scikit-image, scikit-learn, future, pandas, unittest2, threadpoolctl |
| Maintenance | actively maintained — 59 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 149,364/month — #10,994 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: batchgenerators-0.25.3-py3-none-any.whl
Keywords: data augmentation, deep learning, image segmentation, image classification, medical image analysis, medical image segmentation
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
albumentationsAlbumentations applies image transformations to…
permissive · top 5,000 on PyPI
batchgeneratorsv2Reimplemented data augmentation transforms for…
permissive · top 15,000 on PyPI
TotalSegmentatorAutomated segmentation of anatomical structures…
permissive · top 15,000 on PyPI
torchioTorchIO reads, preprocesses, augments, and…
permissive · top 15,000 on PyPI
imgaugAugments images and related data (heatmaps,…
permissive · top 5,000 on PyPI
ttachWraps PyTorch models to apply test-time…
permissive · top 15,000 on PyPI
torch-audiomentationsProvides PyTorch-native audio data augmentation…
permissive · top 5,000 on PyPI
cellposeCellpose segments cells and nuclei in…
permissive · top 15,000 on PyPI
edtComputes Euclidean distance transforms for 1D,…
copyleft · top 15,000 on PyPI
opensimplexGenerates OpenSimplex noise across 2D, 3D, and…
permissive · top 15,000 on PyPI