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(frontend): Make ordering of multiple FLUX.2 reference images deterministic (#8989)

Lincoln Stein7f2878f691b2
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 db7cba5961..ba27e5dbf6 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
@@ -271,10 +271,7 @@ export const buildFLUXGraph = async (arg: GraphBuilderArg): Promise<GraphBuilder
.filter((entity) => getGlobalReferenceImageWarnings(entity, model).length === 0);
if (validFlux2RefImageConfigs.length > 0) {
- const flux2KontextCollect = g.addNode({
- type: 'collect',
- id: getPrefixedId('flux2_kontext_collect'),
- });
+ let prevCollect: Invocation<'collect'> | null = null;
for (const { config } of validFlux2RefImageConfigs) {
// FLUX.2 uses the same flux_kontext node - it just packages the image
const kontextConditioning = g.addNode({
@@ -282,9 +279,18 @@ export const buildFLUXGraph = async (arg: GraphBuilderArg): Promise<GraphBuilder
id: getPrefixedId('flux_kontext'),
image: zImageField.parse(config.image?.crop?.image ?? config.image?.original.image),
});
- g.addEdge(kontextConditioning, 'kontext_cond', flux2KontextCollect, 'item');
+ const collectNode = g.addNode({
+ type: 'collect',
+ id: getPrefixedId('flux2_kontext_collect'),
+ });
+ g.addEdge(kontextConditioning, 'kontext_cond', collectNode, 'item');
+ if (prevCollect !== null) {
+ g.addEdge(prevCollect, 'collection', collectNode, 'collection');
+ }
+ prevCollect = collectNode;
}
- g.addEdge(flux2KontextCollect, 'collection', flux2Denoise, 'kontext_conditioning');
+ assert(prevCollect !== null);
+ g.addEdge(prevCollect, 'collection', flux2Denoise, 'kontext_conditioning');
g.upsertMetadata({ ref_images: validFlux2RefImageConfigs }, 'merge');
}