diff --git a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/AddModelPanel/AdvancedImport.tsx b/invokeai/frontend/web/src/features/modelManagerV2/subpanels/AddModelPanel/AdvancedImport.tsx index e115c68dca..56abf7b09a 100644 --- a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/AddModelPanel/AdvancedImport.tsx +++ b/invokeai/frontend/web/src/features/modelManagerV2/subpanels/AddModelPanel/AdvancedImport.tsx @@ -148,11 +148,11 @@ export const AdvancedImport = () => { {t('modelManager.baseModel')} - control={control} name="base" /> + {t('common.format')} - control={control} name="format" /> + diff --git a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/Fields/BaseModelSelect.tsx b/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/Fields/BaseModelSelect.tsx index bcb84c9b47..f11b436044 100644 --- a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/Fields/BaseModelSelect.tsx +++ b/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/Fields/BaseModelSelect.tsx @@ -14,7 +14,7 @@ const options: ComboboxOption[] = [ { value: 'sdxl-refiner', label: MODEL_TYPE_MAP['sdxl-refiner'] }, ]; -const BaseModelSelect = (props: UseControllerProps) => { +const BaseModelSelect = (props: UseControllerProps) => { const { field } = useController(props); const value = useMemo(() => options.find((o) => o.value === field.value), [field.value]); const onChange = useCallback( diff --git a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/Fields/ModelFormatSelect.tsx b/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/Fields/ModelFormatSelect.tsx index 7c8bed9c02..298dc012f0 100644 --- a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/Fields/ModelFormatSelect.tsx +++ b/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/Fields/ModelFormatSelect.tsx @@ -1,13 +1,12 @@ import type { ComboboxOnChange, ComboboxOption } from '@invoke-ai/ui-library'; import { Combobox } from '@invoke-ai/ui-library'; import { typedMemo } from 'common/util/typedMemo'; -import { LORA_MODEL_FORMAT_MAP } from 'features/parameters/types/constants'; import { useCallback, useMemo } from 'react'; import type { UseControllerProps } from 'react-hook-form'; import { useController, useWatch } from 'react-hook-form'; import type { AnyModelConfig } from 'services/api/types'; -const ModelFormatSelect = (props: UseControllerProps) => { +const ModelFormatSelect = (props: UseControllerProps) => { const { field, formState } = useController(props); const type = useWatch({ control: props.control, name: 'type' }); @@ -21,10 +20,10 @@ const ModelFormatSelect = (props: UseControllerProps { const modelType = type || formState.defaultValues?.type; if (modelType === 'lora') { - return Object.keys(LORA_MODEL_FORMAT_MAP).map((format) => ({ - value: format, - label: LORA_MODEL_FORMAT_MAP[format], - })) as ComboboxOption[]; + return [ + { value: 'lycoris', label: 'LyCORIS' }, + { value: 'diffusers', label: 'Diffusers' }, + ]; } else if (modelType === 'embedding') { return [ { value: 'embedding_file', label: 'Embedding File' }, diff --git a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/Fields/ModelTypeSelect.tsx b/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/Fields/ModelTypeSelect.tsx index e0b244baa9..dc42ae89a8 100644 --- a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/Fields/ModelTypeSelect.tsx +++ b/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/Fields/ModelTypeSelect.tsx @@ -15,7 +15,7 @@ const options: ComboboxOption[] = [ { value: 'controlnet', label: MODEL_TYPE_LABELS['controlnet'] as string }, { value: 'ip_adapter', label: MODEL_TYPE_LABELS['ip_adapter'] as string }, { value: 't2i_adapater', label: MODEL_TYPE_LABELS['t2i_adapter'] as string }, -]; +] as const const ModelTypeSelect = (props: UseControllerProps) => { const { field } = useController(props); diff --git a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/ModelEdit.tsx b/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/ModelEdit.tsx index 2391bf33ad..5025271b8a 100644 --- a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/ModelEdit.tsx +++ b/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/ModelEdit.tsx @@ -14,22 +14,13 @@ import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; import { setSelectedModelMode } from 'features/modelManagerV2/store/modelManagerV2Slice'; import { addToast } from 'features/system/store/systemSlice'; import { makeToast } from 'features/system/util/makeToast'; -import { useCallback, useMemo } from 'react'; +import { useCallback } from 'react'; import type { SubmitHandler } from 'react-hook-form'; import { useForm } from 'react-hook-form'; import { useTranslation } from 'react-i18next'; +import type { UpdateModelArg } from 'services/api/endpoints/models'; import { useGetModelConfigQuery, useUpdateModelsMutation } from 'services/api/endpoints/models'; -import type { - AnyModelConfig, - CheckpointModelConfig, - ControlNetModelConfig, - DiffusersModelConfig, - IPAdapterModelConfig, - LoRAModelConfig, - T2IAdapterModelConfig, - TextualInversionModelConfig, - VAEModelConfig, -} from 'services/api/types'; +import type { AnyModelConfig } from 'services/api/types'; import BaseModelSelect from './Fields/BaseModelSelect'; import BooleanSelect from './Fields/BooleanSelect'; @@ -48,38 +39,38 @@ export const ModelEdit = () => { const { t } = useTranslation(); - const modelData = useMemo(() => { - if (!data) { - return null; - } - const modelFormat = data.format; - const modelType = data.type; + // const modelData = useMemo(() => { + // if (!data) { + // return null; + // } + // const modelFormat = data.format; + // const modelType = data.type; - if (modelType === 'main') { - if (modelFormat === 'diffusers') { - return data as DiffusersModelConfig; - } else if (modelFormat === 'checkpoint') { - return data as CheckpointModelConfig; - } - } + // if (modelType === 'main') { + // if (modelFormat === 'diffusers') { + // return data as DiffusersModelConfig; + // } else if (modelFormat === 'checkpoint') { + // return data as CheckpointModelConfig; + // } + // } - switch (modelType) { - case 'lora': - return data as LoRAModelConfig; - case 'embedding': - return data as TextualInversionModelConfig; - case 't2i_adapter': - return data as T2IAdapterModelConfig; - case 'ip_adapter': - return data as IPAdapterModelConfig; - case 'controlnet': - return data as ControlNetModelConfig; - case 'vae': - return data as VAEModelConfig; - default: - return null; - } - }, [data]); + // switch (modelType) { + // case 'lora': + // return data as LoRAModelConfig; + // case 'embedding': + // return data as TextualInversionModelConfig; + // case 't2i_adapter': + // return data as T2IAdapterModelConfig; + // case 'ip_adapter': + // return data as IPAdapterModelConfig; + // case 'controlnet': + // return data as ControlNetModelConfig; + // case 'vae': + // return data as VAEModelConfig; + // default: + // return null; + // } + // }, [data]); const { register, @@ -88,9 +79,9 @@ export const ModelEdit = () => { formState: { errors }, reset, watch, - } = useForm({ + } = useForm({ defaultValues: { - ...modelData, + ...data, }, mode: 'onChange', }); @@ -100,19 +91,19 @@ export const ModelEdit = () => { const onSubmit = useCallback>( (values) => { - if (!modelData?.key) { + if (!data?.key) { return; } - const responseBody = { - key: modelData.key, + const responseBody: UpdateModelArg = { + key: data.key, body: values, }; updateModel(responseBody) .unwrap() .then((payload) => { - reset(payload as AnyModelConfig, { keepDefaultValues: true }); + reset(payload, { keepDefaultValues: true }); dispatch(setSelectedModelMode('view')); dispatch( addToast( @@ -135,7 +126,7 @@ export const ModelEdit = () => { ); }); }, - [dispatch, modelData?.key, reset, t, updateModel] + [dispatch, data?.key, reset, t, updateModel] ); const handleClickCancel = useCallback(() => { @@ -146,7 +137,7 @@ export const ModelEdit = () => { return {t('common.loading')}; } - if (!modelData) { + if (!data) { return {t('common.somethingWentWrong')}; } return ( @@ -193,7 +184,7 @@ export const ModelEdit = () => { {t('modelManager.baseModel')} - control={control} name="base" /> + {t('modelManager.modelType')} @@ -203,7 +194,7 @@ export const ModelEdit = () => { {t('common.format')} - control={control} name="format" /> + {t('modelManager.path')} diff --git a/invokeai/frontend/web/src/features/parameters/types/constants.ts b/invokeai/frontend/web/src/features/parameters/types/constants.ts index baa255a102..5bdfe9937b 100644 --- a/invokeai/frontend/web/src/features/parameters/types/constants.ts +++ b/invokeai/frontend/web/src/features/parameters/types/constants.ts @@ -1,5 +1,4 @@ import type { ComboboxOption } from '@invoke-ai/ui-library'; -import type { LoRAModelFormat } from 'services/api/types'; /** * Mapping of base model to human readable name @@ -49,16 +48,6 @@ export const CLIP_SKIP_MAP = { }, }; -/** - * Mapping of LoRA format to human readable name - */ -export const LORA_MODEL_FORMAT_MAP: { - [key in LoRAModelFormat]: string; -} = { - lycoris: 'LyCORIS', - diffusers: 'Diffusers', -}; - /** * Mapping of schedulers to human readable name */ diff --git a/invokeai/frontend/web/src/services/api/endpoints/models.ts b/invokeai/frontend/web/src/services/api/endpoints/models.ts index 827356cd22..c125dcd371 100644 --- a/invokeai/frontend/web/src/services/api/endpoints/models.ts +++ b/invokeai/frontend/web/src/services/api/endpoints/models.ts @@ -19,7 +19,7 @@ import type { import type { ApiTagDescription, tagTypes } from '..'; import { api, buildV2Url, LIST_TAG } from '..'; -type UpdateModelArg = { +export type UpdateModelArg = { key: paths['/api/v2/models/i/{key}']['patch']['parameters']['path']['key']; body: paths['/api/v2/models/i/{key}']['patch']['requestBody']['content']['application/json']; }; diff --git a/invokeai/frontend/web/src/services/api/types.ts b/invokeai/frontend/web/src/services/api/types.ts index 2ecf0a7a09..314eb07bfa 100644 --- a/invokeai/frontend/web/src/services/api/types.ts +++ b/invokeai/frontend/web/src/services/api/types.ts @@ -50,7 +50,6 @@ export type BaseModelType = S['BaseModelType']; export type MainModelField = S['MainModelField']; export type VAEModelField = S['VAEModelField']; export type LoRAModelField = S['LoRAModelField']; -export type LoRAModelFormat = S['LoRAModelFormat']; export type ControlNetModelField = S['ControlNetModelField']; export type IPAdapterModelField = S['IPAdapterModelField']; export type T2IAdapterModelField = S['T2IAdapterModelField']; @@ -72,8 +71,6 @@ export type DiffusersModelConfig = S['MainDiffusersConfig']; export type CheckpointModelConfig = S['MainCheckpointConfig']; type CLIPVisionDiffusersConfig = S['CLIPVisionDiffusersConfig']; export type MainModelConfig = DiffusersModelConfig | CheckpointModelConfig; -export type RefinerMainModelConfig = Omit & { base: 'sdxl-refiner' }; -export type NonRefinerMainModelConfig = Omit & { base: 'any' | 'sd-1' | 'sd-2' | 'sdxl' }; export type AnyModelConfig = | LoRAModelConfig | VAEModelConfig @@ -81,20 +78,9 @@ export type AnyModelConfig = | IPAdapterModelConfig | T2IAdapterModelConfig | TextualInversionModelConfig - | RefinerMainModelConfig - | NonRefinerMainModelConfig + | MainModelConfig | CLIPVisionDiffusersConfig; -type AnyModelConfig2 = - | (S['MainDiffusersConfig'] | S['MainCheckpointConfig']) - | (S['VaeDiffusersConfig'] | S['VaeCheckpointConfig']) - | (S['ControlNetDiffusersConfig'] | S['ControlNetCheckpointConfig']) - | S['LoRAConfig'] - | S['TextualInversionConfig'] - | S['IPAdapterConfig'] - | S['CLIPVisionDiffusersConfig'] - | S['T2IConfig']; - export const isLoRAModelConfig = (config: AnyModelConfig): config is LoRAModelConfig => { return config.type === 'lora'; }; @@ -119,16 +105,14 @@ export const isTextualInversionModelConfig = (config: AnyModelConfig): config is return config.type === 'embedding'; }; -export const isNonRefinerMainModelConfig = (config: AnyModelConfig): config is NonRefinerMainModelConfig => { +export const isNonRefinerMainModelConfig = (config: AnyModelConfig): config is MainModelConfig => { return config.type === 'main' && config.base !== 'sdxl-refiner'; }; -export const isRefinerMainModelModelConfig = (config: AnyModelConfig): config is RefinerMainModelConfig => { +export const isRefinerMainModelModelConfig = (config: AnyModelConfig): config is MainModelConfig => { return config.type === 'main' && config.base === 'sdxl-refiner'; }; -export type MergeModelConfig = S['Body_merge']; -export type ImportModelConfig = S['Body_import_model']; export type ModelInstallJob = S['ModelInstallJob']; export type ModelInstallStatus = S['InstallStatus'];