Skip to content

Commit 39e4199

Browse files
feat(ui): use latent-space kontext ref image concat in flux graph
Prevents a large spike in VRAM when preparing to denoise w/ multiple ref images. There doesn't appear to be any different in image quality / ref adherence when concatenating in latent space vs image space, though images _are_ different.
1 parent c6eff71 commit 39e4199

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

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

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,17 +156,24 @@ export const buildFLUXGraph = async (arg: GraphBuilderArg): Promise<GraphBuilder
156156
.filter((entity) => getGlobalReferenceImageWarnings(entity, model).length === 0);
157157

158158
if (validFLUXKontextConfigs.length > 0) {
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)),
159+
const fluxKontextCollect = g.addNode({
160+
type: 'collect',
161+
id: getPrefixedId('flux_kontext_collect'),
163162
});
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');
163+
for (const { config } of validFLUXKontextConfigs) {
164+
const kontextImagePrep = g.addNode({
165+
id: getPrefixedId('flux_kontext_image_prep'),
166+
type: 'flux_kontext_image_prep',
167+
images: [zImageField.parse(config.image)],
168+
});
169+
const kontextConditioning = g.addNode({
170+
type: 'flux_kontext',
171+
id: getPrefixedId('flux_kontext'),
172+
});
173+
g.addEdge(kontextImagePrep, 'image', kontextConditioning, 'image');
174+
g.addEdge(kontextConditioning, 'kontext_cond', fluxKontextCollect, 'item');
175+
}
176+
g.addEdge(fluxKontextCollect, 'collection', denoise, 'kontext_conditioning');
170177

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

0 commit comments

Comments
 (0)