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.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
fix(canvas): explain conditional Seedream image budgets (#10258)
rnshine9c69f20f2ff5
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex 64bed010bf..db4cf0eb75 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -3355,6 +3355,7 @@"krea2ReferenceKvCacheNeedsEditReferences": "Applies only with Edit references and an edit LoRA in Concepts.","krea2ReferenceKvCacheNeedsLora": "Applies only with an edit LoRA enabled in Concepts.","krea2EditReferencesNeedLora": "Edit references need an edit LoRA (pose, depth, …); without one the model copies the reference.",+ "canvasReferenceImageBudgetHint": "When the frame contains visible content, it uses one image slot. Remove a reference image to stay within this model’s limit.","styleStrength": "Style strength","timestepShift": "Shift","timestepShiftHelp": "Auto derives the schedule shift from the image size.",diff --git a/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.test.ts b/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.test.tsindex 667db25482..726b805c19 100644--- a/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.test.ts+++ b/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.test.ts@@ -27,6 +27,7 @@ import {getComponentSectionPolicy,getDefaultComponentSlotPolicies,getDefaultGenerateSettings,+ getGenerateInvocationIssues,getGenerateModelSelectionResult,getGenerationDimensions,getGenerationModelAvailabilityReasons,@@ -48,6 +49,7 @@ import {isLossyModelSwitch,isModelFromRepo,isSupportedGenerateModel,+ needsEmptyCanvasFrameForReferenceBudget,type NewReferenceImage,type ReferenceVisionComponents,} from './baseGenerationPolicies';@@ -582,6 +584,50 @@ describe('component policies', () => {}});+ it('warns when only visible Canvas content would exceed the reference budget', () => {+ const model: GenerateModelConfig = {+ ...externalModel,+ provider_id: 'seedream',+ provider_model_id: 'seedream-4-5-251128',+ capabilities: { modes: ['txt2img', 'img2img'], supports_reference_images: true, max_reference_images: 14 },+ };+ const settings = createSettings(model, {+ referenceImages: Array.from({ length: 14 }, (_, i) => ({+ id: `reference-${i}`,+ isEnabled: true,+ config: {+ type: 'external_reference_image',+ image: {+ imageName: `reference-${i}.png`,+ width: 512,+ height: 512,+ original: { image: { image_name: `reference-${i}.png`, width: 512, height: 512 } },+ },+ },+ })),+ });+ const values = { ...settings, model };+ expect(needsEmptyCanvasFrameForReferenceBudget(model, settings)).toBe(true);+ expect(getGenerateInvocationIssues(values, { canvasFrame: { height: 512, width: 512 } })).toEqual([]);+ expect(getGenerateInvocationIssues(values)).toEqual([]);+ expect(getGenerationValidationReasons(model, settings, 'img2img')).toEqual([+ 'External Model supports at most 15 images total (reference + init + output), got 16.',+ ]);+ expect(needsEmptyCanvasFrameForReferenceBudget({ ...model, capabilities: { modes: ['txt2img'] } }, settings)).toBe(+ false+ );+ settings.referenceImages[0]!.isEnabled = false;+ expect(needsEmptyCanvasFrameForReferenceBudget(model, settings)).toBe(false);+ settings.referenceImages.push(+ { ...settings.referenceImages[1]!, id: 'extra-1' },+ { ...settings.referenceImages[2]!, id: 'extra-2' }+ );+ expect(needsEmptyCanvasFrameForReferenceBudget(model, settings)).toBe(false);+ expect(getGenerateInvocationIssues({ ...settings, model }).map(({ message }) => message)).toContain(+ 'External Model supports at most 15 images total (reference + init + output), got 16.'+ );+ });+it('keeps concepts but clears incompatible selections when the selected model changes', () => {const model = createModel('sdxl');const settings = createSettings(createModel('sd-1'), {diff --git a/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.ts b/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.tsindex 803ca98f52..5bc52c7ec0 100644--- a/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.ts+++ b/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.ts@@ -3558,6 +3558,23 @@ export const getGenerationValidationReasons = (mode: ExternalGenerationMode = 'txt2img'): string[] => getGenerationValidationIssues(model, settings, mode).map(({ message }) => message);+export const needsEmptyCanvasFrameForReferenceBudget = (+ model: GenerateModelConfig | undefined,+ settings: Pick<GenerateSettings, 'referenceImages'>+): boolean => {+ if (+ !model ||+ model.type !== 'external_image_generator' ||+ !isSeedreamBatchModel(model) ||+ !model.capabilities?.modes?.includes('txt2img') ||+ !model.capabilities.modes.includes('img2img')+ ) {+ return false;+ }++ return getExternalReferenceImages(settings, model).length + 1 === SEEDREAM_BATCH_MAX_TOTAL_IMAGES;+};+/** Shared by the Invoke route and the Generate form. Omit `models` while the catalog is unread. */export const getGenerateInvocationIssues = (values: GenerateSettings & { model: GenerateModelConfig },diff --git a/invokeai/frontend/webv2/src/features/generation/ui/GenerateGuidanceSection.browser.test.tsx b/invokeai/frontend/webv2/src/features/generation/ui/GenerateGuidanceSection.browser.test.tsxindex 8cb193412e..ea08336d21 100644--- a/invokeai/frontend/webv2/src/features/generation/ui/GenerateGuidanceSection.browser.test.tsx+++ b/invokeai/frontend/webv2/src/features/generation/ui/GenerateGuidanceSection.browser.test.tsx@@ -16,6 +16,7 @@ import { GenerateGuidanceSection } from './GenerateGuidanceSection';vi.mock('./GenerationUiContext', () => ({useGenerationUi: () => ({models: { status: 'loaded' },+ project: { activeProjectId: 'project', invocationSourceId: 'generate', showPromptSyntaxHighlighting: false },sectionPreferences: { sectionsOpen: { guidance: true }, setSectionsOpen: vi.fn() },}),}));diff --git a/invokeai/frontend/webv2/src/features/generation/ui/GenerateGuidanceSection.tsx b/invokeai/frontend/webv2/src/features/generation/ui/GenerateGuidanceSection.tsxindex d38bc691f2..d833e8840b 100644--- a/invokeai/frontend/webv2/src/features/generation/ui/GenerateGuidanceSection.tsx+++ b/invokeai/frontend/webv2/src/features/generation/ui/GenerateGuidanceSection.tsx@@ -2,7 +2,11 @@ import type { GenerationModelCatalogItem as ModelConfig } from '@features/generaimport type { GenerateModelConfig, GenerateSettings, LoraModelConfig } from '@features/generation/core/types';import { Flex, Icon, Stack, Text } from '@chakra-ui/react';-import { getKrea2EditLoraState, isReferenceImageSupported } from '@features/generation/core/baseGenerationPolicies';+import {+ getKrea2EditLoraState,+ isReferenceImageSupported,+ needsEmptyCanvasFrameForReferenceBudget,+} from '@features/generation/core/baseGenerationPolicies';import {type GenerateDraft,type GenerateSettingsUpdate,@@ -55,7 +59,8 @@ export const GenerateGuidanceSection = ({const activeReferenceImages = referenceImagesSupported? settings.referenceImages.filter((image) => image.isEnabled).length: 0;- const catalogStatus = useGenerationUi().models.status;+ const ui = useGenerationUi();+ const catalogStatus = ui.models.status;const activeConcepts = settings.loras.filter((lora) =>lora.isEnabled && isCompatibleLora(lora, selectedModel) && isConceptInstalled(lora, loraModels, catalogStatus)@@ -116,6 +121,12 @@ export const GenerateGuidanceSection = ({onCommit={onReferenceCommit}onCommitImmediate={onCommitImmediate}/>+ {ui.project.invocationSourceId === 'canvas' &&+ needsEmptyCanvasFrameForReferenceBudget(selectedModel, settings) ? (+ <Text color="fg.warning" fontSize="xs" role="status" textWrap="pretty">+ {t('widgets.generate.canvasReferenceImageBudgetHint')}+ </Text>+ ) : null}{/* Not blocking: the run works, but without an edit LoRA it only copies the references. */}{getKrea2EditLoraState(selectedModel, settings) === 'noLora' ? (<Text color="fg.warning" fontSize="xs" role="status" textWrap="pretty">diff --git a/invokeai/frontend/webv2/src/features/generation/ui/GenerateSettingsForm.browser.test.tsx b/invokeai/frontend/webv2/src/features/generation/ui/GenerateSettingsForm.browser.test.tsxindex 424a7ec47f..eece7c4866 100644--- a/invokeai/frontend/webv2/src/features/generation/ui/GenerateSettingsForm.browser.test.tsx+++ b/invokeai/frontend/webv2/src/features/generation/ui/GenerateSettingsForm.browser.test.tsx@@ -308,6 +308,58 @@ afterEach(async () => {accountLifecycle.invalidate();});+describe('Canvas hosted-provider preflight', () => {+ it('shows a conditional Canvas budget hint without a blocking issue', async () => {+ const model = {+ ...MODEL,+ base: 'external',+ type: 'external_image_generator',+ key: 'seedream',+ name: 'Seedream',+ provider_id: 'seedream',+ provider_model_id: 'seedream-4-5-251128',+ capabilities: { modes: ['txt2img', 'img2img'], supports_reference_images: true, max_reference_images: 14 },+ } as unknown as GenerationModelCatalogItem;+ stableGroups.models.catalog = [model];+ await settle(() =>+ storedValues().patchSnapshot({+ ...getDefaultGenerateSettings(model as never),+ modelKey: model.key,+ referenceImages: Array.from({ length: 14 }, (_, i) => ({+ id: `ref-${i}`,+ isEnabled: true,+ config: {+ type: 'external_reference_image',+ image: {+ imageName: `ref-${i}.png`,+ width: 512,+ height: 512,+ original: { image: { image_name: `ref-${i}.png`, width: 512, height: 512 } },+ },+ },+ })),+ })+ );+ const adapter = buildAdapter();+ adapter.project = { ...adapter.project, invocationSourceId: 'canvas' };+ await renderAdapter(adapter);+ const hint = 'widgets.generate.canvasReferenceImageBudgetHint';+ const issue = 'Seedream supports at most 15 images total (reference + init + output), got 16.';+ expect(host!.textContent).toContain(hint);+ expect(host!.textContent).not.toContain(issue);+ await renderAdapter(buildAdapter());+ expect(host!.textContent).not.toContain(hint);+ await renderAdapter(adapter);+ await settle(() => {+ const references = storedValues().getSnapshot().referenceImages as { isEnabled: boolean }[];+ storedValues().patchSnapshot({+ referenceImages: references.map((ref, i) => (i === 0 ? { ...ref, isEnabled: false } : ref)),+ });+ });+ expect(host!.textContent).not.toContain(hint);+ });+});+describe('GenerateSettingsForm Anima inpaint adapter', () => {const adapterSlot = () => host!.querySelector<HTMLElement>('[data-component-types="controlnet"]');const weightLabel = 'widgets.generate.animaInpaintAdapterWeight';diff --git a/invokeai/frontend/webv2/src/workbench/invocation.test.ts b/invokeai/frontend/webv2/src/workbench/invocation.test.tsindex 94fb1b1445..043bb1b775 100644--- a/invokeai/frontend/webv2/src/workbench/invocation.test.ts+++ b/invokeai/frontend/webv2/src/workbench/invocation.test.ts@@ -295,6 +295,55 @@ describe('resolveInvocationRoute — canvas source', () => {).toBe(true);});+ it('defers an uncertain Canvas init budget while retaining definite input refusals', () => {+ const model: GenerateModelConfig = {+ ...unknownExternalModel,+ provider_id: 'seedream',+ provider_model_id: 'seedream-4-5-251128',+ capabilities: { modes: ['txt2img', 'img2img'], supports_reference_images: true, max_reference_images: 14 },+ };+ const generateValues = createGenerateValues(model, {+ referenceImages: Array.from({ length: 14 }, (_, i) => ({+ id: `ref-${i}`,+ isEnabled: true,+ config: {+ type: 'external_reference_image',+ image: {+ imageName: `ref-${i}.png`,+ width: 512,+ height: 512,+ original: { image: { image_name: `ref-${i}.png`, width: 512, height: 512 } },+ },+ },+ })),+ });+ const input = canvasInputFor({ generateValues, rasterInFrame: true });+ const blocked = resolveInvocationRouteInput(+ { ...input, canvasLayers: [modellessControlLayer()] },+ 'global',+ canvasRoute+ );+ expect(blocked.validationReasons).toContainEqual({+ canvasInputIssue: {+ kind: 'hosted_refusal',+ modelName: 'Unknown External Provider',+ refusal: { kind: 'control_layer', layerName: 'Control Layer 1' },+ },+ });+ expect(resolveInvocationRouteInput(input, 'global', { ...canvasRoute, sourceId: 'generate' }).sourceValid).toBe(+ true+ );+ expect(resolveInvocationRouteInput(input, 'global', canvasRoute).sourceValid).toBe(true);+ const tooMany = {+ ...generateValues,+ referenceImages: [...generateValues.referenceImages, { ...generateValues.referenceImages[0]!, id: 'too-many' }],+ };+ const rejected = resolveInvocationRouteInput(canvasInputFor({ generateValues: tooMany }), 'global', canvasRoute);+ expect(rejected.validationReasons.map(reasonText)).toContain(+ 'Unknown External Provider supports at most 15 images total (reference + init + output), got 16.'+ );+ });+it('blocks a typed content-bearing control layer no model resolves once models are loaded', () => {const route = resolveInvocationRouteInput(canvasInputFor({ layers: [{ ...modellessControlLayer(), controlType: 'depth', detection: null }] }),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.tsindex 9cfe3c2474..aacc2261eb 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@@ -499,6 +499,48 @@ describe('runCanvasInvocation', () => {expect(submitted[0]?.graph.backendGraph?.nodes.canvas_processing_output).not.toHaveProperty('init_image');});+ it('uses actual frame alpha for a hosted-provider init image budget with identical layer geometry', async () => {+ const model: GenerateModelConfig = {+ ...externalModel,+ name: 'Seedream',+ provider_id: 'seedream',+ provider_model_id: 'seedream-4-5-251128',+ capabilities: { modes: ['txt2img', 'img2img'], supports_reference_images: true, max_reference_images: 14 },+ };+ const generateValues = {+ referenceImages: Array.from({ length: 14 }, (_, i) => ({+ id: `ref-${i}`,+ isEnabled: true,+ config: {+ type: 'external_reference_image',+ image: {+ imageName: `ref-${i}.png`,+ width: 512,+ height: 512,+ original: { image: { image_name: `ref-${i}.png`, width: 512, height: 512 } },+ },+ },+ })),+ };+ const document = makeDoc([rasterLayer('same-layer')]);+ const transparent = makeHarness({ alpha: 0, document, generateValues, model });+ await runCanvasInvocation(transparent.deps);++ expect(transparent.notices()).toEqual([]);+ expect(transparent.submittedGraphs()).toHaveLength(1);+ const output = transparent.submittedGraphs()[0]?.graph.backendGraph?.nodes.canvas_processing_output;+ expect(output).toMatchObject({ mode: 'txt2img' });+ expect(output).not.toHaveProperty('init_image');++ const opaque = makeHarness({ alpha: 255, document, generateValues, model });+ await runCanvasInvocation(opaque.deps);++ expect(opaque.submittedGraphs()).toEqual([]);+ expect(opaque.notices()).toMatchObject([+ { message: 'Seedream supports at most 15 images total (reference + init + output), got 16.' },+ ]);+ });+it('discards provisional dedupe entries when synchronous queue dispatch fails', async () => {const dispatch = vi.fn((action: WorkbenchAction) => {if (action.type === 'submitCanvasInvocationSnapshot') {