nemo_automodel.components.datasets.diffusion.multi_tier_bucketing
nemo_automodel.components.datasets.diffusion.multi_tier_bucketing
Module Contents
Classes
Data
API
Calculate resolution buckets constrained by a maximum pixel budget. Supports various aspect ratios, each scaled to fit within the pixel budget.
Build efficient lookup structures.
Calculate the maximum resolution for an aspect ratio within the pixel budget.
For a given aspect ratio r = w/h, and pixel budget P: w * h <= P w = r * h r * h * h <= P h <= sqrt(P / r)
Then w = r * h
Generate all unique resolution buckets within the pixel budget.
Print summary of generated buckets.
Round value to nearest quantization multiple.
Create calculator from a named preset.
Parameters:
One of ‘256p’, ‘512p’, ‘768p’, ‘1024p’, ‘1536p’
Resolution quantization
Returns: MultiTierBucketCalculator
MultiTierBucketCalculator instance
Get all buckets.
Get bucket by ID.
Get bucket by exact resolution.
Get the best bucket for an image.
Parameters:
Original image width
Original image height
Override max pixels for this query (deprecated, use constructor)
Returns: Dict
Bucket dictionary with resolution and metadata
Calculate dynamic batch size based on resolution. Larger images get smaller batches to maintain GPU memory usage.
Parameters:
(width, height)
Batch size for base resolution
Reference resolution
Returns: int
Recommended batch size
Resize and crop image to target resolution.
Parameters:
PIL Image or numpy array
Target width
Target height
‘center’, ‘random’, or ‘smart’
Returns: Tuple
(resized_image, crop_offset_x, crop_offset_y)