Skip to content

Commit d591b50

Browse files
feat(ui): use image-space concatenation in FLUX graphs
1 parent b365aad commit d591b50

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

invokeai/frontend/web/src/features/nodes/util/graph/generation/buildFLUXGraph.ts

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { selectRefImagesSlice } from 'features/controlLayers/store/refImagesSlic
55
import { selectCanvasMetadata, selectCanvasSlice } from 'features/controlLayers/store/selectors';
66
import { isFluxKontextReferenceImageConfig } from 'features/controlLayers/store/types';
77
import { getGlobalReferenceImageWarnings } from 'features/controlLayers/store/validators';
8+
import { zImageField } from 'features/nodes/types/common';
89
import { addFLUXFill } from 'features/nodes/util/graph/generation/addFLUXFill';
910
import { addFLUXLoRAs } from 'features/nodes/util/graph/generation/addFLUXLoRAs';
1011
import { addFLUXReduxes } from 'features/nodes/util/graph/generation/addFLUXRedux';
@@ -155,24 +156,17 @@ export const buildFLUXGraph = async (arg: GraphBuilderArg): Promise<GraphBuilder
155156
.filter((entity) => getGlobalReferenceImageWarnings(entity, model).length === 0);
156157

157158
if (validFLUXKontextConfigs.length > 0) {
158-
const kontextCollector = g.addNode({
159-
id: getPrefixedId('flux_kontext_collector'),
160-
type: 'collect',
159+
const kontextConcatenator = g.addNode({
160+
id: getPrefixedId('flux_kontext_image_prep'),
161+
type: 'flux_kontext_image_prep',
162+
images: validFLUXKontextConfigs.map(({ config }) => zImageField.parse(config.image)),
161163
});
162-
g.addEdge(kontextCollector, 'collection', denoise, 'kontext_conditioning');
163-
164-
for (const kontextConfig of validFLUXKontextConfigs) {
165-
const { image } = kontextConfig.config;
166-
167-
assert(image, 'getGlobalReferenceImageWarnings checks if the image is there, this should never raise');
168-
169-
const kontextConditioning = g.addNode({
170-
type: 'flux_kontext',
171-
id: getPrefixedId(`flux_kontext_${kontextConfig.id}`),
172-
image,
173-
});
174-
g.addEdge(kontextConditioning, 'kontext_cond', kontextCollector, 'item');
175-
}
164+
const kontextConditioning = g.addNode({
165+
type: 'flux_kontext',
166+
id: getPrefixedId('flux_kontext'),
167+
});
168+
g.addEdge(kontextConcatenator, 'image', kontextConditioning, 'image');
169+
g.addEdge(kontextConditioning, 'kontext_cond', denoise, 'kontext_conditioning');
176170

177171
g.upsertMetadata({ ref_images: [validFLUXKontextConfigs] }, 'merge');
178172
}

0 commit comments

Comments
 (0)