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(models): add checkpoint repair fields to the model edit form

joshistoast1e89fa9850ab
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.json
index ed363c9172..fc6f589930 100644
--- a/invokeai/frontend/webv2/public/locales/en.json
+++ b/invokeai/frontend/webv2/public/locales/en.json
@@ -846,6 +846,8 @@
"clearSelectedModel": "Clear selected model",
"clearSelection": "Clear selection",
"compactRows": "Compact rows",
+ "configPath": "Config Path",
+ "configPathHelp": "Path to the .yaml config file for legacy checkpoints.",
"conversionFailed": "Conversion failed",
"convert": "Convert",
"convertBody": "Convert \"{{name}}\" to the diffusers format in place? The original checkpoint file is replaced by a diffusers folder.",
@@ -926,6 +928,8 @@
"filterAndSortStarterModels": "Filter and sort starter models",
"filterFiles": "Filter files",
"filterResults": "Filter results",
+ "format": "Format",
+ "formatHelp": "Changing the format re-classifies the model; invalid combinations are rejected.",
"fullRows": "Full rows",
"hash": "Hash",
"huggingFaceKeyDescription": "For gated repos like FLUX. Stored on the InvokeAI server and verified with HuggingFace.",
diff --git a/invokeai/frontend/webv2/src/features/models/core/schemas.ts b/invokeai/frontend/webv2/src/features/models/core/schemas.ts
index 6a8dc38d01..ace2873fbc 100644
--- a/invokeai/frontend/webv2/src/features/models/core/schemas.ts
+++ b/invokeai/frontend/webv2/src/features/models/core/schemas.ts
@@ -11,7 +11,9 @@ const trimmed = z.string().trim();
export const modelEditSchema = z.object({
base: trimmed.min(1, 'Base architecture is required.'),
+ configPath: trimmed,
description: trimmed.max(2000, 'Keep the description under 2000 characters.'),
+ format: trimmed.min(1, 'Format is required.'),
name: trimmed.min(1, 'Name is required.').max(200, 'Keep the name under 200 characters.'),
predictionType: z.union([z.literal(''), z.enum(['epsilon', 'v_prediction', 'sample'])]),
sourceUrl: z.union([z.literal(''), z.url({ error: 'Must be a valid http(s) URL.' })]),
diff --git a/invokeai/frontend/webv2/src/features/models/core/taxonomy.test.ts b/invokeai/frontend/webv2/src/features/models/core/taxonomy.test.ts
index 48236bb52e..a33464a748 100644
--- a/invokeai/frontend/webv2/src/features/models/core/taxonomy.test.ts
+++ b/invokeai/frontend/webv2/src/features/models/core/taxonomy.test.ts
@@ -1,6 +1,13 @@
import { describe, expect, it } from 'vitest';
-import { formatBytes, getModelFormatLabel, getModelTypeLabel } from './taxonomy';
+import {
+ EDITABLE_MODEL_FORMATS,
+ formatBytes,
+ getModelFormatLabel,
+ getModelTypeLabel,
+ getModelVariantLabel,
+ getVariantOptionsFor,
+} from './taxonomy';
describe('formatBytes', () => {
it('renders a dash for missing or invalid sizes', () => {
@@ -33,3 +40,39 @@ describe('label fallbacks', () => {
expect(getModelFormatLabel('gguf_quantized')).toBe('GGUF');
});
});
+
+describe('variant options', () => {
+ it('offers main-model variants keyed by base', () => {
+ expect(getVariantOptionsFor('sd-1', 'main')).toEqual(['normal', 'inpaint']);
+ expect(getVariantOptionsFor('sd-2', 'main')).toEqual(['normal', 'inpaint', 'depth']);
+ expect(getVariantOptionsFor('flux', 'main')).toEqual(['schnell', 'dev', 'dev_fill']);
+ expect(getVariantOptionsFor('wan', 'main')).toEqual(['t2v_a14b', 'i2v_a14b', 'ti2v_5b']);
+ });
+
+ it('distinguishes wan main and wan lora variants', () => {
+ expect(getVariantOptionsFor('wan', 'lora')).toEqual(['a14b', '5b']);
+ expect(getVariantOptionsFor('sdxl', 'lora')).toEqual([]);
+ });
+
+ it('offers per-type variants for encoder-style types regardless of base', () => {
+ expect(getVariantOptionsFor('any', 'clip_embed')).toEqual(['large', 'gigantic']);
+ expect(getVariantOptionsFor('flux2', 'qwen3_encoder')).toEqual(['qwen3_4b', 'qwen3_8b', 'qwen3_06b']);
+ });
+
+ it('returns empty for pairs with no variant concept, enabling free text', () => {
+ expect(getVariantOptionsFor('sdxl', 'vae')).toEqual([]);
+ expect(getVariantOptionsFor('unknown', 'main')).toEqual([]);
+ });
+
+ it('labels known variants and title-cases unknown ones', () => {
+ expect(getModelVariantLabel('dev_fill')).toBe('FLUX Dev - Fill');
+ expect(getModelVariantLabel('some_new_variant')).toBe('Some New Variant');
+ });
+
+ it('keeps unknown and external_api out of the assignable formats', () => {
+ expect(EDITABLE_MODEL_FORMATS).not.toContain('unknown');
+ expect(EDITABLE_MODEL_FORMATS).not.toContain('external_api');
+ expect(EDITABLE_MODEL_FORMATS).toContain('checkpoint');
+ expect(EDITABLE_MODEL_FORMATS).toContain('diffusers');
+ });
+});
diff --git a/invokeai/frontend/webv2/src/features/models/core/taxonomy.ts b/invokeai/frontend/webv2/src/features/models/core/taxonomy.ts
index d99156b0fa..8ec86fe14d 100644
--- a/invokeai/frontend/webv2/src/features/models/core/taxonomy.ts
+++ b/invokeai/frontend/webv2/src/features/models/core/taxonomy.ts
@@ -81,6 +81,91 @@ const FORMAT_LABELS: Record<string, string> = {
export const getModelFormatLabel = (format: ModelFileFormat): string => FORMAT_LABELS[format] ?? toTitleCase(format);
+/**
+ * Formats a user may assign in the edit form (repairing a mis-detected
+ * model). `unknown` is not a repair target and `external_api` would misroute
+ * a local model, mirroring the base select's `external` exclusion. The PATCH
+ * re-validates through the config factory, so an invalid combination is
+ * rejected server-side rather than silently accepted.
+ */
+export const EDITABLE_MODEL_FORMATS: readonly string[] = Object.keys(FORMAT_LABELS).filter(
+ (format) => format !== 'unknown' && format !== 'external_api'
+);
+
+/** Long display names for every known variant value. */
+export const MODEL_VARIANT_LABELS: Record<string, string> = {
+ '5b': 'Wan 2.2 5B LoRA',
+ a14b: 'Wan 2.2 A14B LoRA',
+ cow_mistral3_small: 'cow-mistral3-small (FLUX.2)',
+ depth: 'Depth',
+ dev: 'FLUX Dev',
+ dev_fill: 'FLUX Dev - Fill',
+ edit: 'Qwen Image Edit',
+ generate: 'Qwen Image',
+ gigantic: 'CLIP G',
+ i2v_a14b: 'Wan 2.2 I2V A14B',
+ inpaint: 'Inpaint',
+ klein_4b: 'FLUX.2 Klein 4B',
+ klein_4b_base: 'FLUX.2 Klein 4B Base',
+ klein_9b: 'FLUX.2 Klein 9B',
+ klein_9b_base: 'FLUX.2 Klein 9B Base',
+ krea2_base: 'Krea-2 Raw',
+ krea2_turbo: 'Krea-2 Turbo',
+ large: 'CLIP L',
+ mistral3_24b: 'Mistral Small 3 (24B, FLUX.2)',
+ normal: 'Normal',
+ qwen3_06b: 'Qwen3 0.6B',
+ qwen3_4b: 'Qwen3 4B',
+ qwen3_8b: 'Qwen3 8B',
+ res2k_sr4x: 'PiD 2K (4x SR)',
+ res2kto4k_sr4x: 'PiD 4K (4x SR Upscale)',
+ schnell: 'FLUX Schnell',
+ t2v_a14b: 'Wan 2.2 T2V A14B',
+ ti2v_5b: 'Wan 2.2 TI2V 5B',
+ turbo: 'Z-Image Turbo',
+ zbase: 'Z-Image Base',
+};
+
+export const getModelVariantLabel = (variant: string): string => MODEL_VARIANT_LABELS[variant] ?? toTitleCase(variant);
+
+// Mirrors the backend's per-class variant enums (taxonomy.py): main models
+// key their variants off the base, and a few non-main types carry their own.
+const MAIN_VARIANTS_BY_BASE: Record<string, readonly string[]> = {
+ flux: ['schnell', 'dev', 'dev_fill'],
+ flux2: ['klein_4b', 'klein_4b_base', 'klein_9b', 'klein_9b_base', 'dev'],
+ 'krea-2': ['krea2_turbo', 'krea2_base'],
+ 'qwen-image': ['generate', 'edit'],
+ 'sd-1': ['normal', 'inpaint'],
+ 'sd-2': ['normal', 'inpaint', 'depth'],
+ sdxl: ['normal', 'inpaint'],
+ 'sdxl-refiner': ['normal'],
+ wan: ['t2v_a14b', 'i2v_a14b', 'ti2v_5b'],
+ 'z-image': ['turbo', 'zbase'],
+};
+
+const VARIANTS_BY_TYPE: Record<string, readonly string[]> = {
+ clip_embed: ['large', 'gigantic'],
+ mistral_encoder: ['cow_mistral3_small', 'mistral3_24b'],
+ pid_decoder: ['res2k_sr4x', 'res2kto4k_sr4x'],
+ qwen3_encoder: ['qwen3_4b', 'qwen3_8b', 'qwen3_06b'],
+};
+
+/**
+ * Constrained variant choices for a base/type pair; empty means the pair has
+ * no variant concept and the edit form falls back to free text.
+ */
+export const getVariantOptionsFor = (base: string, type: string): readonly string[] => {
+ if (type === 'main') {
+ return MAIN_VARIANTS_BY_BASE[base] ?? [];
+ }
+
+ if (type === 'lora') {
+ return base === 'wan' ? ['a14b', '5b'] : [];
+ }
+
+ return VARIANTS_BY_TYPE[type] ?? [];
+};
+
const BYTE_UNITS = ['B', 'KB', 'MB', 'GB', 'TB'] as const;
export const formatBytes = (bytes: number | null | undefined): string => {
diff --git a/invokeai/frontend/webv2/src/features/models/ui/detail/ModelDetail.tsx b/invokeai/frontend/webv2/src/features/models/ui/detail/ModelDetail.tsx
index e4de516adf..e450e533d1 100644
--- a/invokeai/frontend/webv2/src/features/models/ui/detail/ModelDetail.tsx
+++ b/invokeai/frontend/webv2/src/features/models/ui/detail/ModelDetail.tsx
@@ -33,6 +33,7 @@ type VaeCpuOnlyModel = Pick<ModelConfig, 'cpu_only' | 'key' | 'name' | 'type'>;
type ModelIdentityModel = Pick<
ModelConfig,
| 'base'
+ | 'config_path'
| 'cover_image'
| 'description'
| 'file_size'
@@ -63,6 +64,7 @@ const selectModelIdentity = (models: readonly ModelConfig[], modelKey: string):
return model
? {
base: model.base,
+ config_path: model.config_path,
cover_image: model.cover_image,
description: model.description,
file_size: model.file_size,
diff --git a/invokeai/frontend/webv2/src/features/models/ui/detail/ModelEditForm.browser.test.tsx b/invokeai/frontend/webv2/src/features/models/ui/detail/ModelEditForm.browser.test.tsx
new file mode 100644
index 0000000000..885dce570f
--- /dev/null
+++ b/invokeai/frontend/webv2/src/features/models/ui/detail/ModelEditForm.browser.test.tsx
@@ -0,0 +1,182 @@
+import type { ModelConfig } from '@features/models/core/types';
+
+import { ChakraProvider } from '@chakra-ui/react';
+import { accountLifecycle } from '@platform/state/accountLifecycle';
+import { system } from '@theme/system';
+import { act } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { afterEach, beforeEach, describe, expect, it, vi, type Mock } from 'vitest';
+
+import { ModelEditForm } from './ModelEditForm';
+
+const api = vi.hoisted(() => ({
+ getModelsDir: vi.fn(),
+ listMissingModels: vi.fn(),
+ listModels: vi.fn(),
+ updateModel: vi.fn(),
+}));
+
+vi.mock('@features/models/data/api', () => api);
+vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string) => key }) }));
+
+(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
+
+const checkpointMain = {
+ base: 'sd-1',
+ config_path: 'v1-inference.yaml',
+ description: null,
+ file_size: 1,
+ format: 'checkpoint',
+ hash: 'hash',
+ key: 'ckpt-main',
+ name: 'Checkpoint Main',
+ path: '/models/main.ckpt',
+ prediction_type: null,
+ source: '/models/main.ckpt',
+ source_type: 'path',
+ type: 'main',
+ variant: 'normal',
+} as ModelConfig;
+
+const diffusersVae = {
+ base: 'sdxl',
+ description: null,
+ file_size: 1,
+ format: 'diffusers',
+ hash: 'hash',
+ key: 'sdxl-vae',
+ name: 'SDXL VAE',
+ path: 'sdxl/vae',
+ source: 'sdxl/vae',
+ source_type: 'path',
+ type: 'vae',
+} as ModelConfig;
+
+const setInputValue = (input: HTMLInputElement, value: string): void => {
+ const setter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value')!.set!;
+
+ setter.call(input, value);
+ input.dispatchEvent(new Event('input', { bubbles: true }));
+};
+
+describe('ModelEditForm', () => {
+ let host: HTMLDivElement;
+ let root: Root;
+ let onCancel: Mock<() => void>;
+ let onSaved: Mock<() => void>;
+
+ const mount = async (model: ModelConfig) => {
+ await act(() => {
+ root.render(
+ <ChakraProvider value={system}>
+ <ModelEditForm model={model} onCancel={onCancel} onSaved={onSaved} />
+ </ChakraProvider>
+ );
+ });
+ };
+
+ const saveButton = () =>
+ [...host.querySelectorAll<HTMLButtonElement>('button')].find((button) =>
+ button.textContent.includes('users.saveChanges')
+ )!;
+
+ beforeEach(() => {
+ api.updateModel.mockReset();
+ onCancel = vi.fn();
+ onSaved = vi.fn();
+ accountLifecycle.activate('model-edit-test-a', ':user:model-edit-test-a');
+ host = document.createElement('div');
+ document.body.append(host);
+ root = createRoot(host);
+ });
+
+ afterEach(async () => {
+ await act(() => root.unmount());
+ host.remove();
+ accountLifecycle.invalidate();
+ });
+
+ it('offers format, a constrained variant select, and config path for a checkpoint main', async () => {
+ await mount(checkpointMain);
+
+ expect(host.querySelector('[aria-label="models.format"]')).not.toBeNull();
+ // sd-1 main has a curated variant list, so the field is a select.
+ expect(host.querySelector('[aria-label="models.variant"]')).not.toBeNull();
+ expect(host.textContent).toContain('models.configPath');
+ expect(host.querySelector<HTMLInputElement>('input[value="v1-inference.yaml"]')).not.toBeNull();
+ });
+
+ it('hides config path and falls back to free-text variant when the model has neither', async () => {
+ await mount(diffusersVae);
+
+ expect(host.textContent).not.toContain('models.configPath');
+ // sdxl vae has no variant concept: free-text input, no select trigger.
+ expect(host.querySelector('[aria-label="models.variant"]')).toBeNull();
+ });
+
+ it('submits format and config_path alongside the identity fields', async () => {
+ api.updateModel.mockResolvedValue({ ...checkpointMain, name: 'Renamed' });
+ await mount(checkpointMain);
+
+ const nameInput = host.querySelector<HTMLInputElement>('input[value="Checkpoint Main"]')!;
+
+ await act(async () => {
+ setInputValue(nameInput, 'Renamed');
+ await Promise.resolve();
+ });
+
+ await act(async () => {
+ saveButton().click();
+ await Promise.resolve();
+ });
+
+ expect(api.updateModel).toHaveBeenCalledWith(
+ 'ckpt-main',
+ expect.objectContaining({
+ base: 'sd-1',
+ config_path: 'v1-inference.yaml',
+ format: 'checkpoint',
+ name: 'Renamed',
+ type: 'main',
+ variant: 'normal',
+ }),
+ expect.anything()
+ );
+ expect(onSaved).toHaveBeenCalledOnce();
+ });
+
+ it('nulls a cleared config path but never sends one for models without the field', async () => {
+ api.updateModel.mockResolvedValue(checkpointMain);
+ await mount(checkpointMain);
+
+ const configInput = host.querySelector<HTMLInputElement>('input[value="v1-inference.yaml"]')!;
+
+ await act(async () => {
+ setInputValue(configInput, '');
+ await Promise.resolve();
+ });
+
+ await act(async () => {
+ saveButton().click();
+ await Promise.resolve();
+ });
+
+ expect(api.updateModel).toHaveBeenCalledWith(
+ 'ckpt-main',
+ expect.objectContaining({ config_path: null }),
+ expect.anything()
+ );
+
+ api.updateModel.mockClear();
+ api.updateModel.mockResolvedValue(diffusersVae);
+ await mount(diffusersVae);
+
+ await act(async () => {
+ saveButton().click();
+ await Promise.resolve();
+ });
+
+ expect(api.updateModel).toHaveBeenCalledOnce();
+ expect(api.updateModel.mock.calls[0]![1]).not.toHaveProperty('config_path');
+ });
+});
diff --git a/invokeai/frontend/webv2/src/features/models/ui/detail/ModelEditForm.tsx b/invokeai/frontend/webv2/src/features/models/ui/detail/ModelEditForm.tsx
index 31efb49e95..8a65fbadf0 100644
--- a/invokeai/frontend/webv2/src/features/models/ui/detail/ModelEditForm.tsx
+++ b/invokeai/frontend/webv2/src/features/models/ui/detail/ModelEditForm.tsx
@@ -4,7 +4,14 @@ import type { ModelConfig, PredictionType } from '@features/models/core/types';
import { createListCollection, HStack, Input, Stack, Text, Textarea } from '@chakra-ui/react';
import { getModelBaseLabel, KNOWN_MODEL_BASES } from '@features/models/core/baseIdentity';
import { modelEditSchema, type ModelEditFormValues } from '@features/models/core/schemas';
-import { getModelTypeLabel, MODEL_CATEGORIES } from '@features/models/core/taxonomy';
+import {
+ EDITABLE_MODEL_FORMATS,
+ getModelFormatLabel,
+ getModelTypeLabel,
+ getModelVariantLabel,
+ getVariantOptionsFor,
+ MODEL_CATEGORIES,
+} from '@features/models/core/taxonomy';
import { updateModel } from '@features/models/data/api';
import { replaceModelInStore } from '@features/models/data/modelsStore';
import { useZodForm } from '@platform/react/useZodForm';
@@ -28,7 +35,16 @@ const MODEL_TYPE_COLLECTION = createListCollection({
/** Zod-validated editor for a model's identity fields. */
type ModelEditTarget = Pick<
ModelConfig,
- 'base' | 'description' | 'key' | 'name' | 'prediction_type' | 'source_url' | 'type' | 'variant'
+ | 'base'
+ | 'config_path'
+ | 'description'
+ | 'format'
+ | 'key'
+ | 'name'
+ | 'prediction_type'
+ | 'source_url'
+ | 'type'
+ | 'variant'
>;
export const ModelEditForm = ({
@@ -41,9 +57,14 @@ export const ModelEditForm = ({
onSaved: () => void;
}) => {
const { t } = useTranslation();
+ // `config_path` only exists on checkpoint-style config classes; its absence
+ // (not emptiness) hides the field, since the PATCH would silently drop it.
+ const hasConfigPath = model.config_path !== undefined;
const form = useZodForm(modelEditSchema, {
base: String(model.base),
+ configPath: model.config_path ?? '',
description: model.description ?? '',
+ format: String(model.format),
name: model.name,
predictionType: (model.prediction_type ?? '') as ModelEditFormValues['predictionType'],
sourceUrl: model.source_url ?? '',
@@ -72,6 +93,34 @@ export const ModelEditForm = ({
}),
[t]
);
+ const formatCollection = useMemo(() => {
+ const formats: readonly string[] = EDITABLE_MODEL_FORMATS.includes(String(model.format))
+ ? EDITABLE_MODEL_FORMATS
+ : [String(model.format), ...EDITABLE_MODEL_FORMATS];
+
+ return createListCollection({
+ items: formats.map((format) => ({ label: getModelFormatLabel(format), value: format })),
+ });
+ }, [model.format]);
+ // Reacts to base/type edits so the offered variants always match the
+ // combination being saved; an unknown current value stays selectable.
+ const { variantCollection, variantOptions } = useMemo(() => {
+ const options = getVariantOptionsFor(form.values.base, form.values.type);
+ const withCurrent =
+ form.values.variant !== '' && !options.includes(form.values.variant)
+ ? [form.values.variant, ...options]
+ : options;
+
+ return {
+ variantCollection: createListCollection({
+ items: [
+ { label: t('common.none'), value: '' },
+ ...withCurrent.map((variant) => ({ label: getModelVariantLabel(variant), value: variant })),
+ ],
+ }),
+ variantOptions: options,
+ };
+ }, [form.values.base, form.values.type, form.values.variant, t]);
const handleSave = () =>
form.handleSubmit(async (values) => {
@@ -83,11 +132,13 @@ export const ModelEditForm = ({
{
base: values.base,
description: values.description || null,
+ format: values.format,
name: values.name,
prediction_type: values.predictionType === '' ? null : (values.predictionType as PredictionType),
source_url: values.sourceUrl === '' ? null : values.sourceUrl,
type: values.type,
variant: values.variant === '' ? null : values.variant,
+ ...(hasConfigPath ? { config_path: values.configPath === '' ? null : values.configPath } : {}),
},
owner.signal
);
@@ -156,11 +207,27 @@ export const ModelEditForm = ({
</HStack>
<HStack align="start" gap="2">
<Field error={form.errors.variant} helpText={t('models.variantHelp')} label={t('models.variant')}>
- <Input
- size="sm"
- value={form.values.variant}
- onChange={(event) => form.setValue('variant', event.currentTarget.value)}
- />
+ {variantOptions.length > 0 ? (
+ <Select
+ aria-label={t('models.variant')}
+ collection={variantCollection}
+ size="sm"
+ value={[form.values.variant]}
+ onValueChange={({ value }) => {
+ const variant = value[0];
+
+ if (variant !== undefined) {
+ form.setValue('variant', variant);
+ }
+ }}
+ />
+ ) : (
+ <Input
+ size="sm"
+ value={form.values.variant}
+ onChange={(event) => form.setValue('variant', event.currentTarget.value)}
+ />
+ )}
</Field>
<Field error={form.errors.predictionType} label={t('models.predictionType')}>
<Select
@@ -178,6 +245,32 @@ export const ModelEditForm = ({
/>
</Field>
</HStack>
+ <HStack align="start" gap="2">
+ <Field error={form.errors.format} helpText={t('models.formatHelp')} label={t('models.format')}>
+ <Select
+ aria-label={t('models.format')}
+ collection={formatCollection}
+ size="sm"
+ value={[form.values.format]}
+ onValueChange={({ value }) => {
+ const format = value[0];
+
+ if (format !== undefined) {
+ form.setValue('format', format);
+ }
+ }}
+ />
+ </Field>
+ {hasConfigPath ? (
+ <Field error={form.errors.configPath} helpText={t('models.configPathHelp')} label={t('models.configPath')}>
+ <Input
+ size="sm"
+ value={form.values.configPath}
+ onChange={(event) => form.setValue('configPath', event.currentTarget.value)}
+ />
+ </Field>
+ ) : null}
+ </HStack>
<Field error={form.errors.sourceUrl} helpText={t('models.sourceUrlHelp')} label={t('models.sourceUrl')}>
<Input
aria-invalid={form.errors.sourceUrl ? true : undefined}