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.

feat(webv2): add Krea 2 regional guidance

joshistoastd62f7944c1d1
diff --git a/invokeai/frontend/webv2/src/features/generation/core/canvas/addRegionalGuidance.test.ts b/invokeai/frontend/webv2/src/features/generation/core/canvas/addRegionalGuidance.test.ts
index b50c90a839..feaa093a2a 100644
--- a/invokeai/frontend/webv2/src/features/generation/core/canvas/addRegionalGuidance.test.ts
+++ b/invokeai/frontend/webv2/src/features/generation/core/canvas/addRegionalGuidance.test.ts
@@ -92,6 +92,26 @@ const flux2BaseGraph = (): TestGraph => ({
},
});
+/** A minimal Krea-2 graph with its Qwen3-VL encoder and positive collector seam. */
+const krea2BaseGraph = (): TestGraph => ({
+ edges: [
+ {
+ destination: { field: 'qwen3_vl_encoder', node_id: 'pos_cond' },
+ source: { field: 'qwen3_vl_encoder', node_id: 'model_loader' },
+ },
+ {
+ destination: { field: 'positive_conditioning', node_id: 'denoise_latents' },
+ source: { field: 'collection', node_id: 'pos_cond_collect' },
+ },
+ ],
+ id: 'g',
+ nodes: {
+ denoise_latents: { id: 'denoise_latents', type: 'krea2_denoise' },
+ pos_cond: { id: 'pos_cond', type: 'krea2_text_encoder' },
+ pos_cond_collect: { id: 'pos_cond_collect', type: 'collect' },
+ },
+});
+
const ipModel = (base: string): RegionalReferenceModel => ({
base,
key: `ip-${base}`,
@@ -121,16 +141,45 @@ const hasEdge = (graph: TestGraph, s: string, sf: string, d: string, df: string)
);
describe('isRegionalGuidanceSupportedForBase', () => {
- it('supports sd-1 / sdxl / flux / flux2 and nothing else', () => {
+ it('supports sd-1 / sdxl / flux / flux2 / krea-2 and nothing else', () => {
expect(isRegionalGuidanceSupportedForBase('sd-1')).toBe(true);
expect(isRegionalGuidanceSupportedForBase('sdxl')).toBe(true);
expect(isRegionalGuidanceSupportedForBase('flux')).toBe(true);
expect(isRegionalGuidanceSupportedForBase('flux2')).toBe(true);
+ expect(isRegionalGuidanceSupportedForBase('krea-2')).toBe(true);
expect(isRegionalGuidanceSupportedForBase('sd-3')).toBe(false);
expect(isRegionalGuidanceSupportedForBase('cogview4')).toBe(false);
});
});
+describe('addRegionalGuidance — Krea-2', () => {
+ it('creates positive-only masked conditioning, copies Qwen3-VL, and collects the transformed source', () => {
+ const graph = krea2BaseGraph();
+ const transformCalls: Array<{ nodeId: string; regionId: string }> = [];
+ const g = run(graph, {
+ base: 'krea-2',
+ regions: [region({ negativePrompt: null })],
+ transformRegionalPositiveConditioning: (conditioning, regionId) => {
+ transformCalls.push({ nodeId: conditioning.id, regionId });
+ const transformed = { id: `transformed_${regionId}`, type: 'krea2_seed_variance' };
+ graph.nodes[transformed.id] = transformed;
+ graph.edges.push({
+ destination: { field: 'conditioning', node_id: transformed.id },
+ source: { field: 'conditioning', node_id: conditioning.id },
+ });
+ return transformed;
+ },
+ });
+
+ expect(g.nodes.rg_pos_cond_r1).toMatchObject({ prompt: 'a cat', type: 'krea2_text_encoder' });
+ expect(hasEdge(g, 'model_loader', 'qwen3_vl_encoder', 'rg_pos_cond_r1', 'qwen3_vl_encoder')).toBe(true);
+ expect(hasEdge(g, 'rg_mask_to_tensor_r1', 'mask', 'rg_pos_cond_r1', 'mask')).toBe(true);
+ expect(transformCalls).toEqual([{ nodeId: 'rg_pos_cond_r1', regionId: 'r1' }]);
+ expect(hasEdge(g, 'transformed_r1', 'conditioning', 'pos_cond_collect', 'item')).toBe(true);
+ expect(hasEdge(g, 'rg_pos_cond_r1', 'conditioning', 'pos_cond_collect', 'item')).toBe(false);
+ });
+});
+
describe('addRegionalGuidance — FLUX.2 Klein', () => {
it('creates mask-scoped positive conditioning and copies Qwen3 inputs', () => {
const g = run(flux2BaseGraph(), { base: 'flux2', regions: [region()] });
@@ -358,4 +407,16 @@ describe('getRegionalGuidanceRejectionReason', () => {
/reference images are not supported for FLUX\.2/
);
});
+
+ it('rejects Krea-2 negative prompts, autoNegative, and reference images', () => {
+ expect(getRegionalGuidanceRejectionReason({ ...params, mainBase: 'krea-2', negativePrompt: 'blurry' })).toMatch(
+ /negative prompts are not supported for Krea-2/
+ );
+ expect(getRegionalGuidanceRejectionReason({ ...params, autoNegative: true, mainBase: 'krea-2' })).toMatch(
+ /auto-negative is not supported for Krea-2/
+ );
+ expect(getRegionalGuidanceRejectionReason({ ...params, mainBase: 'krea-2', referenceImageCount: 1 })).toMatch(
+ /reference images are not supported for Krea-2/
+ );
+ });
});
diff --git a/invokeai/frontend/webv2/src/features/generation/core/canvas/addRegionalGuidance.ts b/invokeai/frontend/webv2/src/features/generation/core/canvas/addRegionalGuidance.ts
index f270bb22cd..6c385c1e2a 100644
--- a/invokeai/frontend/webv2/src/features/generation/core/canvas/addRegionalGuidance.ts
+++ b/invokeai/frontend/webv2/src/features/generation/core/canvas/addRegionalGuidance.ts
@@ -11,13 +11,13 @@ const POS_COND_COLLECT_ID = 'pos_cond_collect';
const NEG_COND_COLLECT_ID = 'neg_cond_collect';
/** The base models regional guidance supports. */
-export type RegionalGuidanceBase = 'sd-1' | 'sdxl' | 'flux' | 'flux2';
+export type RegionalGuidanceBase = 'sd-1' | 'sdxl' | 'flux' | 'flux2' | 'krea-2';
/** True when `base` supports regional guidance at all. */
export const isRegionalGuidanceSupportedForBase = (base: string): base is RegionalGuidanceBase =>
- base === 'sd-1' || base === 'sdxl' || base === 'flux' || base === 'flux2';
+ base === 'sd-1' || base === 'sdxl' || base === 'flux' || base === 'flux2' || base === 'krea-2';
-/** Whether a base supports regional NEGATIVE prompts / autoNegative (SD family only, not FLUX). */
+/** Whether a base supports regional NEGATIVE prompts / autoNegative (SD family only). */
const supportsRegionalNegative = (base: RegionalGuidanceBase): boolean => base === 'sd-1' || base === 'sdxl';
/** A resolved reference-image (component) model identifier — the backend model field shape. */
@@ -72,6 +72,11 @@ export interface RegionalGuidanceInput {
export interface AddRegionalGuidanceOptions {
base: RegionalGuidanceBase;
regions: readonly RegionalGuidanceInput[];
+ /** Applies model-specific transforms before a regional positive conditioning is collected. */
+ transformRegionalPositiveConditioning?: (
+ conditioning: BackendInvocationContract,
+ regionId: string
+ ) => BackendInvocationContract;
}
/** Per-base conditioning encoder node type + the fields carrying the prompt. */
@@ -83,6 +88,8 @@ const conditioningNodeType = (base: RegionalGuidanceBase): string => {
return 'flux_text_encoder';
case 'flux2':
return 'flux2_klein_text_encoder';
+ case 'krea-2':
+ return 'krea2_text_encoder';
case 'sd-1':
return 'compel';
}
@@ -105,6 +112,8 @@ const copyEncoderFields = (base: RegionalGuidanceBase): readonly string[] => {
return ['clip', 't5_encoder', 't5_max_seq_len'];
case 'flux2':
return ['qwen3_encoder', 'max_seq_len'];
+ case 'krea-2':
+ return ['qwen3_vl_encoder'];
case 'sd-1':
return ['clip'];
}
@@ -183,7 +192,7 @@ const addRegionalConditioning = (
* - reference images → mask-scoped `ip_adapter` (SD) / `flux_redux` (FLUX).
*/
export const addRegionalGuidance = (graph: BackendGraphContract, options: AddRegionalGuidanceOptions): void => {
- const { base, regions } = options;
+ const { base, regions, transformRegionalPositiveConditioning } = options;
const denoise = graph.nodes[DENOISE_NODE_ID];
if (!denoise) {
throw new Error('addRegionalGuidance: base graph is missing the denoise node.');
@@ -215,7 +224,8 @@ export const addRegionalGuidance = (graph: BackendGraphContract, options: AddReg
POS_COND_ID
);
addEdge(graph, maskToTensor, 'mask', posCond, 'mask');
- addEdge(graph, posCond, 'conditioning', posCondCollect, 'item');
+ const conditioningSource = transformRegionalPositiveConditioning?.(posCond, region.id) ?? posCond;
+ addEdge(graph, conditioningSource, 'conditioning', posCondCollect, 'item');
}
// Negative prompt → negative collector (SD only; FLUX has no negative path).
@@ -249,7 +259,7 @@ export const addRegionalGuidance = (graph: BackendGraphContract, options: AddReg
// Reference images (mask-scoped): ip_adapter on SD, flux_redux on FLUX.
for (const ref of region.referenceImages) {
- if (ref.type === 'ip_adapter' && base !== 'flux' && base !== 'flux2') {
+ if (ref.type === 'ip_adapter' && (base === 'sd-1' || base === 'sdxl')) {
if (!ipAdapterCollector) {
ipAdapterCollector = resolveDenoiseCollector(graph, denoise, 'ip_adapter', 'regional_ip_adapter_collector');
}
@@ -297,8 +307,8 @@ export const addRegionalGuidance = (graph: BackendGraphContract, options: AddReg
* - unsupported main base (sd-2 / sd-3 / cogview / …) → "unsupported model";
* - no drawn mask content → "no region";
* - no positive prompt, no negative prompt, and no reference images → "empty";
- * - FLUX-family negative prompts / autoNegative are unsupported;
- * - FLUX.2 regional reference images are unsupported.
+ * - FLUX-family and Krea-2 negative prompts / autoNegative are unsupported;
+ * - FLUX.2 and Krea-2 regional reference images are unsupported.
*
* Per-reference-image model/image validity is resolved by the caller (which drops
* incomplete reference images before building), matching how control layers work.
@@ -323,14 +333,15 @@ export const getRegionalGuidanceRejectionReason = (params: {
if (!positivePrompt && !negativePrompt && referenceImageCount === 0) {
return `Regional guidance "${layerName}" has no prompt or reference image.`;
}
- if ((mainBase === 'flux' || mainBase === 'flux2') && negativePrompt) {
- return `Regional guidance "${layerName}" negative prompts are not supported for ${mainBase === 'flux2' ? 'FLUX.2' : 'FLUX'}.`;
+ const positiveOnlyLabel = mainBase === 'flux' ? 'FLUX' : mainBase === 'flux2' ? 'FLUX.2' : 'Krea-2';
+ if ((mainBase === 'flux' || mainBase === 'flux2' || mainBase === 'krea-2') && negativePrompt) {
+ return `Regional guidance "${layerName}" negative prompts are not supported for ${positiveOnlyLabel}.`;
}
- if ((mainBase === 'flux' || mainBase === 'flux2') && autoNegative) {
- return `Regional guidance "${layerName}" auto-negative is not supported for ${mainBase === 'flux2' ? 'FLUX.2' : 'FLUX'}.`;
+ if ((mainBase === 'flux' || mainBase === 'flux2' || mainBase === 'krea-2') && autoNegative) {
+ return `Regional guidance "${layerName}" auto-negative is not supported for ${positiveOnlyLabel}.`;
}
- if (mainBase === 'flux2' && referenceImageCount > 0) {
- return `Regional guidance "${layerName}" reference images are not supported for FLUX.2.`;
+ if ((mainBase === 'flux2' || mainBase === 'krea-2') && referenceImageCount > 0) {
+ return `Regional guidance "${layerName}" reference images are not supported for ${positiveOnlyLabel}.`;
}
return null;
};
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 98d91bada1..d082282819 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
@@ -45,6 +45,13 @@ const zImageModel: MainModelConfig = {
type: 'main',
};
const animaModel: MainModelConfig = { base: 'anima', key: 'anima-model', name: 'Anima', type: 'main' };
+const krea2Model: MainModelConfig = {
+ base: 'krea-2',
+ format: 'diffusers',
+ key: 'krea2-model',
+ name: 'Krea-2',
+ type: 'main',
+};
const externalModel: GenerateModelConfig = {
base: 'external',
capabilities: { modes: ['txt2img'], supports_seed: true },
@@ -770,4 +777,30 @@ describe('compileCanvasGraph — regional guidance', () => {
expect(getEdge(backendGraph, 'rg_pos_cond_r1', 'qwen3_encoder')?.source.node_id).toBe('model_loader');
expect(getEdge(backendGraph, 'pos_cond_collect', 'item')?.source.node_id).toBe('pos_cond');
});
+
+ it('grafts Krea-2 regions through uniquely named conditioning enhancers into the shared collector', () => {
+ const { backendGraph } = compile(krea2Model, 'txt2img', {
+ regionalGuidance: [region('r1'), region('r2', { positivePrompt: 'a dog' })],
+ settings: {
+ krea2RebalanceEnabled: true,
+ krea2SeedVarianceEnabled: true,
+ krea2SeedVarianceStrength: 0.2,
+ },
+ });
+
+ expect(backendGraph.nodes.rg_pos_cond_r1).toMatchObject({ prompt: 'a cat', type: 'krea2_text_encoder' });
+ expect(backendGraph.nodes.rg_pos_cond_r2).toMatchObject({ prompt: 'a dog', type: 'krea2_text_encoder' });
+ expect(getEdge(backendGraph, 'rg_pos_cond_r1', 'qwen3_vl_encoder')?.source.node_id).toBe('model_loader');
+ expect(backendGraph.nodes.rg_krea2_r1_rebalance?.type).toBe('krea2_conditioning_rebalance');
+ expect(backendGraph.nodes.rg_krea2_r2_rebalance?.type).toBe('krea2_conditioning_rebalance');
+ expect(backendGraph.nodes.rg_krea2_r1_seed_variance?.type).toBe('krea2_seed_variance');
+ expect(backendGraph.nodes.rg_krea2_r2_seed_variance?.type).toBe('krea2_seed_variance');
+ expect(getEdge(backendGraph, 'rg_krea2_r1_seed_variance', 'variance_seed')?.source.node_id).toBe('seed');
+ expect(getEdge(backendGraph, 'denoise_latents', 'positive_conditioning')?.source.node_id).toBe('pos_cond_collect');
+
+ const collectedSources = backendGraph.edges
+ .filter((edge) => edge.destination.node_id === 'pos_cond_collect' && edge.destination.field === 'item')
+ .map((edge) => edge.source.node_id);
+ expect(collectedSources).toEqual(['krea2_seed_variance', 'rg_krea2_r1_seed_variance', 'rg_krea2_r2_seed_variance']);
+ });
});
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 b31598dbf7..a676cda5ac 100644
--- a/invokeai/frontend/webv2/src/features/generation/core/canvas/compileCanvasGraph.ts
+++ b/invokeai/frontend/webv2/src/features/generation/core/canvas/compileCanvasGraph.ts
@@ -30,6 +30,7 @@ import type { GenerateModelConfig, GenerateSettings } from '@features/generation
import { getGenerationValidationReasons } from '@features/generation/core/baseGenerationPolicies';
import { GRAPH_BUILDERS } from '@features/generation/core/graph';
import { addEdge, addNode, toGraphContract } from '@features/generation/core/graphBuilder';
+import { addKrea2ConditioningEnhancers } from '@features/generation/core/krea2Conditioning';
import { getIsPidSupportedBase } from '@features/generation/core/pid';
import type {
@@ -547,9 +548,29 @@ export const compileCanvasGraph = (input: CompileCanvasGraphInput): CompiledCanv
// Regional guidance applies in every mode too. The executor already composited
// + uploaded each region's mask and resolved its reference-image models; it
- // passes only valid regions for a supported base (sd-1 / sdxl / flux).
+ // passes only valid regions for a supported base (SD1 / SDXL / FLUX / FLUX.2 / Krea-2).
if (input.regionalGuidance && input.regionalGuidance.length > 0 && isRegionalGuidanceSupportedForBase(model.base)) {
- addRegionalGuidance(backendGraph, { base: model.base, regions: input.regionalGuidance });
+ addRegionalGuidance(backendGraph, {
+ base: model.base,
+ regions: input.regionalGuidance,
+ ...(model.base === 'krea-2'
+ ? {
+ transformRegionalPositiveConditioning: (conditioning: BackendInvocationContract, regionId: string) => {
+ const seed = backendGraph.nodes.seed;
+ if (!seed) {
+ throw new Error('Krea-2 regional guidance requires the base graph seed node.');
+ }
+ return addKrea2ConditioningEnhancers({
+ conditioning,
+ graph: backendGraph,
+ idPrefix: `rg_krea2_${regionId}`,
+ seed,
+ settings,
+ });
+ },
+ }
+ : {}),
+ });
}
return {
diff --git a/invokeai/frontend/webv2/src/features/generation/core/graph.test.ts b/invokeai/frontend/webv2/src/features/generation/core/graph.test.ts
index 4eb3e6a7ea..63c980cfab 100644
--- a/invokeai/frontend/webv2/src/features/generation/core/graph.test.ts
+++ b/invokeai/frontend/webv2/src/features/generation/core/graph.test.ts
@@ -687,7 +687,8 @@ describe('Krea-2, Ideogram 4 and Wan graphs', () => {
expect(getNodeByType(graph, 'krea2_conditioning_rebalance')).toBeUndefined();
expect(getNodeByType(graph, 'krea2_seed_variance')).toBeUndefined();
- expect(getEdge(graph, 'denoise_latents', 'positive_conditioning')?.source.node_id).toBe('pos_cond');
+ expect(getEdge(graph, 'pos_cond_collect', 'item')?.source.node_id).toBe('pos_cond');
+ expect(getEdge(graph, 'denoise_latents', 'positive_conditioning')?.source.node_id).toBe('pos_cond_collect');
});
it('chains rebalance then seed variance between the Krea-2 encoder and denoise', () => {
@@ -699,7 +700,8 @@ describe('Krea-2, Ideogram 4 and Wan graphs', () => {
expect(getEdge(graph, 'krea2_rebalance', 'conditioning')?.source.node_id).toBe('pos_cond');
expect(getEdge(graph, 'krea2_seed_variance', 'conditioning')?.source.node_id).toBe('krea2_rebalance');
- expect(getEdge(graph, 'denoise_latents', 'positive_conditioning')?.source.node_id).toBe('krea2_seed_variance');
+ expect(getEdge(graph, 'pos_cond_collect', 'item')?.source.node_id).toBe('krea2_seed_variance');
+ expect(getEdge(graph, 'denoise_latents', 'positive_conditioning')?.source.node_id).toBe('pos_cond_collect');
// Seed variance needs the seed to be reproducible run-to-run.
expect(getEdge(graph, 'krea2_seed_variance', 'variance_seed')?.source.node_id).toBe('seed');
});
diff --git a/invokeai/frontend/webv2/src/features/generation/core/graph.ts b/invokeai/frontend/webv2/src/features/generation/core/graph.ts
index 3c64380075..692fb2ae5b 100644
--- a/invokeai/frontend/webv2/src/features/generation/core/graph.ts
+++ b/invokeai/frontend/webv2/src/features/generation/core/graph.ts
@@ -43,6 +43,7 @@ import {
toModelIdentifier,
toGraphContract,
} from './graphBuilder';
+import { addKrea2ConditioningEnhancers } from './krea2Conditioning';
import { addPidDecode, getPidDenoiseSize, getPidMetadata, shouldUsePidDecode } from './pidGraph';
import { getEffectiveReferenceImage } from './referenceImage';
import { SEED_MAX } from './settings';
@@ -1123,6 +1124,7 @@ const buildKrea2Graph = (
])
: modelLoader;
const posCond = addNode(graph, { id: 'pos_cond', type: 'krea2_text_encoder' });
+ const posCondCollect = addNode(graph, { id: 'pos_cond_collect', type: 'collect' });
const negCond = useCfg ? addNode(graph, { id: 'neg_cond', type: 'krea2_text_encoder' }) : null;
const denoise = addNode(graph, {
cfg_scale: settings.cfgScale,
@@ -1140,36 +1142,15 @@ const buildKrea2Graph = (
addEdge(graph, modelLoader, 'vae', output, 'vae');
addEdge(graph, positivePrompt, 'value', posCond, 'prompt');
- // Optional conditioning enhancers, both default-off, chained between the encoder and denoise:
- // rebalance first (scale the signal toward the prompt), then seed variance (perturb it).
- let positiveConditioningSource = posCond;
-
- if (settings.krea2RebalanceEnabled) {
- const rebalance = addNode(graph, {
- id: 'krea2_rebalance',
- multiplier: settings.krea2RebalanceMultiplier,
- per_layer_weights: settings.krea2RebalanceWeights,
- type: 'krea2_conditioning_rebalance',
- });
-
- addEdge(graph, positiveConditioningSource, 'conditioning', rebalance, 'conditioning');
- positiveConditioningSource = rebalance;
- }
-
- if (settings.krea2SeedVarianceEnabled && settings.krea2SeedVarianceStrength > 0) {
- const seedVariance = addNode(graph, {
- id: 'krea2_seed_variance',
- randomize_percent: settings.krea2SeedVarianceRandomizePercent,
- strength: settings.krea2SeedVarianceStrength,
- type: 'krea2_seed_variance',
- });
-
- addEdge(graph, positiveConditioningSource, 'conditioning', seedVariance, 'conditioning');
- addEdge(graph, seed, 'value', seedVariance, 'variance_seed');
- positiveConditioningSource = seedVariance;
- }
-
- addEdge(graph, positiveConditioningSource, 'conditioning', denoise, 'positive_conditioning');
+ const positiveConditioningSource = addKrea2ConditioningEnhancers({
+ conditioning: posCond,
+ graph,
+ idPrefix: 'krea2',
+ seed,
+ settings,
+ });
+ addEdge(graph, positiveConditioningSource, 'conditioning', posCondCollect, 'item');
+ addEdge(graph, posCondCollect, 'collection', denoise, 'positive_conditioning');
if (negCond) {
addEdge(graph, loraSource, 'qwen3_vl_encoder', negCond, 'qwen3_vl_encoder');
diff --git a/invokeai/frontend/webv2/src/features/generation/core/krea2Conditioning.ts b/invokeai/frontend/webv2/src/features/generation/core/krea2Conditioning.ts
new file mode 100644
index 0000000000..42fd8fb388
--- /dev/null
+++ b/invokeai/frontend/webv2/src/features/generation/core/krea2Conditioning.ts
@@ -0,0 +1,61 @@
+import type { BackendGraphContract, BackendInvocationContract } from '@features/generation/core/contracts';
+import type { GenerateSettings } from '@features/generation/core/types';
+
+import { addEdge, addNode } from './graphBuilder';
+
+type Krea2ConditioningSettings = Pick<
+ GenerateSettings,
+ | 'krea2RebalanceEnabled'
+ | 'krea2RebalanceMultiplier'
+ | 'krea2RebalanceWeights'
+ | 'krea2SeedVarianceEnabled'
+ | 'krea2SeedVarianceRandomizePercent'
+ | 'krea2SeedVarianceStrength'
+>;
+
+/**
+ * Applies Krea-2's optional conditioning transforms in their required order.
+ * `idPrefix` makes the same chain safe for any number of regional prompts.
+ */
+export const addKrea2ConditioningEnhancers = ({
+ conditioning,
+ graph,
+ idPrefix,
+ seed,
+ settings,
+}: {
+ conditioning: BackendInvocationContract;
+ graph: BackendGraphContract;
+ idPrefix: string;
+ seed: BackendInvocationContract;
+ settings: Krea2ConditioningSettings;
+}): BackendInvocationContract => {
+ let source = conditioning;
+
+ if (settings.krea2RebalanceEnabled) {
+ const rebalance = addNode(graph, {
+ id: `${idPrefix}_rebalance`,
+ multiplier: settings.krea2RebalanceMultiplier,
+ per_layer_weights: settings.krea2RebalanceWeights,
+ type: 'krea2_conditioning_rebalance',
+ });
+
+ addEdge(graph, source, 'conditioning', rebalance, 'conditioning');
+ source = rebalance;
+ }
+
+ if (settings.krea2SeedVarianceEnabled && settings.krea2SeedVarianceStrength > 0) {
+ const seedVariance = addNode(graph, {
+ id: `${idPrefix}_seed_variance`,
+ randomize_percent: settings.krea2SeedVarianceRandomizePercent,
+ strength: settings.krea2SeedVarianceStrength,
+ type: 'krea2_seed_variance',
+ });
+
+ addEdge(graph, source, 'conditioning', seedVariance, 'conditioning');
+ addEdge(graph, seed, 'value', seedVariance, 'variance_seed');
+ source = seedVariance;
+ }
+
+ return source;
+};
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/prepareCanvasInvocation.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/prepareCanvasInvocation.test.ts
index a26b1f2763..9a494ddabf 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/prepareCanvasInvocation.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/prepareCanvasInvocation.test.ts
@@ -1031,7 +1031,7 @@ describe('resolveRegionalReferenceImages', () => {
expect(resolveRegionalReferenceImages({ referenceImages: [ipAdapterRef(null)] }, 'sd-1')).toEqual([]);
});
- it('keeps an IP-Adapter ref once an image is assigned (non-FLUX base)', () => {
+ it('keeps an IP-Adapter ref once an image is assigned for a supported SD base', () => {
const inputs = resolveRegionalReferenceImages({ referenceImages: [ipAdapterRef(asset)] }, 'sd-1');
expect(inputs).toHaveLength(1);
expect(inputs[0]).toMatchObject({ id: 'ref-ipa', imageName: 'ref.png', type: 'ip_adapter' });
@@ -1041,6 +1041,10 @@ describe('resolveRegionalReferenceImages', () => {
expect(resolveRegionalReferenceImages({ referenceImages: [ipAdapterRef(asset)] }, 'flux2')).toEqual([]);
});
+ it('drops regional reference images for Krea-2', () => {
+ expect(resolveRegionalReferenceImages({ referenceImages: [ipAdapterRef(asset)] }, 'krea-2')).toEqual([]);
+ });
+
it('drops a FLUX Redux ref with no image assigned', () => {
expect(resolveRegionalReferenceImages({ referenceImages: [fluxReduxRef(null)] }, 'flux')).toEqual([]);
});
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/prepareCanvasInvocation.ts b/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/prepareCanvasInvocation.ts
index f4b9bca504..819b0166c5 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/prepareCanvasInvocation.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/invoke/prepareCanvasInvocation.ts
@@ -218,7 +218,7 @@ export const resolveRegionalReferenceImages = (
continue;
}
const { config } = ref;
- if (config.type === 'ip_adapter' && base !== 'flux' && base !== 'flux2') {
+ if (config.type === 'ip_adapter' && (base === 'sd-1' || base === 'sdxl')) {
if (!config.image || !config.model || config.model.base !== base) {
continue;
}