From 01100a2b9a439958fee2f3a664d500087c824a34 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Fri, 4 Jul 2025 19:44:55 +1000 Subject: [PATCH] fix(ui): check for ref image config compatibility for flux kontext dev --- .../util/graph/generation/buildFLUXGraph.ts | 36 +++++++++++++------ 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/invokeai/frontend/web/src/features/nodes/util/graph/generation/buildFLUXGraph.ts b/invokeai/frontend/web/src/features/nodes/util/graph/generation/buildFLUXGraph.ts index c97b34a174..6aec9cad23 100644 --- a/invokeai/frontend/web/src/features/nodes/util/graph/generation/buildFLUXGraph.ts +++ b/invokeai/frontend/web/src/features/nodes/util/graph/generation/buildFLUXGraph.ts @@ -3,6 +3,8 @@ import { getPrefixedId } from 'features/controlLayers/konva/util'; import { selectMainModelConfig, selectParamsSlice } from 'features/controlLayers/store/paramsSlice'; import { selectRefImagesSlice } from 'features/controlLayers/store/refImagesSlice'; import { selectCanvasMetadata, selectCanvasSlice } from 'features/controlLayers/store/selectors'; +import { isFluxKontextReferenceImageConfig } from 'features/controlLayers/store/types'; +import { getGlobalReferenceImageWarnings } from 'features/controlLayers/store/validators'; import { addFLUXFill } from 'features/nodes/util/graph/generation/addFLUXFill'; import { addFLUXLoRAs } from 'features/nodes/util/graph/generation/addFLUXLoRAs'; import { addFLUXReduxes } from 'features/nodes/util/graph/generation/addFLUXRedux'; @@ -88,10 +90,9 @@ export const buildFLUXGraph = async (arg: GraphBuilderArg): Promise entity.isEnabled) + .filter((entity) => isFluxKontextReferenceImageConfig(entity.config)) + .filter((entity) => getGlobalReferenceImageWarnings(entity, model).length === 0); + + // FLUX Kontext supports only a single conditioning image - we'll just take the first one. + // In the future, we can explore concatenating multiple conditioning images in image or latent space. + const firstValidFLUXKontextConfig = validFLUXKontextConfigs[0]; + + if (firstValidFLUXKontextConfig) { + const { image } = firstValidFLUXKontextConfig.config; + + assert(image, 'getGlobalReferenceImageWarnings checks if the image is there, this should never raise'); + + const kontextConditioning = g.addNode({ + type: 'flux_kontext', + id: getPrefixedId('flux_kontext'), + image, + }); + g.addEdge(kontextConditioning, 'kontext_cond', denoise, 'kontext_conditioning'); + } } g.addEdge(modelLoader, 'transformer', denoise, 'transformer');