Registry / ai-ml / batchgeneratorsv2

batchgeneratorsv2

JSON →
library0.3.2pypypiunverified

Batchgenerators is a deep learning data augmentation and batching library originally for medical image segmentation. Version 2 overhauls the API for composable transformations, deterministic ordering, and reduced overhead. Current version 0.3.2 (pre-1.0, breaking changes likely). Released irregularly.

pip install batchgeneratorsv2
INSTALL
IMPORT
SIG · BATCHGENERATORSV2
B
batchgeneratorsv2
ai-mlpythonv0.3.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BatchGenerator
from batchgeneratorsv2 import BatchGenerator
from batchgeneratorsv2.generators import BatchGenerator

Minimal example: create a BatchGenerator with transforms and iterate.

import numpy as np from batchgeneratorsv2.generators import BatchGenerator from batchgeneratorsv2.transforms import Compose, SpatialTransform, ColorTransform # Dummy data data = np.random.rand(100, 3, 128, 128) # N, C, H, W # Define transforms transforms = Compose([ SpatialTransform(patch_size=(64, 64), do_rotation=True), ColorTransform(brightness_range=(0.9, 1.1), contrast_range=(0.9, 1.1)) ]) # Create batch generator batch_gen = BatchGenerator( data=data, batch_size=4, transforms=transforms, num_processes=1 ) # Iterate for batch in batch_gen: x = batch['data'] # x shape: (4, 3, 64, 64) break print('Quickstart works: shape', x.shape)
Debug
Known issues
breakingbatchgeneratorsv2 is a complete rewrite from batchgenerators (v1). Import paths, API, and behavior differ: v2 uses generators module, Compose is in transforms, and data is passed as dict with 'data' key.
fix
Do not mix v1 and v2 imports. Rewrite code to use v2 API: from batchgeneratorsv2.generators import BatchGenerator; from batchgeneratorsv2.transforms import Compose.
affects: >=0.1.0
breakingv0.3.0 removed the old 'batchgeneratorsv2.transforms.abstract' submodule. All transforms now inherit from base classes in transforms.base.
fix
Use transforms.base.AbstractTransform instead of transforms.abstract.AbstractTransform.
affects: >=0.3.0
deprecatedSetting num_processes > 1 is experimental. May cause deadlocks or data corruption.
fix
Use num_processes=1 for stability, or test carefully with multiprocessing.
affects: <=0.3.2
gotchaSpatialTransform's 'patch_size' must be smaller than input dimensions; otherwise, it silently fails or returns empty arrays.
fix
Ensure patch_size is less than or equal to the spatial dimensions of your input data.
affects: all
Upgrade
Version history
0.3.2latest on PyPI · released Apr 13, 2026
Audit
Dependencies
numpyrequiredcore data structures
torchrequiredPyTorch tensor operations
scipyrequiredinterpolation for geometric transforms
Agent activity
19 hits · last 30 days
node
16
Amazon
1
OpenAI (training)
1
Resources
batchgeneratorsv2 — pip install batchgeneratorsv2 · libregistry