Skip to content

FLUX.3: match the released BFL reference image sizing - #15073

Merged
yiyixuxu merged 3 commits into
mainfrom
flux3-reference-sizing
Oct 19, 2026
Merged

yiyixuxu merged 3 commits into
mainfrom
flux3-reference-sizing

Conversation

@yiyixuxu

@yiyixuxu yiyixuxu commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #15068

this PR matches how BFL prepares reference images and derive the default output size from the reference

Default output size
before, when you did not pass height/width, the output defaulted to about 1024 x 1024 pixels of area in the shape of the reference, whatever the reference's size, so a 1920 x1080 input came back as 1376 x 768. Now the output defaults to the exact size of the reference. The model keeps everything it is not asked to change where it was, which makes edits much more precise. Passing height/width works as before.

Reference sizing.

  • One reference image is kept as is, up to a size of about 2048 x 2048 (larger images are scaled down to fit). Its edges are extended by mirroring the image, rather than cutting it, to reach the 16-pixel grid the model works on, and the output is cut back to the original size. No pixel of the input is lost. (If you pass height/width, nothing is cut back.)
  • Several reference images are each scaled down to fit under 1024 x 1024 and trimmed to the 16-pixel grid. The default output size follows the first image.
  • These rules live in Flux3ImageProcessor.preprocess, which also returns the box to cut the output back to, applied in postprocess. The pipeline block only chooses between the two cases.

With the default output size, images under 1024 x 1024 cost the same or less than before. Images between 1024 x 1024 and 2048 x 2048 produce a larger output than before, so they take more time and memory (up to about 1.5x). Larger images are much cheaper than before, because the old limit was 4096 x 4096.

see more details (include 3 examples https://claude.ai/artifact/KBEVcvLyjqs8DpisezaekF)

A single reference is kept whole: downscaled so its padded canvas fits under 4 MP, reflect-padded to the token grid (`resize_mode="fill"` of the FLUX.3 image processor), and cropped back on output. Several references are fitted under 1 MP each. The default output size follows the first reference.

Fixes #15068

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@github-actions github-actions Bot added documentation Improvements or additions to documentation tests modular-pipelines fixes-issue size/L PR with diff > 200 LOC labels Oct 18, 2026
@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

`preprocess` takes only the image and `resize_mode`: "fill" downscales the reference so that its canvas fits under 4 megapixels and reflect-pads it to the canvas, "crop" fits it under 1 megapixel and center-crops it to the grid. The process-images block only picks the mode. Fill is a pure pad, like crop is a pure crop, and the crop-back box is read from the preprocessed tensor. The flags of the base processor are fixed; only the VAE scale factor and latent channels remain configurable.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@yiyixuxu
yiyixuxu requested review from DN6 and sayakpaul October 19, 2026 01:26

@sayakpaul sayakpaul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

canvas_height, canvas_width = self._get_canvas_height_width(height, width, max_side=max_side)
if canvas_height * canvas_width <= target_area:
break
scale *= 0.995

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could benefit from a reference / explainer.

# several references: the first one's size, each cropped to the grid
assert pipe(**inputs, image=self.get_reference_images(sizes=((62, 46), (32, 32))), output="images").shape[
-2:
] == (32, 48)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah so, this is happening because with multiple references, preprocessing center-crops each image to multiples of 16.

For the first reference, (width, height) = (62, 46) becomes:

  • Width: 62 // 16 * 16 = 48
  • Height: 46 // 16 * 16 = 32

I thought it would be (46, 62) but now it makes sense.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@yiyixuxu
yiyixuxu merged commit 4df4a5b into main Oct 19, 2026
17 checks passed
@yiyixuxu
yiyixuxu deleted the flux3-reference-sizing branch October 19, 2026 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation fixes-issue modular-pipelines size/L PR with diff > 200 LOC tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FLUX.3: match the released BFL reference image sizing

3 participants