Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

fix(canvas): inpaint and outpaint with FLUX Fill models (#10381)

Alexander Eichhornc63dabe95e92
diff --git a/docs/src/content/docs/Users Guide/03.Models/Local Models/flux-1.mdx b/docs/src/content/docs/Users Guide/03.Models/Local Models/flux-1.mdx
index 69da32bed2..1e898b94d7 100644
--- a/docs/src/content/docs/Users Guide/03.Models/Local Models/flux-1.mdx
+++ b/docs/src/content/docs/Users Guide/03.Models/Local Models/flux-1.mdx
@@ -148,11 +148,15 @@ On the Canvas, a control layer can use either kind of FLUX.1 structural control:
## FLUX Fill
-FLUX Fill regenerates a masked region of an image. The Generate tab and Canvas refuse a Fill model (they
-report that it does not support text-to-image), so use it in the workflow editor: connect a
-**FLUX Fill Conditioning** node (image plus inpainting mask) to the **Fill Conditioning** input of
-**FLUX Denoise**, and connect the VAE to its `controlnet_vae` input. A guidance of about 30 is
-recommended.
+FLUX Fill regenerates a masked region of an image. On the Canvas it inpaints (paint an inpaint mask over
+the area to replace) and outpaints (move the frame past the image edge). It always regenerates the masked
+area from scratch, so the denoising strength, a mask layer's denoise limit and the coherence and infill
+settings do not apply: any painted area is regenerated fully. Without
+a mask or a transparent area in the frame, Invoke reports that FLUX Fill only inpaints and outpaints; the
+Generate tab refuses a Fill model for the same reason. Guidance below 25 is refused; about 30 is recommended.
+
+In the workflow editor, connect a **FLUX Fill Conditioning** node (image plus inpainting mask) to the
+**Fill Conditioning** input of **FLUX Denoise**, and connect the VAE to its `controlnet_vae` input.
## LoRA
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.json
index 1030f4775f..253497c4cd 100644
--- a/invokeai/frontend/webv2/public/locales/en.json
+++ b/invokeai/frontend/webv2/public/locales/en.json
@@ -3728,6 +3728,7 @@
"capabilitiesUnavailable": "Model capabilities are not available. Generation is blocked until they load; if this persists, retry from the Generate panel.",
"componentNotInstalled": "$t(widgets.generate.switchSubjects.{{component}}) \"{{name}}\" is not installed. Choose another, or clear it.",
"conceptNotInstalled": "Concept \"{{name}}\" is not installed. Remove it, or reinstall it.",
+ "fluxFillMode": "FLUX Fill only inpaints and outpaints: add an inpaint mask on the Canvas, or move the frame past the image edge.",
"heightGrid": "Height must be a multiple of {{grid}}.",
"heightRange": "Height must be between {{min}} and {{max}}.",
"modelNotInstalled": "{{name}} is not installed. Choose another model, or reinstall it.",
diff --git a/invokeai/frontend/webv2/src/features/generation/core/__snapshots__/generateGraphNodeTypes.json b/invokeai/frontend/webv2/src/features/generation/core/__snapshots__/generateGraphNodeTypes.json
index da91a5199c..a8e94dd80b 100644
--- a/invokeai/frontend/webv2/src/features/generation/core/__snapshots__/generateGraphNodeTypes.json
+++ b/invokeai/frontend/webv2/src/features/generation/core/__snapshots__/generateGraphNodeTypes.json
@@ -110,22 +110,35 @@
"clipEmbedModel",
"t5EncoderModel",
"vae"
+ ],
+ "canvas-fill-outpaint-masked": [
+ "clipEmbedModel",
+ "t5EncoderModel",
+ "vae"
]
},
"nodeTypes": [
"collect",
"core_metadata",
+ "expand_mask_with_fade",
"flux_denoise",
+ "flux_fill",
"flux_ip_adapter",
"flux_lora_collection_loader",
"flux_model_loader",
"flux_text_encoder",
"flux_vae_decode",
+ "image_mask_to_tensor",
"img_nsfw",
"img_watermark",
"integer",
+ "invert_tensor_mask",
+ "invokeai_img_blend",
"lora_selector",
- "string"
+ "mask_combine",
+ "string",
+ "tensor_mask_to_image",
+ "tomask"
]
},
"flux2": {
@@ -737,6 +750,7 @@
1,
3,
3.5,
+ 30,
4,
4.5,
6,
@@ -765,6 +779,7 @@
"anima_txt2img",
"cogview4_txt2img",
"ernie_image_txt2img",
+ "flux_outpaint",
"flux_txt2img",
"flux2_txt2img",
"flux3_txt2img",
@@ -781,7 +796,8 @@
"z_image_txt2img"
],
"guidance": [
- 3.5
+ 3.5,
+ 30
],
"height": [
1024,
@@ -916,7 +932,8 @@
9
],
"strength": [
- 0.6
+ 0.6,
+ 1
],
"t2iAdapters": [],
"t5_encoder": [],
@@ -1133,9 +1150,29 @@
"image"
]
},
+ "expand_mask_with_fade": {
+ "inputs": [
+ "mask"
+ ],
+ "literalInputs": {
+ "fade_size_px": [
+ 16
+ ],
+ "is_intermediate": [
+ true
+ ],
+ "use_cache": [
+ true
+ ]
+ },
+ "outputs": [
+ "image"
+ ]
+ },
"flux_denoise": {
"inputs": [
"controlnet_vae",
+ "fill_conditioning",
"ip_adapter",
"positive_text_conditioning",
"seed",
@@ -1158,7 +1195,8 @@
3
],
"guidance": [
- 3.5
+ 3.5,
+ 30
],
"height": [
1024
@@ -1167,7 +1205,8 @@
true
],
"num_steps": [
- 28
+ 28,
+ 50
],
"scheduler": [
"euler"
@@ -1183,6 +1222,23 @@
"latents"
]
},
+ "flux_fill": {
+ "inputs": [
+ "mask"
+ ],
+ "literalInputs": {
+ "image": [],
+ "is_intermediate": [
+ true
+ ],
+ "use_cache": [
+ true
+ ]
+ },
+ "outputs": [
+ "fill_cond"
+ ]
+ },
"flux_ip_adapter": {
"inputs": [],
"literalInputs": {
@@ -1778,6 +1834,25 @@
"image"
]
},
+ "image_mask_to_tensor": {
+ "inputs": [
+ "image"
+ ],
+ "literalInputs": {
+ "cutoff": [
+ 255
+ ],
+ "is_intermediate": [
+ true
+ ],
+ "use_cache": [
+ true
+ ]
+ },
+ "outputs": [
+ "mask"
+ ]
+ },
"img_nsfw": {
"inputs": [
"image"
@@ -1823,6 +1898,39 @@
"value"
]
},
+ "invert_tensor_mask": {
+ "inputs": [
+ "mask"
+ ],
+ "literalInputs": {
+ "is_intermediate": [
+ true
+ ],
+ "use_cache": [
+ true
+ ]
+ },
+ "outputs": [
+ "mask"
+ ]
+ },
+ "invokeai_img_blend": {
+ "inputs": [
+ "layer_upper",
+ "mask",
+ "metadata"
+ ],
+ "literalInputs": {
+ "is_intermediate": [
+ true
+ ],
+ "layer_base": [],
+ "use_cache": [
+ false
+ ]
+ },
+ "outputs": []
+ },
"ip_adapter": {
"inputs": [],
"literalInputs": {
@@ -2051,6 +2159,23 @@
"vae"
]
},
+ "mask_combine": {
+ "inputs": [
+ "mask2"
+ ],
+ "literalInputs": {
+ "is_intermediate": [
+ true
+ ],
+ "mask1": [],
+ "use_cache": [
+ true
+ ]
+ },
+ "outputs": [
+ "image"
+ ]
+ },
"moss_image_denoise": {
"inputs": [
"negative_conditioning",
@@ -2684,6 +2809,37 @@
"value"
]
},
+ "tensor_mask_to_image": {
+ "inputs": [
+ "mask"
+ ],
+ "literalInputs": {
+ "is_intermediate": [
+ true
+ ],
+ "use_cache": [
+ true
+ ]
+ },
+ "outputs": [
+ "image"
+ ]
+ },
+ "tomask": {
+ "inputs": [],
+ "literalInputs": {
+ "image": [],
+ "is_intermediate": [
+ true
+ ],
+ "use_cache": [
+ true
+ ]
+ },
+ "outputs": [
+ "image"
+ ]
+ },
"wan_denoise": {
"inputs": [
"negative_conditioning",
diff --git a/invokeai/frontend/webv2/src/features/generation/core/architectureGenerationConfig.ts b/invokeai/frontend/webv2/src/features/generation/core/architectureGenerationConfig.ts
index 235516b584..fbee3c4f2c 100644
--- a/invokeai/frontend/webv2/src/features/generation/core/architectureGenerationConfig.ts
+++ b/invokeai/frontend/webv2/src/features/generation/core/architectureGenerationConfig.ts
@@ -2,7 +2,7 @@
import type { ArchitectureCapabilitiesRow } from '@features/models/architectures';
-import { getArchitectureCapabilityRow } from '@features/models/architectures';
+import { getArchitectureCapabilityRow, isFluxFillModel } from '@features/models/architectures';
import type { BaseGenerationConfig, GuidanceLabel } from './generationConfig';
@@ -11,6 +11,12 @@ const FALLBACK_CFG_SCALE = 7;
const FALLBACK_SCHEDULER = 'euler_a';
const FALLBACK_OPTIMAL_SIDE = 1024;
+/**
+ * `flux_denoise` warns below this: FLUX Fill was trained on guidance of about 30 and degrades at the FLUX dev default.
+ * A frontend product floor, stricter than the node-enforced `guidance_min` the backend serves.
+ */
+const FLUX_FILL_MIN_GUIDANCE = 25;
+
/** guidance_label selects the field; CFG-off markers are not guidance values. */
const guidanceValue = (defaults: NonNullable<ArchitectureCapabilitiesRow['defaults']>, label: GuidanceLabel): number =>
(label === 'Guidance' ? (defaults.guidance ?? defaults.cfg_scale) : (defaults.cfg_scale ?? defaults.guidance)) ??
@@ -45,7 +51,10 @@ export const toBaseGenerationConfig = (row: ArchitectureCapabilitiesRow): BaseGe
schedulerAppliesToGraph: features.scheduler_applies_to_graph,
guidanceLabel,
// Nullish fallbacks support older backend fields without producing NaN bounds.
- guidance: { min: features.guidance_min ?? 1, max: features.guidance_max ?? null },
+ guidance: {
+ min: Math.max(features.guidance_min ?? 1, isFluxFillModel(row) ? FLUX_FILL_MIN_GUIDANCE : 0),
+ max: features.guidance_max ?? null,
+ },
negativePrompt: features.negative_prompt,
ui: {
sdVaeOverride: features.sd_vae_override,
diff --git a/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.test.ts b/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.test.ts
index 726b805c19..7912acb134 100644
--- a/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.test.ts
+++ b/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.test.ts
@@ -29,7 +29,10 @@ import {
getDefaultGenerateSettings,
getGenerateInvocationIssues,
getGenerateModelSelectionResult,
+ getGenerationDefaults,
getGenerationDimensions,
+ getGuidanceBoundReason,
+ getGuidanceSliderMax,
getGenerationModelAvailabilityReasons,
getGenerationUiPolicy,
getGenerationValidationIssues,
@@ -628,6 +631,69 @@ describe('component policies', () => {
);
});
+ it('blocks FLUX Fill outside inpaint and outpaint, but not while a Canvas frame decides the mode', () => {
+ const model = createModel('flux', { variant: 'dev_fill' });
+ const settings = {
+ ...createSettings(model),
+ clipEmbedModel: clipEmbed,
+ t5EncoderModel: t5Encoder,
+ vae: fluxVae,
+ };
+ const reasons = (mode?: Parameters<typeof getGenerationValidationReasons>[2]) =>
+ getGenerationValidationReasons(model, settings, mode).filter((reason) => reason.startsWith('FLUX Fill only'));
+
+ expect(reasons()).toHaveLength(1);
+ expect(reasons('img2img')).toHaveLength(1);
+ expect(reasons('inpaint')).toEqual([]);
+ expect(reasons('outpaint')).toEqual([]);
+ expect(getGenerateInvocationIssues({ ...settings, model }).map(({ message }) => message)).toEqual(reasons());
+ expect(
+ getGenerateInvocationIssues({ ...settings, model }, { canvasFrame: { height: 512, width: 512 } }).map(
+ ({ message }) => message
+ )
+ ).not.toContain(reasons()[0]);
+ });
+
+ it('holds FLUX Fill to a guidance floor of 25 with the field reason and a one-step fix', () => {
+ const model = createModel('flux', { variant: 'dev_fill' });
+ const settings = { ...createSettings(model), clipEmbedModel: clipEmbed, t5EncoderModel: t5Encoder, vae: fluxVae };
+ const guidanceIssues = (cfgScale: number) =>
+ getGenerationValidationIssues(model, { ...settings, cfgScale }, 'inpaint').filter(
+ ({ target }) => target.field === 'cfgScale'
+ );
+
+ expect(getGuidanceBoundReason(model, 3.5)).toBe(`Guidance must be at least 25 for ${model.name}.`);
+ expect(guidanceIssues(3.5)).toEqual([
+ expect.objectContaining({
+ fix: { kind: 'clampGuidance', value: 25 },
+ message: getGuidanceBoundReason(model, 3.5),
+ }),
+ ]);
+ expect(getGuidanceBoundReason(model, 25)).toBeNull();
+ expect(guidanceIssues(25)).toEqual([]);
+ expect(guidanceIssues(30)).toEqual([]);
+ expect(getGenerationUiPolicy(model).guidanceMin).toBe(25);
+ });
+
+ it('lands on the FLUX Fill floor when switching from FLUX dev at its default guidance', () => {
+ const dev = createModel('flux', { key: 'flux-dev', variant: 'dev' });
+ const fill = createModel('flux', { key: 'flux-fill', variant: 'dev_fill' });
+ const currentValues = createSettings(dev, { cfgScale: 3.5 });
+
+ const { settings } = getGenerateModelSelectionResult({ currentValues, model: fill, models: [dev, fill] });
+
+ expect(settings.cfgScale).toBeGreaterThanOrEqual(25);
+ });
+
+ it('raises a FLUX Fill model default saved below the floor to the floor', () => {
+ const fill = createModel('flux', { variant: 'dev_fill', default_settings: { guidance: 3.5 } });
+
+ expect(getGenerationDefaults(fill).cfgScale).toBe(25);
+ expect(
+ getGenerationDefaults(createModel('flux', { variant: 'dev', default_settings: { guidance: 3.5 } })).cfgScale
+ ).toBe(3.5);
+ });
+
it('keeps concepts but clears incompatible selections when the selected model changes', () => {
const model = createModel('sdxl');
const settings = createSettings(createModel('sd-1'), {
@@ -1544,7 +1610,9 @@ describe('the guidance range the architecture declares', () => {
}
const where = `${row.base}/${row.variant ?? '-'}`;
- const { guidance_max: max, guidance_min: min } = row.features;
+ const { guidance_max: max } = row.features;
+ // FLUX Fill is the one deliberate exception: a product floor above the served node minimum.
+ const min = where === 'flux/dev_fill' ? 25 : row.features.guidance_min;
expect(guidanceReasons(model, min), `${where} rejected its own floor`).toEqual([]);
@@ -2210,3 +2278,22 @@ describe("a main model's default components", () => {
});
});
});
+
+describe('getGuidanceSliderMax', () => {
+ it('keeps the 10-wide track for floors below it', () => {
+ expect(getGuidanceSliderMax(1, null)).toBe(10);
+ expect(getGuidanceSliderMax(1, 20)).toBe(10);
+ expect(getGuidanceSliderMax(1, 6)).toBe(6);
+ expect(getGuidanceSliderMax(0, 100)).toBe(10);
+ });
+
+ it('spans a usable range above a floor at or beyond the track, so FLUX Fill runs from 25 to 35', () => {
+ expect(getGuidanceSliderMax(25, null)).toBe(35);
+ expect(getGuidanceSliderMax(10, null)).toBe(20);
+ });
+
+ it('never crosses the input ceiling or drops below the floor', () => {
+ expect(getGuidanceSliderMax(25, 30)).toBe(30);
+ expect(getGuidanceSliderMax(25, 25)).toBe(25);
+ });
+});
diff --git a/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.ts b/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.ts
index 5bc52c7ec0..7be6c71106 100644
--- a/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.ts
+++ b/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.ts
@@ -11,7 +11,7 @@ import {
SUPPORTED_GENERATE_BASES,
type SupportedGenerateBase,
} from '@features/generation/core/supportedBases';
-import { getArchitectureFeatures, hasArchitectureCapabilities } from '@features/models/architectures';
+import { getArchitectureFeatures, hasArchitectureCapabilities, isFluxFillModel } from '@features/models/architectures';
import { areJsonValuesStructurallyEqual } from '@platform/core/json';
import { SEED_MAX } from '@platform/core/seed';
@@ -1227,10 +1227,6 @@ const getBaseComponentSectionPolicy = (
missingMessage: 'Generate needs a VAE for FLUX models.',
},
]),
- rules: (ctx) =>
- ctx.model.type !== 'external_image_generator' && ctx.model.variant === 'dev_fill'
- ? ['FLUX Fill models do not support text-to-image generation.']
- : [],
};
case 'flux2': {
const isDev = model.variant === 'dev';
@@ -3293,6 +3289,24 @@ export const getGuidanceBoundReason = (
return null;
};
+const GUIDANCE_SLIDER_SPAN = 10;
+const GUIDANCE_INPUT_MAX = 100;
+
+/**
+ * Slider track for the guidance field. The input accepts values up to the architecture ceiling; the track spans
+ * `GUIDANCE_SLIDER_SPAN` above zero, or above the floor when the floor already reaches that span (FLUX Fill), so the
+ * track never collapses onto values the model refuses.
+ */
+export const getGuidanceSliderMax = (guidanceMin: number, guidanceMax: number | null): number => {
+ const inputMax = guidanceMax ?? GUIDANCE_INPUT_MAX;
+ const trackEnd = guidanceMin >= GUIDANCE_SLIDER_SPAN ? guidanceMin + GUIDANCE_SLIDER_SPAN : GUIDANCE_SLIDER_SPAN;
+
+ return Math.max(guidanceMin, Math.min(trackEnd, inputMax));
+};
+
+/** Upper bound of the typed input for the guidance field. */
+export const getGuidanceInputMax = (guidanceMax: number | null): number => guidanceMax ?? GUIDANCE_INPUT_MAX;
+
/** Combinations the backend refuses only after queueing. */
const getKrea2ReferenceValidationReasons = (
settings: GenerateSettings
@@ -3438,11 +3452,19 @@ const getComponentValidationIssues = (model: GenerateModelConfig, settings: Gene
];
};
-/** `mode` is the external generation mode being compiled; local models are validated the same way for every mode. */
+/**
+ * What a validation answers for: the generation mode being compiled, or `canvasFrame` for Canvas readiness, where the
+ * mode is only known once the composite exists. Local models differ only for FLUX Fill, which edits an image.
+ */
+export type GenerationValidationMode = ExternalGenerationMode | 'outpaint' | 'canvasFrame';
+
+const FLUX_FILL_MODE_REASON =
+ 'FLUX Fill only inpaints and outpaints: add an inpaint mask on the Canvas, or move the frame past the image edge.';
+
export const getGenerationValidationIssues = (
model: GenerateModelConfig,
settings: GenerateSettings,
- mode: ExternalGenerationMode = 'txt2img'
+ mode: GenerationValidationMode = 'txt2img'
): GenerationIssue[] => {
if (!hasArchitectureCapabilities()) {
// Keep core independent of the load-state store; failures direct callers to retry.
@@ -3496,7 +3518,9 @@ export const getGenerationValidationIssues = (
}
if (model.type === 'external_image_generator') {
- const modeReason = getExternalModeReason(model, mode);
+ // Canvas compiles reject outpainting themselves, and readiness asks providers by their own modes.
+ const providerMode: ExternalGenerationMode = mode === 'outpaint' || mode === 'canvasFrame' ? 'txt2img' : mode;
+ const modeReason = getExternalModeReason(model, providerMode);
if (modeReason) {
issues.push(createUntranslatedGenerationIssue(modeReason, MODEL_TARGET));
@@ -3513,7 +3537,7 @@ export const getGenerationValidationIssues = (
// Every request emits one output, and the Canvas edit modes add the composite as one init image.
if (isSeedreamBatchModel(model)) {
- const totalImages = getExternalReferenceImages(settings, model).length + (mode === 'txt2img' ? 0 : 1) + 1;
+ const totalImages = getExternalReferenceImages(settings, model).length + (providerMode === 'txt2img' ? 0 : 1) + 1;
if (totalImages > SEEDREAM_BATCH_MAX_TOTAL_IMAGES) {
issues.push(
@@ -3541,6 +3565,10 @@ export const getGenerationValidationIssues = (
);
}
+ if (isFluxFillModel(model) && (mode === 'txt2img' || mode === 'img2img')) {
+ issues.push(issue('model:fluxFillMode', 'fluxFillMode', FLUX_FILL_MODE_REASON, MODEL_TARGET));
+ }
+
issues.push(...getModelFamilyValidationIssues(model, settings));
issues.push(
...getRefinerValidationReasons(model, settings).map((reason) =>
@@ -3555,7 +3583,7 @@ export const getGenerationValidationIssues = (
export const getGenerationValidationReasons = (
model: GenerateModelConfig,
settings: GenerateSettings,
- mode: ExternalGenerationMode = 'txt2img'
+ mode: GenerationValidationMode = 'txt2img'
): string[] => getGenerationValidationIssues(model, settings, mode).map(({ message }) => message);
export const needsEmptyCanvasFrameForReferenceBudget = (
@@ -3592,7 +3620,13 @@ export const getGenerateInvocationIssues = (
providerModes !== null && canvasFrame
? { ...values, ...resolveExternalCanvasRequestSize(model, canvasFrame) }
: values,
- providerModes !== null && !providerModes.includes('txt2img') ? 'img2img' : 'txt2img'
+ providerModes !== null
+ ? providerModes.includes('txt2img')
+ ? 'txt2img'
+ : 'img2img'
+ : canvasFrame
+ ? 'canvasFrame'
+ : 'txt2img'
),
...(models ? getGenerationModelAvailabilityIssues(model, values, models) : []),
];
diff --git a/invokeai/frontend/webv2/src/features/generation/core/canvas/compileCanvasGraph.test.ts b/invokeai/frontend/webv2/src/features/generation/core/canvas/compileCanvasGraph.test.ts
index 4efbf9410e..385a7c2983 100644
--- a/invokeai/frontend/webv2/src/features/generation/core/canvas/compileCanvasGraph.test.ts
+++ b/invokeai/frontend/webv2/src/features/generation/core/canvas/compileCanvasGraph.test.ts
@@ -22,6 +22,7 @@ const sd2Model: MainModelConfig = { base: 'sd-2', key: 'sd2-model', name: 'SD 2'
const sdxlModel: MainModelConfig = { base: 'sdxl', key: 'sdxl-model', name: 'SDXL', type: 'main' };
const sd3Model: MainModelConfig = { base: 'sd-3', format: 'diffusers', key: 'sd3-model', name: 'SD3', type: 'main' };
const fluxModel: MainModelConfig = { base: 'flux', key: 'flux-model', name: 'FLUX dev', type: 'main' };
+const fluxFillModel: MainModelConfig = { ...fluxModel, key: 'flux-fill-model', name: 'FLUX Fill', variant: 'dev_fill' };
const flux2Model: MainModelConfig = {
base: 'flux2',
format: 'diffusers',
@@ -650,6 +651,94 @@ describe('compileCanvasGraph — outpaint per base', () => {
});
});
+describe('compileCanvasGraph — FLUX Fill', () => {
+ const noLatentNodes = (graph: BackendGraphContract) =>
+ Object.values(graph.nodes).filter((node) => ['flux_vae_encode', 'create_gradient_mask'].includes(node.type));
+
+ it('inpaints from the composite and mask conditioning, with no latents or denoise mask', () => {
+ const { backendGraph, mode } = compile(fluxFillModel, 'inpaint', { strength: 0.5 });
+ expect(mode).toBe('inpaint');
+
+ expect(noLatentNodes(backendGraph)).toEqual([]);
+ expect(getEdge(backendGraph, 'denoise_latents', 'denoise_mask')).toBeUndefined();
+ expect(getEdge(backendGraph, 'denoise_latents', 'latents')).toBeUndefined();
+ expect(backendGraph.nodes.denoise_latents).toMatchObject({ denoising_end: 1, denoising_start: 0 });
+
+ expect(backendGraph.nodes.flux_fill).toMatchObject({
+ image: { image_name: 'canvas-composite.png' },
+ type: 'flux_fill',
+ });
+ // Only a white pixel is kept, so a mask layer's gray denoise limit still regenerates.
+ expect(backendGraph.nodes.flux_fill_mask_tensor).toMatchObject({
+ cutoff: 255,
+ image: { image_name: 'canvas-mask.png' },
+ type: 'image_mask_to_tensor',
+ });
+ expect(getEdge(backendGraph, 'flux_fill', 'mask')?.source.node_id).toBe('flux_fill_mask_tensor');
+ expect(getEdge(backendGraph, 'denoise_latents', 'fill_conditioning')?.source).toEqual({
+ field: 'fill_cond',
+ node_id: 'flux_fill',
+ });
+
+ expect(getEdge(backendGraph, 'flux_fill_keep_tensor', 'mask')?.source.node_id).toBe('flux_fill_mask_tensor');
+ expect(getEdge(backendGraph, 'flux_fill_keep_mask', 'mask')?.source.node_id).toBe('flux_fill_keep_tensor');
+ expect(backendGraph.nodes.expand_mask).toMatchObject({ fade_size_px: 16 });
+ expect(backendGraph.nodes.expand_mask?.mask).toBeUndefined();
+ expect(getEdge(backendGraph, 'expand_mask', 'mask')?.source.node_id).toBe('flux_fill_keep_mask');
+ expect(backendGraph.nodes.canvas_output).toMatchObject({
+ layer_base: { image_name: 'canvas-composite.png' },
+ type: 'invokeai_img_blend',
+ });
+ expect(getEdge(backendGraph, 'canvas_output', 'layer_upper')?.source.node_id).toBe('canvas_l2i');
+ expect(getEdge(backendGraph, 'canvas_output', 'mask')?.source.node_id).toBe('expand_mask');
+ expect(getNodeByType(backendGraph, 'core_metadata')?.generation_mode).toBe('flux_inpaint');
+ });
+
+ it('outpaints from the alpha mask combined with the explicit mask, without infill', () => {
+ const { backendGraph } = compile(fluxFillModel, 'outpaint', { maskImageName: 'canvas-mask.png' });
+
+ expect(backendGraph.nodes.infill).toBeUndefined();
+ expect(noLatentNodes(backendGraph)).toEqual([]);
+ expect(backendGraph.nodes.mask_combine).toMatchObject({ mask1: { image_name: 'canvas-mask.png' } });
+ expect(getEdge(backendGraph, 'mask_combine', 'mask2')?.source.node_id).toBe('image_alpha_to_mask');
+ expect(getEdge(backendGraph, 'flux_fill_mask_tensor', 'image')?.source.node_id).toBe('mask_combine');
+ expect(backendGraph.nodes.flux_fill_mask_tensor).toMatchObject({ cutoff: 255 });
+ expect(getEdge(backendGraph, 'flux_fill_keep_tensor', 'mask')?.source.node_id).toBe('flux_fill_mask_tensor');
+ expect(getEdge(backendGraph, 'expand_mask', 'mask')?.source.node_id).toBe('flux_fill_keep_mask');
+ expect(backendGraph.nodes.flux_fill?.image).toEqual({ image_name: 'canvas-composite.png' });
+ expect(getNodeByType(backendGraph, 'core_metadata')?.generation_mode).toBe('flux_outpaint');
+ });
+
+ it('outpaints from the alpha mask alone and applies the mask when only masked regions are kept', () => {
+ const { backendGraph } = compile(fluxFillModel, 'outpaint', { maskImageName: null, outputOnlyMaskedRegions: true });
+
+ expect(getEdge(backendGraph, 'flux_fill_mask_tensor', 'image')?.source.node_id).toBe('image_alpha_to_mask');
+ expect(backendGraph.nodes.canvas_output).toMatchObject({ invert_mask: true, type: 'apply_mask_to_image' });
+ });
+
+ it('feeds the fill inputs at the bbox and restores only the generated image when processing differs', () => {
+ const { backendGraph } = compile(fluxFillModel, 'inpaint', {
+ bbox: { height: 512, width: 512, x: 0, y: 0 },
+ scaling: { height: 768, method: 'manual', width: 1024 },
+ });
+
+ expect(backendGraph.nodes.denoise_latents).toMatchObject({ height: 768, width: 1024 });
+ expect(backendGraph.nodes.canvas_resize_initial_to_processing).toBeUndefined();
+ expect(backendGraph.nodes.canvas_resize_generated_to_bbox).toMatchObject({ height: 512, width: 512 });
+ expect(backendGraph.nodes.canvas_resize_output_mask_to_bbox).toBeUndefined();
+ expect(getEdge(backendGraph, 'canvas_output', 'layer_upper')?.source.node_id).toBe(
+ 'canvas_resize_generated_to_bbox'
+ );
+ expect(getEdge(backendGraph, 'canvas_output', 'mask')?.source.node_id).toBe('expand_mask');
+ });
+
+ it('rejects the modes without an image to edit', () => {
+ for (const mode of ['txt2img', 'img2img'] as const) {
+ expect(() => compile(fluxFillModel, mode)).toThrow('FLUX Fill only inpaints and outpaints');
+ }
+ });
+});
+
describe('compileCanvasGraph — control layers (integration)', () => {
const controlNetLayer: ControlLayerGraphInput = {
beginEndStepPct: [0.1, 0.85],
diff --git a/invokeai/frontend/webv2/src/features/generation/core/canvas/compileCanvasGraph.ts b/invokeai/frontend/webv2/src/features/generation/core/canvas/compileCanvasGraph.ts
index 585971612d..072cdac916 100644
--- a/invokeai/frontend/webv2/src/features/generation/core/canvas/compileCanvasGraph.ts
+++ b/invokeai/frontend/webv2/src/features/generation/core/canvas/compileCanvasGraph.ts
@@ -11,7 +11,6 @@ import {
} from '@features/generation/core/baseGenerationPolicies';
import {
describeExternalCanvasRefusal,
- isExternalGenerationMode,
isExternalTextOnlyCanvasModel,
} from '@features/generation/core/externalProvider';
import { buildExternalGraph, getFamilyGraphBuilder } from '@features/generation/core/graph';
@@ -29,6 +28,7 @@ import { shouldUsePidDecode } from '@features/generation/core/pidGraph';
import { getEffectivePrompts } from '@features/generation/core/promptTemplates';
import { getBaseDenoisingRange } from '@features/generation/core/sdxlRefiner';
import { MAX_ANIMA_INPAINT_ADAPTER_WEIGHT, MIN_ANIMA_INPAINT_ADAPTER_WEIGHT } from '@features/generation/core/settings';
+import { isFluxFillModel } from '@features/models/architectures';
import type { CanvasInpaintSources } from './addControlLayers';
import type {
@@ -57,7 +57,7 @@ import { isAnimaInpaintAdapterModel } from './controlValidation';
/** SD-3, FLUX, FLUX.2, FLUX.3 and MOSS-Image start at 1 - strength^0.2; FLUX Fill at 0; others at 1 - strength. */
const canvasDenoisingStart = (model: GenerateModelConfig, strength: number): number => {
- if (model.base === 'flux' && model.variant === 'dev_fill') {
+ if (isFluxFillModel(model)) {
return 0;
}
const usesOptimizedCurve =
@@ -170,8 +170,12 @@ const getCanvasValidationReasons = (input: CompileCanvasGraphInput, processingSi
reasons.push('Canvas generation requires a composited source image.');
}
- // A provider edits at its own strength; only the local denoise reads this one.
- if (model.type !== 'external_image_generator' && (!Number.isFinite(strength) || strength <= 0 || strength > 1)) {
+ // A provider edits at its own strength and FLUX Fill always denoises fully; only other local denoises read this.
+ if (
+ model.type !== 'external_image_generator' &&
+ !isFluxFillModel(model) &&
+ (!Number.isFinite(strength) || strength <= 0 || strength > 1)
+ ) {
reasons.push('Canvas denoising strength must be greater than 0 and at most 1.');
}
}
@@ -512,6 +516,86 @@ const addAnimaInpaintAdapter = (
}
};
+/**
+ * Fades the regenerated area, restores the generated image and mask to the bbox, and composites the result over the
+ * canvas image. `mask` is black where the model generated; `maskSize` is the size it has.
+ */
+const addCanvasPasteBack = (
+ family: FamilyGraph,
+ args: {
+ bbox: CompileCanvasGraphInput['bbox'];
+ compositing: CanvasCompositingSettings;
+ destination: CompileCanvasGraphInput['destination'];
+ initialImageName: string;
+ mask: CanvasInpaintSources['mask'];
+ maskSize: CanvasSize;
+ processingSize: CanvasSize;
+ }
+): void => {
+ const { bbox, compositing, destination, initialImageName } = args;
+ const { graph } = family;
+
+ // The base decoder, until the composited output below takes over canvas_output from it.
+ const l2i = graph.nodes.canvas_output;
+ if (!l2i) {
+ throw new Error('Canvas generation could not find the base graph output.');
+ }
+
+ const expandMask = addNode(graph, {
+ fade_size_px: compositing.maskBlur,
+ id: 'expand_mask',
+ ...('node' in args.mask ? {} : { mask: args.mask }),
+ type: 'expand_mask_with_fade',
+ });
+ if ('node' in args.mask) {
+ addEdge(graph, args.mask.node, args.mask.field, expandMask, 'mask');
+ }
+
+ let generatedImageSource: BackendInvocationContract = l2i;
+ let outputMaskSource: BackendInvocationContract = expandMask;
+
+ if (!sizesMatch(bbox, args.processingSize)) {
+ generatedImageSource = addNode(graph, {
+ height: bbox.height,
+ id: 'canvas_resize_generated_to_bbox',
+ is_intermediate: true,
+ type: 'img_resize',
+ width: bbox.width,
+ });
+ addEdge(graph, l2i, 'image', generatedImageSource, 'image');
+ }
+ if (!sizesMatch(bbox, args.maskSize)) {
+ outputMaskSource = addNode(graph, {
+ height: bbox.height,
+ id: 'canvas_resize_output_mask_to_bbox',
+ is_intermediate: true,
+ type: 'img_resize',
+ width: bbox.width,
+ });
+ addEdge(graph, expandMask, 'image', outputMaskSource, 'image');
+ }
+
+ const { output } = replaceCanvasOutput(
+ graph,
+ 'canvas_l2i',
+ compositing.outputOnlyMaskedRegions
+ ? {
+ invert_mask: true,
+ is_intermediate: destination === 'canvas',
+ type: 'apply_mask_to_image',
+ use_cache: false,
+ }
+ : {
+ is_intermediate: destination === 'canvas',
+ layer_base: { image_name: initialImageName },
+ type: 'invokeai_img_blend',
+ use_cache: false,
+ }
+ );
+ addEdge(graph, generatedImageSource, 'image', output, compositing.outputOnlyMaskedRegions ? 'image' : 'layer_upper');
+ addEdge(graph, outputMaskSource, 'image', output, 'mask');
+};
+
/** Returns what the inpaint-conditioned adapters read. */
const graftMaskTail = (
family: FamilyGraph,
@@ -533,13 +617,6 @@ const graftMaskTail = (
): CanvasInpaintSources => {
const { compositing, destination, initialImageName, latents, model, settings } = args;
const { denoise, graph } = family;
- const needsResize = !sizesMatch(args.bbox, args.processingSize);
-
- // The base decoder, until the composited output below takes over canvas_output from it.
- const l2i = graph.nodes.canvas_output;
- if (!l2i) {
- throw new Error('Canvas generation could not find the base graph output.');
- }
const gradientMask = addNode(graph, {
coherence_mode: compositing.coherenceMode,
@@ -578,54 +655,15 @@ const graftMaskTail = (
});
}
- const expandMask = addNode(graph, {
- fade_size_px: compositing.maskBlur,
- id: 'expand_mask',
- type: 'expand_mask_with_fade',
+ addCanvasPasteBack(family, {
+ bbox: args.bbox,
+ compositing,
+ destination,
+ initialImageName,
+ mask: { field: 'expanded_mask_area', node: gradientMask },
+ maskSize: args.processingSize,
+ processingSize: args.processingSize,
});
- addEdge(graph, gradientMask, 'expanded_mask_area', expandMask, 'mask');
-
- let generatedImageSource: BackendInvocationContract = l2i;
- let outputMaskSource: BackendInvocationContract = expandMask;
-
- if (needsResize) {
- generatedImageSource = addNode(graph, {
- height: args.bbox.height,
- id: 'canvas_resize_generated_to_bbox',
- is_intermediate: true,
- type: 'img_resize',
- width: args.bbox.width,
- });
- outputMaskSource = addNode(graph, {
- height: args.bbox.height,
- id: 'canvas_resize_output_mask_to_bbox',
- is_intermediate: true,
- type: 'img_resize',
- width: args.bbox.width,
- });
- addEdge(graph, l2i, 'image', generatedImageSource, 'image');
- addEdge(graph, expandMask, 'image', outputMaskSource, 'image');
- }
-
- const { output } = replaceCanvasOutput(
- graph,
- 'canvas_l2i',
- compositing.outputOnlyMaskedRegions
- ? {
- invert_mask: true,
- is_intermediate: destination === 'canvas',
- type: 'apply_mask_to_image',
- use_cache: false,
- }
- : {
- is_intermediate: destination === 'canvas',
- layer_base: { image_name: initialImageName },
- type: 'invokeai_img_blend',
- use_cache: false,
- }
- );
- addEdge(graph, generatedImageSource, 'image', output, compositing.outputOnlyMaskedRegions ? 'image' : 'layer_upper');
- addEdge(graph, outputMaskSource, 'image', output, 'mask');
return inpaint;
};
@@ -658,6 +696,89 @@ const addNoiseBeforeEncode = (
return { edgeFrom: noise };
};
+/** The outpaint mask: transparent image areas generate, combined with an explicit inpaint mask when present. */
+const addOutpaintMask = (
+ graph: BackendGraphContract,
+ initialImageName: string,
+ maskImageName: string | null | undefined
+): { node: BackendInvocationContract; field: string } => {
+ const alphaToMask = addNode(graph, {
+ id: 'image_alpha_to_mask',
+ image: { image_name: initialImageName },
+ type: 'tomask',
+ });
+
+ if (!maskImageName) {
+ return { field: 'image', node: alphaToMask };
+ }
+ const maskCombine = addNode(graph, {
+ id: 'mask_combine',
+ mask1: { image_name: maskImageName },
+ type: 'mask_combine',
+ });
+ addEdge(graph, alphaToMask, 'image', maskCombine, 'mask2');
+ return { field: 'image', node: maskCombine };
+};
+
+/**
+ * FLUX Fill is conditioned on the image and mask itself, so it takes no latents, noise or denoise mask; the backend
+ * resizes the fill inputs to the denoise size, and only the result is restored to the bbox.
+ *
+ * Fill has no partial denoise, so a mask layer's denoise limit (a gray mask) does not apply: every pixel that is not
+ * white regenerates. The fill conditioning and the paste-back both read that binary mask, so the result is neither
+ * discarded nor blended by the gray level.
+ */
+const graftFluxFill = (
+ family: FamilyGraph,
+ input: CompileCanvasGraphInput,
+ compositing: CanvasCompositingSettings,
+ processingSize: CanvasSize,
+ mode: 'inpaint' | 'outpaint'
+): CanvasInpaintSources => {
+ const { denoise, graph } = family;
+ const initialImageName = input.compositeImageName as string;
+
+ setCanvasDenoisingRange(denoise, input.model, input.settings, input.strength);
+
+ const canvasMask: CanvasInpaintSources['mask'] =
+ mode === 'outpaint'
+ ? addOutpaintMask(graph, initialImageName, input.maskImageName)
+ : { image_name: input.maskImageName as string };
+ // Below white (cutoff 255) is True: regenerate.
+ const maskTensor = addNode(graph, {
+ cutoff: 255,
+ id: 'flux_fill_mask_tensor',
+ ...('node' in canvasMask ? {} : { image: canvasMask }),
+ type: 'image_mask_to_tensor',
+ });
+ if ('node' in canvasMask) {
+ addEdge(graph, canvasMask.node, canvasMask.field, maskTensor, 'image');
+ }
+ const fill = addNode(graph, { id: 'flux_fill', image: { image_name: initialImageName }, type: 'flux_fill' });
+ addEdge(graph, maskTensor, 'mask', fill, 'mask');
+ addEdge(graph, fill, 'fill_cond', denoise, 'fill_conditioning');
+
+ // White = keep, black = regenerate, the convention of the paste-back and of the control adapters.
+ const keepTensor = addNode(graph, { id: 'flux_fill_keep_tensor', type: 'invert_tensor_mask' });
+ addEdge(graph, maskTensor, 'mask', keepTensor, 'mask');
+ const keepMask = addNode(graph, { id: 'flux_fill_keep_mask', type: 'tensor_mask_to_image' });
+ addEdge(graph, keepTensor, 'mask', keepMask, 'mask');
+ const mask: CanvasInpaintSources['mask'] = { field: 'image', node: keepMask };
+
+ addCanvasPasteBack(family, {
+ bbox: input.bbox,
+ compositing,
+ destination: input.destination,
+ initialImageName,
+ mask,
+ maskSize: input.bbox,
+ processingSize,
+ });
+
+ setMetadataMode(graph, mode, input.strength);
+ return { image: { image_name: initialImageName }, mask };
+};
+
const graftInpaint = (
family: FamilyGraph,
input: CompileCanvasGraphInput,
@@ -745,25 +866,7 @@ const graftOutpaint = (
infill.image = { image_name: initialImageName };
}
- // Derive the mask from image alpha (transparent means generate), combining an explicit inpaint mask when present.
- const alphaToMask = addNode(graph, {
- id: 'image_alpha_to_mask',
- image: { image_name: initialImageName },
- type: 'tomask',
- });
-
- let gradientMaskEdge: { node: BackendInvocationContract; field: string };
- if (input.maskImageName) {
- const maskCombine = addNode(graph, {
- id: 'mask_combine',
- mask1: { image_name: input.maskImageName },
- type: 'mask_combine',
- });
- addEdge(graph, alphaToMask, 'image', maskCombine, 'mask2');
- gradientMaskEdge = { field: 'image', node: maskCombine };
- } else {
- gradientMaskEdge = { field: 'image', node: alphaToMask };
- }
+ let gradientMaskEdge = addOutpaintMask(graph, initialImageName, input.maskImageName);
if (needsResize) {
const maskResize = addNode(graph, {
@@ -965,7 +1068,7 @@ export const compileCanvasGraph = (input: CompileCanvasGraphInput): CompiledCanv
const validationReasons = [
...getCanvasValidationReasons(input, processingSize),
- ...getGenerationValidationReasons(model, settings, isExternalGenerationMode(mode) ? mode : 'txt2img'),
+ ...getGenerationValidationReasons(model, settings, mode),
];
if (validationReasons.length > 0) {
@@ -1022,10 +1125,12 @@ export const compileCanvasGraph = (input: CompileCanvasGraphInput): CompiledCanv
let inpaint: CanvasInpaintSources | undefined;
if (mode === 'img2img') {
graftImageToImage(family, model, settings, compositeImageName as string, strength, bbox);
- } else if (mode === 'inpaint') {
- inpaint = graftInpaint(family, input, compositing, processingSize);
- } else if (mode === 'outpaint') {
- inpaint = graftOutpaint(family, input, compositing, processingSize);
+ } else if (mode === 'inpaint' || mode === 'outpaint') {
+ if (isFluxFillModel(model)) {
+ inpaint = graftFluxFill(family, input, compositing, processingSize, mode);
+ } else {
+ inpaint = (mode === 'inpaint' ? graftInpaint : graftOutpaint)(family, input, compositing, processingSize);
+ }
}
// Inpaint and outpaint also hand the control adapters what they regenerate.
diff --git a/invokeai/frontend/webv2/src/features/generation/core/canvas/controlValidation.ts b/invokeai/frontend/webv2/src/features/generation/core/canvas/controlValidation.ts
index 76889bfd19..2853f3964c 100644
--- a/invokeai/frontend/webv2/src/features/generation/core/canvas/controlValidation.ts
+++ b/invokeai/frontend/webv2/src/features/generation/core/canvas/controlValidation.ts
@@ -1,4 +1,4 @@
-import { getArchitectureFeatures, hasArchitectureCapabilities } from '@features/models/architectures';
+import { getArchitectureFeatures, hasArchitectureCapabilities, isFluxFillModel } from '@features/models/architectures';
/** Every adapter kind a control layer can carry, in the order pickers list them. */
export const CONTROL_ADAPTER_KINDS = [
@@ -180,7 +180,7 @@ export const getControlValidationReason = (params: {
if (kind === 'anima_lllite' && lliteModelInUse) {
return 'duplicate_lllite_model';
}
- if (kind === 'control_lora' && mainBase === 'flux' && mainVariant === 'dev_fill') {
+ if (kind === 'control_lora' && isFluxFillModel({ base: mainBase, variant: mainVariant })) {
return 'flux_fill_control_lora';
}
if (kind === 'qwen_image_control' && mainBase === 'qwen-image' && mainVariant === 'edit') {
diff --git a/invokeai/frontend/webv2/src/features/generation/core/graph.ts b/invokeai/frontend/webv2/src/features/generation/core/graph.ts
index cffa8d27c8..ba18bf0d5d 100644
--- a/invokeai/frontend/webv2/src/features/generation/core/graph.ts
+++ b/invokeai/frontend/webv2/src/features/generation/core/graph.ts
@@ -734,10 +734,6 @@ const buildFluxGraph = (
outputIsIntermediate: boolean,
projectSettings: GenerationProjectSettings
): FamilyGraph => {
- if (model.variant === 'dev_fill') {
- throw new Error('FLUX Fill models do not support text-to-image generation.');
- }
-
const graph: BackendGraphContract = { edges: [], id: createId('flux_graph'), nodes: {} };
const { positivePrompt, seed } = addPromptAndSeedNodes(graph);
const hasBundledComponents = isSelfContainedSDNQFlux1Pipeline(model);
diff --git a/invokeai/frontend/webv2/src/features/generation/core/graphCoverage.test.ts b/invokeai/frontend/webv2/src/features/generation/core/graphCoverage.test.ts
index 9a072426e9..f67084e1f5 100644
--- a/invokeai/frontend/webv2/src/features/generation/core/graphCoverage.test.ts
+++ b/invokeai/frontend/webv2/src/features/generation/core/graphCoverage.test.ts
@@ -145,6 +145,38 @@ const sdxlCanvasCase = (colorCompensation: boolean) => {
return { base: 'sdxl' as const, filled, graph, shape };
};
+const fluxFillCanvasCase = () => {
+ const shape: ModelShape = {
+ label: 'canvas-fill-outpaint-masked',
+ overrides: { format: 'checkpoint', variant: 'dev_fill' },
+ };
+ const { filled, model, settings } = satisfiedSettingsFor('flux', shape);
+ const { backendGraph: graph } = compileCanvasGraph({
+ bbox: { height: 1024, width: 1024, x: 0, y: 0 },
+ compositeImageName: 'canvas-input.png',
+ compositing: {
+ coherenceEdgeSize: 16,
+ coherenceMinDenoise: 0,
+ coherenceMode: 'Gaussian Blur',
+ infillColorValue: { a: 1, b: 0, g: 0, r: 0 },
+ infillMethod: 'lama',
+ infillPatchmatchDownscaleSize: 1,
+ infillTileSize: 32,
+ maskBlur: 16,
+ outputOnlyMaskedRegions: false,
+ },
+ destination: 'canvas',
+ maskImageName: 'canvas-mask.png',
+ mode: 'outpaint',
+ model,
+ projectSettings: { useCpuNoise: true, useNsfwChecker: false, useWatermark: false },
+ settings,
+ strength: 1,
+ });
+
+ return { base: 'flux' as const, filled, graph, shape };
+};
+
const krea2EditCase = () => {
const { filled, model, settings } = satisfiedSettingsFor('krea-2', KREA2_EDIT_SHAPE);
const image = { original: { image: { height: 1024, image_name: 'edit-reference.png', width: 1024 } } };
@@ -338,6 +370,7 @@ describe('generate graph coverage', () => {
refinerCase(),
sdxlCanvasCase(false),
sdxlCanvasCase(true),
+ fluxFillCanvasCase(),
krea2EditCase(),
];
diff --git a/invokeai/frontend/webv2/src/features/generation/ui/GenerateRenderSection.tsx b/invokeai/frontend/webv2/src/features/generation/ui/GenerateRenderSection.tsx
index 9a628e9241..623d78c61e 100644
--- a/invokeai/frontend/webv2/src/features/generation/ui/GenerateRenderSection.tsx
+++ b/invokeai/frontend/webv2/src/features/generation/ui/GenerateRenderSection.tsx
@@ -12,6 +12,8 @@ import {
getDefaultGenerateSettings,
getGenerationUiPolicy,
getGuidanceBoundReason,
+ getGuidanceInputMax,
+ getGuidanceSliderMax,
getSchedulerOptions,
} from '@features/generation/core/baseGenerationPolicies';
import { getEffectivePrompts } from '@features/generation/core/promptTemplates';
@@ -79,10 +81,6 @@ const TIMESTEP_SHIFT_MARKS = [{ label: String(DEFAULT_TIMESTEP_SHIFT), value: DE
const DYPE_EXPONENT_SLIDER_MAX = 10;
const formatPercent = (value: number): string => `${value}%`;
-/** Slider tracks are practical ranges, not input bounds: FLUX Fill's default of 30 exceeds its track. */
-const GUIDANCE_SLIDER_MAX = 10;
-const GUIDANCE_INPUT_MAX = 100;
-
interface GenerateRenderSectionProps {
draft: GenerateDraft;
selectedModel: GenerateModelConfig | undefined;
@@ -644,8 +642,8 @@ export const GenerateRenderSection = ({
const guidanceLabel = isIdeogram4 ? t('widgets.generate.ideogram4GuidanceScale') : uiPolicy.guidanceLabel;
// Cap both input and track at the architecture ceiling without crossing the floor.
- const guidanceInputMax = uiPolicy.guidanceMax ?? GUIDANCE_INPUT_MAX;
- const guidanceSliderMax = Math.max(uiPolicy.guidanceMin, Math.min(GUIDANCE_SLIDER_MAX, guidanceInputMax));
+ const guidanceInputMax = getGuidanceInputMax(uiPolicy.guidanceMax);
+ const guidanceSliderMax = getGuidanceSliderMax(uiPolicy.guidanceMin, uiPolicy.guidanceMax);
// Validate recalled/persisted values inline because they bypass model-selection clamps.
const guidanceError = selectedModel ? getGuidanceBoundReason(selectedModel, settings.cfgScale) : null;
diff --git a/invokeai/frontend/webv2/src/features/models/architectures.ts b/invokeai/frontend/webv2/src/features/models/architectures.ts
index 58a3afc7bd..50237dd8cd 100644
--- a/invokeai/frontend/webv2/src/features/models/architectures.ts
+++ b/invokeai/frontend/webv2/src/features/models/architectures.ts
@@ -10,4 +10,4 @@ export {
withArchitectureCapabilities,
type ArchitectureCapabilitiesRow,
} from './core/architectureCapabilities';
-export { getModelBaseLabel } from './core/baseIdentity';
+export { getModelBaseLabel, isFluxFillModel } from './core/baseIdentity';
diff --git a/invokeai/frontend/webv2/src/features/models/core/baseIdentity.ts b/invokeai/frontend/webv2/src/features/models/core/baseIdentity.ts
index ad401320a6..27f6a219ed 100644
--- a/invokeai/frontend/webv2/src/features/models/core/baseIdentity.ts
+++ b/invokeai/frontend/webv2/src/features/models/core/baseIdentity.ts
@@ -199,3 +199,7 @@ export const isConvertibleToDiffusers = (model: Pick<ModelConfig, 'base' | 'form
model.format === 'checkpoint' &&
model.type === 'main' &&
Boolean(getModelBaseInfo(model.base).supportsDiffusersConversion);
+
+/** FLUX.1 Fill edits an image under a mask: it needs fill conditioning, so it cannot text-to-image, upscale or take a Control LoRA. */
+export const isFluxFillModel = (model: { base: string; variant?: unknown }): boolean =>
+ model.base === 'flux' && model.variant === 'dev_fill';
diff --git a/invokeai/frontend/webv2/src/features/upscale/core/settings.ts b/invokeai/frontend/webv2/src/features/upscale/core/settings.ts
index b5d7cd2ede..7d34ec1e50 100644
--- a/invokeai/frontend/webv2/src/features/upscale/core/settings.ts
+++ b/invokeai/frontend/webv2/src/features/upscale/core/settings.ts
@@ -38,7 +38,7 @@ import {
sanitizeBatchCount,
servesAsType,
} from '@features/generation/settings';
-import { hasArchitectureCapabilities } from '@features/models/architectures';
+import { hasArchitectureCapabilities, isFluxFillModel } from '@features/models/architectures';
import { isSeedMode, SEED_MAX } from '@platform/core/seed';
import type { SpandrelModelConfig, TileControlNetModelConfig, UpscaleMode, UpscaleWidgetValues } from './types';
@@ -925,7 +925,7 @@ export const getUpscaleValidationIssues = (
}
// `flux_denoise` refuses a Fill model without fill conditioning, which an upscale never supplies.
- if (values.model?.base === 'flux' && values.model.variant === 'dev_fill') {
+ if (values.model && isFluxFillModel(values.model)) {
issues.push({ message: 'Upscale cannot use a FLUX Fill model.', section: 'generation' });
}
// Without a reference, `qwen_image_denoise` gives Edit a zero reference doubling image tokens: ~3x time for nothing.