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(generate): explain when a model cannot use concepts

Josh Corbett4697ae16de1d
diff --git a/docs/src/content/docs/Users Guide/04.Image Generation/generate-panel.mdx b/docs/src/content/docs/Users Guide/04.Image Generation/generate-panel.mdx
index 01392a248d..aa05b74a55 100644
--- a/docs/src/content/docs/Users Guide/04.Image Generation/generate-panel.mdx
+++ b/docs/src/content/docs/Users Guide/04.Image Generation/generate-panel.mdx
@@ -84,7 +84,7 @@ Concepts, also called LoRAs, are small add-on models that teach the main model a
</Steps>
-You can add as many concepts as you like and combine them. Use the switch on each row to turn a concept off without removing it, and the trash button to remove it. If you change to a model from a different family, its concepts are marked **Incompatible** or removed.
+You can add as many concepts as you like and combine them. Use the switch on each row to turn a concept off without removing it, and the trash button to remove it. If you change to a model from a different family, its concepts are marked **Incompatible** or removed. SD3, CogView4, ERNIE Image, Ideogram 4 and external API models don't support concepts, so with one of them selected the section says so instead of offering LoRAs.
## Adding reference images
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.json
index d1a64e162d..4979a5d949 100644
--- a/invokeai/frontend/webv2/public/locales/en.json
+++ b/invokeai/frontend/webv2/public/locales/en.json
@@ -2226,6 +2226,7 @@
},
"conceptWeight": "{{name}} weight",
"concepts": "Concepts",
+ "conceptsUnsupported": "Concepts are not supported by the selected model.",
"copyValue": "Copy value",
"couldNotExpandPrompt": "Could not expand the prompt.",
"couldNotGeneratePromptFromImage": "Could not generate a prompt from the selected image.",
diff --git a/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.ts b/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.ts
index 3868f08f14..70542c2e52 100644
--- a/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.ts
+++ b/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.ts
@@ -1259,6 +1259,26 @@ const isFluxKontextModel = (model: GenerateModelConfig | undefined): model is Ma
model.name.toLowerCase().includes('kontext')
);
+/**
+ * Families whose Generate graph loads LoRAs. The backend installs no LoRAs for the others, so their concept picker
+ * could only ever be empty; graph coverage holds the builders to this list.
+ */
+const LORA_SUPPORTED_BASES: ReadonlySet<string> = new Set<SupportedGenerateBase>([
+ 'anima',
+ 'flux',
+ 'flux2',
+ 'krea-2',
+ 'qwen-image',
+ 'sd-1',
+ 'sd-2',
+ 'sdxl',
+ 'wan',
+ 'z-image',
+]);
+
+export const isLoraSupported = (model: GenerateModelConfig | undefined): boolean =>
+ Boolean(model && model.type !== 'external_image_generator' && LORA_SUPPORTED_BASES.has(model.base));
+
/** Picker and validation must agree on compatibility, including required variants. */
export const isReferenceImageSupported = (model: GenerateModelConfig | undefined): boolean => {
if (!model) {
diff --git a/invokeai/frontend/webv2/src/features/generation/core/graphCoverage.test.ts b/invokeai/frontend/webv2/src/features/generation/core/graphCoverage.test.ts
index aabaa2ea2a..594703a4de 100644
--- a/invokeai/frontend/webv2/src/features/generation/core/graphCoverage.test.ts
+++ b/invokeai/frontend/webv2/src/features/generation/core/graphCoverage.test.ts
@@ -11,6 +11,7 @@ import type { ModelIdentifierConfig, VaeModelConfig } from './types';
import {
getComponentSectionPolicy,
getGenerationValidationReasons,
+ isLoraSupported,
SUPPORTED_GENERATE_BASES,
} from './baseGenerationPolicies';
import { compileGenerateGraph, GRAPH_BUILDERS } from './graph';
@@ -119,7 +120,7 @@ describe('generate graph coverage', () => {
});
// An image's metadata is what recall restores, so it must name exactly the LoRAs that reached inference.
- it.each(generateGraphCases)('$label records only the concepts its graph loads', ({ base, shape }) => {
+ it.each(generateGraphCases)('$label loads concepts as policy says, and records only those', ({ base, shape }) => {
const { model, settings } = satisfiedSettingsFor(base, shape);
const lora = (key: string) => ({ base, key, name: key, type: 'lora' as const });
const { backendGraph } = compileGenerateGraph(
@@ -144,6 +145,10 @@ describe('generate graph coverage', () => {
weight: number;
}[];
+ // The concept picker trusts this policy, so a builder that gains or loses a LoRA loader must update it.
+ expect(loaded.length > 0, `${base}/${shape.label} LoRA support disagrees with isLoraSupported`).toBe(
+ isLoraSupported(model)
+ );
expect(recorded.map((entry) => [entry.model.key, entry.weight])).toEqual(loaded);
});
diff --git a/invokeai/frontend/webv2/src/features/generation/ui/GenerateConceptsSection.browser.test.tsx b/invokeai/frontend/webv2/src/features/generation/ui/GenerateConceptsSection.browser.test.tsx
new file mode 100644
index 0000000000..7cdfe6fe52
--- /dev/null
+++ b/invokeai/frontend/webv2/src/features/generation/ui/GenerateConceptsSection.browser.test.tsx
@@ -0,0 +1,110 @@
+/* oxlint-disable react-perf/jsx-no-new-object-as-prop, react-perf/jsx-no-new-array-as-prop */
+import type { GenerateModelConfig, GenerateSettings, LoraModelConfig } from '@features/generation/core/types';
+
+import { ChakraProvider } from '@chakra-ui/react';
+import { seedArchitectureCapabilities } from '@features/generation/core/architectureCapabilities.testing';
+import { getDefaultGenerateSettings } from '@features/generation/core/baseGenerationPolicies';
+import { system } from '@theme/system';
+import { act } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+
+import { GenerateConceptsContent } from './GenerateConceptsSection';
+import { GenerationUiProvider, type GenerationUiAdapter } from './GenerationUiContext';
+
+vi.mock('react-i18next', () => {
+ const t = (key: string) => key;
+ return { useTranslation: () => ({ i18n: { resolvedLanguage: 'en' }, t }) };
+});
+
+seedArchitectureCapabilities();
+(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
+
+const sdxl: GenerateModelConfig = { base: 'sdxl', key: 'sdxl', name: 'SDXL', type: 'main' };
+const sd3: GenerateModelConfig = { base: 'sd-3', key: 'sd3', name: 'SD3', type: 'main' };
+const inkLora: LoraModelConfig = { base: 'sdxl', key: 'ink', name: 'Ink', type: 'lora' };
+
+const adapter = {
+ models: {
+ ModelSelect: () => <div data-testid="concept-picker" />,
+ getBaseColorPalette: () => 'gray',
+ getBaseLabel: (base: string) => base,
+ },
+} as unknown as GenerationUiAdapter;
+
+let host: HTMLDivElement | null = null;
+let root: Root | null = null;
+
+const renderConcepts = async (selectedModel: GenerateModelConfig, loras: GenerateSettings['loras']) => {
+ const onCommitImmediate = vi.fn();
+
+ host = document.createElement('div');
+ document.body.append(host);
+ root = createRoot(host);
+ await act(() => {
+ root?.render(
+ <ChakraProvider value={system}>
+ <GenerationUiProvider adapter={adapter}>
+ <GenerateConceptsContent
+ loraModels={[inkLora]}
+ projectId="project-1"
+ selectedModel={selectedModel}
+ settings={{ ...getDefaultGenerateSettings(sdxl as never), loras }}
+ onCommit={vi.fn()}
+ onCommitImmediate={onCommitImmediate}
+ />
+ </GenerationUiProvider>
+ </ChakraProvider>
+ );
+ });
+
+ return { host, onCommitImmediate };
+};
+
+afterEach(async () => {
+ await act(() => root?.unmount());
+ host?.remove();
+ host = null;
+ root = null;
+});
+
+describe('GenerateConceptsContent', () => {
+ it('offers the concept picker for a model family that loads LoRAs', async () => {
+ const { host } = await renderConcepts(sdxl, []);
+
+ expect(host.querySelector('[data-testid="concept-picker"]')).not.toBeNull();
+ expect(host.textContent).toContain('widgets.generate.addConceptsHelp');
+ expect(host.textContent).not.toContain('widgets.generate.conceptsUnsupported');
+ });
+
+ it('explains instead of offering an always-empty picker when the model cannot use concepts', async () => {
+ const { host } = await renderConcepts(sd3, []);
+
+ expect(host.querySelector('[data-testid="concept-picker"]')).toBeNull();
+ expect(host.textContent).toContain('widgets.generate.conceptsUnsupported');
+ expect(host.textContent).not.toContain('widgets.generate.addConceptsHelp');
+ });
+
+ it('keeps concepts from another model removable when the model cannot use concepts', async () => {
+ const { host, onCommitImmediate } = await renderConcepts(sd3, [{ isEnabled: true, model: inkLora, weight: 0.8 }]);
+
+ expect(host.textContent).toContain('Ink');
+ expect(host.textContent).toContain('widgets.generate.incompatible');
+
+ const remove = host.querySelector<HTMLButtonElement>('button[aria-label="widgets.generate.removeConceptNamed"]');
+
+ expect(remove).not.toBeNull();
+ await act(() => {
+ remove?.click();
+ });
+
+ expect(onCommitImmediate).toHaveBeenCalledWith({ loras: [] });
+ });
+
+ it('marks a same-family concept incompatible when the model cannot use concepts', async () => {
+ const sd3Lora: LoraModelConfig = { base: 'sd-3', key: 'sd3-lora', name: 'Glow', type: 'lora' };
+ const { host } = await renderConcepts(sd3, [{ isEnabled: true, model: sd3Lora, weight: 0.8 }]);
+
+ expect(host.textContent).toContain('widgets.generate.incompatible');
+ });
+});
diff --git a/invokeai/frontend/webv2/src/features/generation/ui/GenerateConceptsSection.tsx b/invokeai/frontend/webv2/src/features/generation/ui/GenerateConceptsSection.tsx
index e428287918..74c983502e 100644
--- a/invokeai/frontend/webv2/src/features/generation/ui/GenerateConceptsSection.tsx
+++ b/invokeai/frontend/webv2/src/features/generation/ui/GenerateConceptsSection.tsx
@@ -8,6 +8,7 @@ import type {
} from '@features/generation/core/types';
import { Badge, HStack, Stack, Text } from '@chakra-ui/react';
+import { isLoraSupported } from '@features/generation/core/baseGenerationPolicies';
import {
DEFAULT_LORA_WEIGHT_CONFIG,
getDefaultLoraWeight,
@@ -42,8 +43,9 @@ interface GenerateConceptsContentProps {
const LORA_WEIGHT_MARKS = [-1, 0, 1, 2];
const LORA_WEIGHT_DEBOUNCE_MS = 250;
-const isCompatibleLora = (lora: GenerateLora, selectedModel: GenerateModelConfig | undefined): boolean =>
- Boolean(selectedModel && isLoraCompatibleWithModel(lora.model, selectedModel));
+/** Whether the selected model's graph will load this concept: its family must take LoRAs and match the LoRA. */
+export const isCompatibleLora = (lora: GenerateLora, selectedModel: GenerateModelConfig | undefined): boolean =>
+ Boolean(selectedModel && isLoraSupported(selectedModel) && isLoraCompatibleWithModel(lora.model, selectedModel));
export const GenerateConceptsContent = ({
loraModels,
@@ -87,6 +89,35 @@ export const GenerateConceptsContent = ({
onCommitImmediate({ loras: loras.filter((lora) => lora.model.key !== modelKey) });
};
+ const rows =
+ loras.length > 0 ? (
+ <Stack gap="2">
+ {loras.map((lora) => (
+ <LoraRow
+ key={lora.model.key}
+ isCompatible={isCompatibleLora(lora, selectedModel)}
+ lora={lora}
+ projectId={projectId}
+ onRemove={() => removeLora(lora.model.key)}
+ onToggle={(isEnabled) => updateLora(lora.model.key, { isEnabled })}
+ onWeightChange={(weight) => updateLora(lora.model.key, { weight })}
+ />
+ ))}
+ </Stack>
+ ) : null;
+
+ if (selectedModel && !isLoraSupported(selectedModel)) {
+ // Rows left from another model stay listed, marked incompatible, so they can still be removed.
+ return (
+ <Stack gap="2">
+ <Text color="fg.muted" fontSize="2xs">
+ {t('widgets.generate.conceptsUnsupported')}
+ </Text>
+ {rows}
+ </Stack>
+ );
+ }
+
return (
<Stack gap="2">
<Field
@@ -109,24 +140,10 @@ export const GenerateConceptsContent = ({
/>
</Field>
- {loras.length === 0 ? (
+ {rows ?? (
<Text color="fg.muted" fontSize="2xs">
{t('widgets.generate.addConceptsHelp')}
</Text>
- ) : (
- <Stack gap="2">
- {loras.map((lora) => (
- <LoraRow
- key={lora.model.key}
- isCompatible={isCompatibleLora(lora, selectedModel)}
- lora={lora}
- projectId={projectId}
- onRemove={() => removeLora(lora.model.key)}
- onToggle={(isEnabled) => updateLora(lora.model.key, { isEnabled })}
- onWeightChange={(weight) => updateLora(lora.model.key, { weight })}
- />
- ))}
- </Stack>
)}
</Stack>
);
diff --git a/invokeai/frontend/webv2/src/features/generation/ui/GenerateGuidanceSection.tsx b/invokeai/frontend/webv2/src/features/generation/ui/GenerateGuidanceSection.tsx
index 3f4ae4cdcd..d7ce260bc8 100644
--- a/invokeai/frontend/webv2/src/features/generation/ui/GenerateGuidanceSection.tsx
+++ b/invokeai/frontend/webv2/src/features/generation/ui/GenerateGuidanceSection.tsx
@@ -4,10 +4,9 @@ import type { GenerateSettingsUpdate } from '@features/generation/ui/generateDeb
import { Badge, Separator, Stack } from '@chakra-ui/react';
import { isReferenceImageSupported } from '@features/generation/core/baseGenerationPolicies';
-import { isLoraCompatibleWithModel } from '@features/generation/core/settings';
import { useTranslation } from 'react-i18next';
-import { GenerateConceptsContent } from './GenerateConceptsSection';
+import { GenerateConceptsContent, isCompatibleLora } from './GenerateConceptsSection';
import { GenerateReferenceImagesContent } from './reference-images/GenerateReferenceImagesSection';
import { GenerateCollapsibleSection } from './shared/GenerateCollapsibleSection';
@@ -40,12 +39,12 @@ export const GenerateGuidanceSection = ({
const activeReferenceImages = referenceImagesSupported
? settings.referenceImages.filter((image) => image.isEnabled).length
: 0;
- const activeConcepts = selectedModel
- ? settings.loras.filter((lora) => lora.isEnabled && isLoraCompatibleWithModel(lora.model, selectedModel)).length
- : 0;
+ const activeConcepts = settings.loras.filter(
+ (lora) => lora.isEnabled && isCompatibleLora(lora, selectedModel)
+ ).length;
const hasIncompatible =
(!referenceImagesSupported && referenceImageCount > 0) ||
- settings.loras.some((lora) => selectedModel && !isLoraCompatibleWithModel(lora.model, selectedModel));
+ Boolean(selectedModel && settings.loras.some((lora) => !isCompatibleLora(lora, selectedModel)));
const activeCount = activeReferenceImages + activeConcepts;
const totalCount = referenceImageCount + settings.loras.length;