Sign In

Bucket Resizing for Text-to-Image Fine-Tuning

3

Jun 21, 2025

(Updated: 5 months ago)

data prep
Bucket Resizing for Text-to-Image Fine-Tuning

When preparing a dataset for fine-tuning a text-to-image model, many creators focus on prompts, learning rates, or training steps. Yet one of the most important decisions comes long before the first batch is processed: how you handle image sizes.

Most datasets include a mix of portraits, landscapes, and everything in between. If all of these are forced into a single square resolution like 1024×1024, you risk cropping out important details or adding black padding that can confuse the model. Fortunately, there is a better approach: bucket resizing.

What is Bucket Resizing?

Bucket resizing is a preprocessing technique that groups images by resolution, based on their shape and size. Each group, or "bucket", contains images that share a similar aspect ratio and pixel area. The idea is simple: rather than fitting every image into the same square shape, match it to the closest resolution that retains its structure and content.

Instead of resizing everything to 1024×1024, for example, your training pipeline might use resolutions like 768×1024, 512×2048 or 896×896, depending on what the images require.

This allows the training process to use more of each image and helps the model learn from clean, consistent data without distortions or unnecessary padding.

Why Fixed Resolutions Fall Short

Resizing every image to a square format, such as 1024×1024, may sound convenient but usually leads to poor results. Non-square images are either cropped aggressively, cutting out important parts of the composition, or padded with black borders that can confuse the model.

This is especially problematic with varied datasets, where composition and framing differ from image to image. By flattening everything into a single resolution, you risk losing the diversity and structure that make your dataset valuable.

How Bucket Resizing Works

The algorithm behind bucket resizing follows two main steps: generating valid bucket sizes and matching each image to one of those buckets.

1. Defining the Bucket Resolutions

First, the training setup creates a list of acceptable width and height combinations. These are calculated based on:

  • A maximum pixel area, often 1024×1024 or similar

  • A step size, usually 64 pixels, to keep resolution increments manageable

  • A filter to exclude extreme aspect ratios such as 16:1 or 1:16

This gives you a set of valid shapes that cover a wide range of image types without overloading memory.

2. Matching Images to Buckets

Each image is assigned to the closest matching bucket based on aspect ratio. Once a match is found:

  • The image is resized proportionally so that one side fits the target

  • The other side is cropped to match the bucket dimensions

  • If upscaling is turned off, only buckets that require shrinking will be considered

This method ensures that images are resized with care and that only the least necessary cropping is applied.

Example: A Tall Portrait

Consider an image that is 1024 by 4096 pixels. This is too large to fit inside a 1024×1024 area. Bucket resizing finds the closest valid shape, such as 512×2048. The image is scaled down to fit that bucket and slightly cropped if needed.

As a result, the model sees a full-height portrait that is properly framed and consistent with other images in the same bucket. This is far better than cramming the image into a square and losing valuable visual information.

Where Bucket Resizing Fits In

Bucket resizing is part of dataset preparation, which makes it broadly compatible across different workflows and architectures. Whether you are fine-tuning with LoRA, using DreamBooth for a personalised subject, or adjusting a full checkpoint, the technique integrates seamlessly.

Because it operates before training begins, bucket resizing works with any model built on a text-to-image architecture, including SDXL, SD3, SD3.5, FLUX1-dev and similar designs. It is supported natively in popular training tools such as Kohya_SS and OneTrainer, each of which uses its own method for selecting and applying bucket resolutions. In more custom setups, such as PyTorch or Diffusers-based pipelines, bucketing may require manual implementation, but the core idea remains consistent.

Is Bucket Resizing Always the Best Choice?

For most training scenarios, bucket resizing offers clear advantages. It preserves the composition of images, reduces unnecessary padding and cropping, and helps ensure consistent and efficient batches during fine-tuning. In many modern workflows, it has become the default approach.

However, it is not entirely without trade-offs. Bucket resizing relies on the ability of the training framework to manage varying resolutions from batch to batch. Some environments, especially those using non-standard GPU architectures or more constrained backends, may not handle these variations efficiently. In such cases, performance issues may appear, not due to the bucket logic itself, but because of how memory is allocated or how resolution switching is managed internally.

This is more common in training environments that are not based on NVIDIA hardware, or in cases where mixed precision, low VRAM, or slow storage further limit flexibility. While these issues are not caused by bucket resizing directly, they can influence whether it performs optimally.

Still, on most widely used setups bucket resizing works reliably and produces better results than fixed-resolution training. For these cases, it remains the recommended choice.

3