ComfyUI Node

HT Training Size

The bucket math for your training set — HT Training Size

By ArtHommage·Created 2 years ago·Updated about a year ago· 4
HT Training Size
  • image
  • width
  • height
  • scale_factor
  • requires_clipping
width1024
height1024
scaling_modeboth

Preparing images for training is where most people lose their dataset. Training frameworks bucket images into a short list of standard resolutions - ai-toolkit's stock config literally ships resolution: [512, 768, 1024] - and your 731×1024 source doesn't fit any of them cleanly. HT Training Size (from the HommageTools pack) does the bucketing math for you: give it your dimensions (or an image), and it returns the target width/height that best matches your aspect ratio from its standard training sizes, plus the scale factor and whether you'll need to clip.

How it works

You provide width and height (or wire an image and it reads the dims off the tensor). It looks at your long edge, then finds the closest target among its standard sizes - 512, 768, 1024 - choosing whichever requires the least scaling. The other dimension is derived from your aspect ratio and rounded to a multiple of 64, which is the divisibility that training pipelines expect.

scaling_mode controls which direction is allowed:

  • both (default) - the image can be scaled up or down to hit the bucket.
  • upscale_only - only move up. Good for tiny sources you don't want shrunk further.
  • downscale_only - only move down. Good for huge sources you don't want upscaled past their native quality.

The outputs tell you everything you need to act: width and height (the target), scale_factor (how much to resize), and requires_clipping - a 0/1 flag for the case where the scaled dimensions exceed the target on one edge, meaning you should crop rather than force-stretch. Wire those into a resize or crop node and your dataset is standardized without you doing mental math per image.

Why this is useful

Multi-resolution bucketing is the standard practice now - the KB's LoRA training essay notes the community trains at 512/768/1024 buckets, and consistent sizing is what keeps batches clean and training stable. This node is that practice in node form: it turns "I have a folder of mixed-size images" into "everything lands on a training-compatible bucket with a known aspect ratio." You can even put it in a per-image loop so each source gets bucketed individually, which is exactly how you want a mixed dataset handled.

Installing it

HommageTools install, once:

cd ComfyUI/custom_nodes
git clone https://github.com/ArtHommage/HommageTools.git
cd HommageTools
pip install -r requirements.txt

Restart ComfyUI, or ComfyUI Manager → "HommageTools". No models to download - it's pure math.

Common issues

It doesn't resize anything. This node calculates and reports; the actual resize/crop is on you (or a sibling scale node). The rounding is to 64, so a very extreme aspect ratio can come back with a second dimension that's off from a pure aspect-ratio fit - that's the flag requires_clipping exists for. And remember the bucket list is fixed at 512/768/1024: if you train at 1280 or 1536 (which some modern recipes do), the numbers it suggests will be conservative. Check requires_clipping on every output, and for extreme-ratio sources you may want to crop first and bucket second. Also note the pack's perpetual-alpha disclaimer - for a calculator that's low risk, but don't build your whole training pipeline on it without eyeballing the first few results.

CategoryHommageTools

Inputs (4)

NameTypeDefaultDescription
widthINT102464–8192
heightINT102464–8192
scaling_modeCOMBOboth3 options: both, upscale_only, downscale_only
imageoptIMAGE

Outputs (4)

NameTypeDescription
widthINT
heightINT
scale_factorFLOAT
requires_clippingINT