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 color compensation to generate widget

joshistoast5fa86c8ccd31
diff --git a/invokeai/frontend/webv2/src/workbench/generation/baseGenerationPolicies.ts b/invokeai/frontend/webv2/src/workbench/generation/baseGenerationPolicies.ts
index 52f1cb63b8..6e5041ca3e 100644
--- a/invokeai/frontend/webv2/src/workbench/generation/baseGenerationPolicies.ts
+++ b/invokeai/frontend/webv2/src/workbench/generation/baseGenerationPolicies.ts
@@ -57,6 +57,7 @@ export interface BaseGenerationConfig {
};
ui: {
sdVaeOverride: boolean;
+ colorCompensation: boolean;
vaePrecision: boolean;
seamless: boolean;
cfgRescale: boolean;
@@ -148,7 +149,7 @@ export const BASE_GENERATION = {
schedulerAppliesToGraph: true,
guidanceLabel: 'CFG',
negativePrompt: { visible: true, usage: 'always' },
- ui: { sdVaeOverride: true, vaePrecision: true, seamless: true, cfgRescale: true, clipSkipMax: 12 },
+ ui: { sdVaeOverride: true, colorCompensation: false, vaePrecision: true, seamless: true, cfgRescale: true, clipSkipMax: 12 },
},
'sd-2': {
dimensions: { grid: 8, optimalSide: 512 },
@@ -157,7 +158,7 @@ export const BASE_GENERATION = {
schedulerAppliesToGraph: true,
guidanceLabel: 'CFG',
negativePrompt: { visible: true, usage: 'always' },
- ui: { sdVaeOverride: true, vaePrecision: true, seamless: true, cfgRescale: true, clipSkipMax: 24 },
+ ui: { sdVaeOverride: true, colorCompensation: false, vaePrecision: true, seamless: true, cfgRescale: true, clipSkipMax: 24 },
},
sdxl: {
dimensions: { grid: 8, optimalSide: 1024 },
@@ -166,7 +167,7 @@ export const BASE_GENERATION = {
schedulerAppliesToGraph: true,
guidanceLabel: 'CFG',
negativePrompt: { visible: true, usage: 'always' },
- ui: { sdVaeOverride: true, vaePrecision: true, seamless: true, cfgRescale: false },
+ ui: { sdVaeOverride: true, colorCompensation: true, vaePrecision: true, seamless: true, cfgRescale: false },
},
'sd-3': {
dimensions: { grid: 16, optimalSide: 1024 },
@@ -175,7 +176,7 @@ export const BASE_GENERATION = {
schedulerAppliesToGraph: false,
guidanceLabel: 'CFG',
negativePrompt: { visible: true, usage: 'always' },
- ui: { sdVaeOverride: false, vaePrecision: false, seamless: false, cfgRescale: false },
+ ui: { sdVaeOverride: false, colorCompensation: false, vaePrecision: false, seamless: false, cfgRescale: false },
},
flux: {
dimensions: { grid: 16, optimalSide: 1024 },
@@ -184,7 +185,7 @@ export const BASE_GENERATION = {
schedulerAppliesToGraph: true,
guidanceLabel: 'Guidance',
negativePrompt: { visible: false, usage: 'never' },
- ui: { sdVaeOverride: false, vaePrecision: false, seamless: false, cfgRescale: false },
+ ui: { sdVaeOverride: false, colorCompensation: false, vaePrecision: false, seamless: false, cfgRescale: false },
},
flux2: {
dimensions: { grid: 16, optimalSide: 1024 },
@@ -193,7 +194,7 @@ export const BASE_GENERATION = {
schedulerAppliesToGraph: true,
guidanceLabel: 'Guidance',
negativePrompt: { visible: false, usage: 'never' },
- ui: { sdVaeOverride: false, vaePrecision: false, seamless: false, cfgRescale: false },
+ ui: { sdVaeOverride: false, colorCompensation: false, vaePrecision: false, seamless: false, cfgRescale: false },
},
cogview4: {
dimensions: { grid: 32, optimalSide: 1024 },
@@ -202,7 +203,7 @@ export const BASE_GENERATION = {
schedulerAppliesToGraph: false,
guidanceLabel: 'CFG',
negativePrompt: { visible: true, usage: 'always' },
- ui: { sdVaeOverride: false, vaePrecision: false, seamless: false, cfgRescale: false },
+ ui: { sdVaeOverride: false, colorCompensation: false, vaePrecision: false, seamless: false, cfgRescale: false },
},
'qwen-image': {
dimensions: { grid: 16, optimalSide: 1024 },
@@ -211,7 +212,7 @@ export const BASE_GENERATION = {
schedulerAppliesToGraph: false,
guidanceLabel: 'CFG',
negativePrompt: { visible: true, usage: 'cfg-gated' },
- ui: { sdVaeOverride: false, vaePrecision: false, seamless: false, cfgRescale: false },
+ ui: { sdVaeOverride: false, colorCompensation: false, vaePrecision: false, seamless: false, cfgRescale: false },
},
'z-image': {
dimensions: { grid: 16, optimalSide: 1024 },
@@ -220,7 +221,7 @@ export const BASE_GENERATION = {
schedulerAppliesToGraph: true,
guidanceLabel: 'CFG',
negativePrompt: { visible: true, usage: 'cfg-gated' },
- ui: { sdVaeOverride: false, vaePrecision: false, seamless: false, cfgRescale: false },
+ ui: { sdVaeOverride: false, colorCompensation: false, vaePrecision: false, seamless: false, cfgRescale: false },
},
anima: {
dimensions: { grid: 8, optimalSide: 1024 },
@@ -229,7 +230,7 @@ export const BASE_GENERATION = {
schedulerAppliesToGraph: true,
guidanceLabel: 'CFG',
negativePrompt: { visible: true, usage: 'cfg-gated' },
- ui: { sdVaeOverride: false, vaePrecision: false, seamless: false, cfgRescale: false },
+ ui: { sdVaeOverride: false, colorCompensation: false, vaePrecision: false, seamless: false, cfgRescale: false },
},
} as const satisfies Partial<Record<KnownModelBase, BaseGenerationConfig>>;
@@ -268,6 +269,7 @@ export interface GenerationModelPolicy {
schedulerVisible: boolean;
clipSkipMax: number | null;
cfgRescaleVisible: boolean;
+ colorCompensationVisible: boolean;
seamlessVisible: boolean;
sdVaeVisible: boolean;
vaePrecisionVisible: boolean;
@@ -282,7 +284,7 @@ const FALLBACK_GENERATION_CONFIG: BaseGenerationConfig = {
schedulerAppliesToGraph: false,
guidanceLabel: 'CFG',
negativePrompt: { visible: true, usage: 'never' },
- ui: { sdVaeOverride: false, vaePrecision: false, seamless: false, cfgRescale: false },
+ ui: { sdVaeOverride: false, colorCompensation: false, vaePrecision: false, seamless: false, cfgRescale: false },
};
// Fallbacks keep UI selectors crash-safe; isSupportedGenerateModel() still blocks invocation.
@@ -421,6 +423,7 @@ export const getGenerationUiPolicy = (
schedulerVisible: config.schedulerAppliesToGraph,
clipSkipMax: config.ui.clipSkipMax ?? null,
cfgRescaleVisible: config.ui.cfgRescale,
+ colorCompensationVisible: config.ui.colorCompensation,
seamlessVisible: config.ui.seamless,
sdVaeVisible: config.ui.sdVaeOverride,
vaePrecisionVisible: config.ui.vaePrecision,
@@ -484,6 +487,7 @@ export const getDefaultGenerateSettings = (model?: GenerateModelConfig): Generat
cfgRescaleMultiplier: defaults.cfgRescaleMultiplier,
cfgScale: defaults.cfgScale,
clipSkip: 0,
+ colorCompensation: false,
clipEmbedModel: null,
clipGEmbedModel: null,
clipLEmbedModel: null,
@@ -521,6 +525,7 @@ export const getSettingsWithModelDefaults = (
aspectRatioValue: modelDefaults.aspectRatioValue,
cfgRescaleMultiplier: modelDefaults.cfgRescaleMultiplier,
cfgScale: modelDefaults.cfgScale,
+ colorCompensation: modelDefaults.colorCompensation,
height: modelDefaults.height,
loras: settings.loras.map((lora) =>
isLoraCompatibleWithModel(lora.model, model) ? lora : { ...lora, isEnabled: false }
@@ -976,6 +981,11 @@ export const getSettingsWithCompatibleModelSelections = (
addClearedLabel(clearedLabels, 'CFG rescale');
}
+ if (!uiPolicy.colorCompensationVisible && nextSettings.colorCompensation) {
+ nextSettings.colorCompensation = false;
+ addClearedLabel(clearedLabels, 'Color compensation');
+ }
+
if (!uiPolicy.seamlessVisible && (nextSettings.seamlessXAxis || nextSettings.seamlessYAxis)) {
nextSettings.seamlessXAxis = false;
nextSettings.seamlessYAxis = false;
diff --git a/invokeai/frontend/webv2/src/workbench/generation/graph.test.ts b/invokeai/frontend/webv2/src/workbench/generation/graph.test.ts
index 0cfe5e214b..2518b5a365 100644
--- a/invokeai/frontend/webv2/src/workbench/generation/graph.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/generation/graph.test.ts
@@ -128,6 +128,13 @@ describe('compileGenerateGraph', () => {
expect(getEdge(graph, 'denoise_latents', 'unet')?.source.node_id).toBe('model_loader');
expect(getEdge(graph, 'canvas_output', 'vae')?.source.node_id).toBe('model_loader');
expect(graph.nodes.canvas_output?.fp32).toBe(true);
+ expect(graph.nodes.canvas_output?.color_compensation).toBe('None');
+ });
+
+ it('passes SDXL color compensation to the VAE decode node when enabled', () => {
+ const graph = compile(sdxlModel, { colorCompensation: true });
+
+ expect(graph.nodes.canvas_output?.color_compensation).toBe('SDXL');
});
it('coerces invalid SD schedulers before graph submission', () => {
diff --git a/invokeai/frontend/webv2/src/workbench/generation/graph.ts b/invokeai/frontend/webv2/src/workbench/generation/graph.ts
index f0dfe018c1..3aeae8cbbd 100644
--- a/invokeai/frontend/webv2/src/workbench/generation/graph.ts
+++ b/invokeai/frontend/webv2/src/workbench/generation/graph.ts
@@ -217,6 +217,7 @@ const buildSDGraph = (
const compelType = model.base === 'sdxl' ? 'sdxl_compel_prompt' : 'compel';
const activeLoras = getActiveCompatibleLoras(settings, model);
const scheduler = coerceSchedulerForGraph(model, settings.scheduler);
+ const colorCompensation = settings.colorCompensation ? 'SDXL' : 'None';
const positivePrompt = addNode(graph, { id: 'positive_prompt', type: 'string' });
const negativePrompt = addNode(graph, { id: 'negative_prompt', type: 'string' });
@@ -244,6 +245,7 @@ const buildSDGraph = (
type: 'denoise_latents',
});
const output = addNode(graph, {
+ color_compensation: colorCompensation,
fp32: settings.vaePrecision === 'fp32',
id: 'canvas_output',
is_intermediate: outputIsIntermediate,
diff --git a/invokeai/frontend/webv2/src/workbench/generation/settings.test.ts b/invokeai/frontend/webv2/src/workbench/generation/settings.test.ts
index 96e1260a7d..288824e12f 100644
--- a/invokeai/frontend/webv2/src/workbench/generation/settings.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/generation/settings.test.ts
@@ -52,6 +52,7 @@ describe('normalizeGenerateSettings', () => {
expect(normalized?.aspectRatioId).toBe('2:3');
expect(normalized?.aspectRatioIsLocked).toBe(false);
expect(normalized?.clipSkip).toBe(0);
+ expect(normalized?.colorCompensation).toBe(false);
expect(normalized?.loras).toEqual([]);
expect(normalized?.seamlessXAxis).toBe(false);
expect(normalized?.vae).toBeNull();
diff --git a/invokeai/frontend/webv2/src/workbench/generation/settings.ts b/invokeai/frontend/webv2/src/workbench/generation/settings.ts
index 818d739ef1..cfa6e91bfd 100644
--- a/invokeai/frontend/webv2/src/workbench/generation/settings.ts
+++ b/invokeai/frontend/webv2/src/workbench/generation/settings.ts
@@ -350,6 +350,7 @@ export const normalizeGenerateSettings = (values: unknown): GenerateSettings | n
cfgRescaleMultiplier: values.cfgRescaleMultiplier as number,
cfgScale: values.cfgScale as number,
clipSkip: hasFiniteNumber(values, 'clipSkip') ? (values.clipSkip as number) : 0,
+ colorCompensation: typeof values.colorCompensation === 'boolean' ? values.colorCompensation : false,
height,
loras: Array.isArray(values.loras) ? values.loras.filter(isGenerateLora) : [],
modelKey: values.modelKey as string,
@@ -397,6 +398,7 @@ export const isGenerateSettings = (values: unknown): values is GenerateSettings
typeof values.aspectRatioIsLocked === 'boolean' &&
hasFiniteNumber(values, 'aspectRatioValue') &&
hasFiniteNumber(values, 'clipSkip') &&
+ typeof values.colorCompensation === 'boolean' &&
Array.isArray(values.loras) &&
values.loras.every(isGenerateLora) &&
typeof values.seamlessXAxis === 'boolean' &&
diff --git a/invokeai/frontend/webv2/src/workbench/generation/types.ts b/invokeai/frontend/webv2/src/workbench/generation/types.ts
index 36dc7201dc..e81e3edcd9 100644
--- a/invokeai/frontend/webv2/src/workbench/generation/types.ts
+++ b/invokeai/frontend/webv2/src/workbench/generation/types.ts
@@ -103,6 +103,7 @@ export interface GenerateSettings {
cfgRescaleMultiplier: number;
scheduler: string;
clipSkip: number;
+ colorCompensation: boolean;
seed: number;
shouldRandomizeSeed: boolean;
seamlessXAxis: boolean;
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.test.ts b/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.test.ts
index a577a4d9bc..4b54c23083 100644
--- a/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/imageRecall.test.ts
@@ -40,6 +40,7 @@ const createValues = (overrides: Partial<GenerateWidgetValues> = {}): GenerateWi
clipGEmbedModel: null,
clipLEmbedModel: null,
clipSkip: 0,
+ colorCompensation: false,
componentSourceModel: null,
height: 1024,
loras: [],
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/generate/GenerateAdvancedFields.tsx b/invokeai/frontend/webv2/src/workbench/widgets/generate/GenerateAdvancedFields.tsx
index 573294b4dd..a157f95ab3 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/generate/GenerateAdvancedFields.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/generate/GenerateAdvancedFields.tsx
@@ -55,6 +55,7 @@ export const GenerateAdvancedFields = ({ onCommit, selectedModel, settings }: Ge
if (
!policy.sdVaeVisible &&
!policy.vaePrecisionVisible &&
+ !policy.colorCompensationVisible &&
!policy.seamlessVisible &&
!policy.clipSkipMax &&
!policy.cfgRescaleVisible
@@ -66,6 +67,7 @@ export const GenerateAdvancedFields = ({ onCommit, selectedModel, settings }: Ge
<>
{settings.seamlessXAxis && <Badge size="xs">Tile X</Badge>}
{settings.seamlessYAxis && <Badge size="xs">Tile Y</Badge>}
+ {settings.colorCompensation && <Badge size="xs">Color compensation</Badge>}
{customVae && (
<Badge maxW="32" size="xs" truncate>
{settings.vae?.name}
@@ -176,6 +178,21 @@ export const GenerateAdvancedFields = ({ onCommit, selectedModel, settings }: Ge
</HStack>
) : null}
+ {policy.colorCompensationVisible ? (
+ <Field label="Color compensation" p="2">
+ <Switch.Root
+ checked={settings.colorCompensation}
+ size="sm"
+ onCheckedChange={(event) => onCommit({ colorCompensation: event.checked })}
+ >
+ <Switch.HiddenInput />
+ <Switch.Control _checked={{ bg: 'accent.solid' }}>
+ <Switch.Thumb />
+ </Switch.Control>
+ </Switch.Root>
+ </Field>
+ ) : null}
+
{policy.seamlessVisible ? (
<Field label="Seamless tiling" p="2">
<HStack gap="4">
diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
index 20498498f6..be3e0cf8f1 100644
--- a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
@@ -25,6 +25,7 @@ const createGenerateValues = (overrides: Partial<GenerateWidgetValues> = {}): Ge
clipGEmbedModel: null,
clipLEmbedModel: null,
clipSkip: 0,
+ colorCompensation: false,
componentSourceModel: null,
height: 1024,
loras: [],