mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Frontend changes to enable multiple IP-Adapters in the workflow editor.
This commit is contained in:
@ -2,13 +2,15 @@ import {
|
|||||||
IPAdapterInputFieldTemplate,
|
IPAdapterInputFieldTemplate,
|
||||||
IPAdapterInputFieldValue,
|
IPAdapterInputFieldValue,
|
||||||
FieldComponentProps,
|
FieldComponentProps,
|
||||||
|
IPAdapterPolymorphicInputFieldValue,
|
||||||
|
IPAdapterPolymorphicInputFieldTemplate,
|
||||||
} from 'features/nodes/types/types';
|
} from 'features/nodes/types/types';
|
||||||
import { memo } from 'react';
|
import { memo } from 'react';
|
||||||
|
|
||||||
const IPAdapterInputFieldComponent = (
|
const IPAdapterInputFieldComponent = (
|
||||||
_props: FieldComponentProps<
|
_props: FieldComponentProps<
|
||||||
IPAdapterInputFieldValue,
|
IPAdapterInputFieldValue | IPAdapterPolymorphicInputFieldValue,
|
||||||
IPAdapterInputFieldTemplate
|
IPAdapterInputFieldTemplate | IPAdapterPolymorphicInputFieldTemplate
|
||||||
>
|
>
|
||||||
) => {
|
) => {
|
||||||
return null;
|
return null;
|
||||||
|
@ -32,6 +32,7 @@ export const COLLECTION_TYPES: FieldType[] = [
|
|||||||
'ControlCollection',
|
'ControlCollection',
|
||||||
'ColorCollection',
|
'ColorCollection',
|
||||||
'T2IAdapterCollection',
|
'T2IAdapterCollection',
|
||||||
|
'IPAdapterCollection',
|
||||||
];
|
];
|
||||||
|
|
||||||
export const POLYMORPHIC_TYPES: FieldType[] = [
|
export const POLYMORPHIC_TYPES: FieldType[] = [
|
||||||
@ -45,6 +46,7 @@ export const POLYMORPHIC_TYPES: FieldType[] = [
|
|||||||
'ControlPolymorphic',
|
'ControlPolymorphic',
|
||||||
'ColorPolymorphic',
|
'ColorPolymorphic',
|
||||||
'T2IAdapterPolymorphic',
|
'T2IAdapterPolymorphic',
|
||||||
|
'IPAdapterPolymorphic',
|
||||||
];
|
];
|
||||||
|
|
||||||
export const MODEL_TYPES: FieldType[] = [
|
export const MODEL_TYPES: FieldType[] = [
|
||||||
@ -60,6 +62,7 @@ export const MODEL_TYPES: FieldType[] = [
|
|||||||
'VaeField',
|
'VaeField',
|
||||||
'ClipField',
|
'ClipField',
|
||||||
'T2IAdapterModelField',
|
'T2IAdapterModelField',
|
||||||
|
'IPAdapterModelField',
|
||||||
];
|
];
|
||||||
|
|
||||||
export const COLLECTION_MAP: FieldTypeMapWithNumber = {
|
export const COLLECTION_MAP: FieldTypeMapWithNumber = {
|
||||||
@ -74,6 +77,7 @@ export const COLLECTION_MAP: FieldTypeMapWithNumber = {
|
|||||||
ControlField: 'ControlCollection',
|
ControlField: 'ControlCollection',
|
||||||
ColorField: 'ColorCollection',
|
ColorField: 'ColorCollection',
|
||||||
T2IAdapterField: 'T2IAdapterCollection',
|
T2IAdapterField: 'T2IAdapterCollection',
|
||||||
|
IPAdapterField: 'IPAdapterCollection',
|
||||||
};
|
};
|
||||||
export const isCollectionItemType = (
|
export const isCollectionItemType = (
|
||||||
itemType: string | undefined
|
itemType: string | undefined
|
||||||
@ -92,6 +96,7 @@ export const SINGLE_TO_POLYMORPHIC_MAP: FieldTypeMapWithNumber = {
|
|||||||
ControlField: 'ControlPolymorphic',
|
ControlField: 'ControlPolymorphic',
|
||||||
ColorField: 'ColorPolymorphic',
|
ColorField: 'ColorPolymorphic',
|
||||||
T2IAdapterField: 'T2IAdapterPolymorphic',
|
T2IAdapterField: 'T2IAdapterPolymorphic',
|
||||||
|
IPAdapterField: 'IPAdapterPolymorphic',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const POLYMORPHIC_TO_SINGLE_MAP: FieldTypeMap = {
|
export const POLYMORPHIC_TO_SINGLE_MAP: FieldTypeMap = {
|
||||||
@ -105,6 +110,7 @@ export const POLYMORPHIC_TO_SINGLE_MAP: FieldTypeMap = {
|
|||||||
ControlPolymorphic: 'ControlField',
|
ControlPolymorphic: 'ControlField',
|
||||||
ColorPolymorphic: 'ColorField',
|
ColorPolymorphic: 'ColorField',
|
||||||
T2IAdapterPolymorphic: 'T2IAdapterField',
|
T2IAdapterPolymorphic: 'T2IAdapterField',
|
||||||
|
IPAdapterPolymorphic: 'IPAdapterField',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const TYPES_WITH_INPUT_COMPONENTS: FieldType[] = [
|
export const TYPES_WITH_INPUT_COMPONENTS: FieldType[] = [
|
||||||
@ -278,6 +284,11 @@ export const FIELDS: Record<FieldType, FieldUIConfig> = {
|
|||||||
description: t('nodes.integerPolymorphicDescription'),
|
description: t('nodes.integerPolymorphicDescription'),
|
||||||
title: t('nodes.integerPolymorphic'),
|
title: t('nodes.integerPolymorphic'),
|
||||||
},
|
},
|
||||||
|
IPAdapterCollection: {
|
||||||
|
color: 'teal.500',
|
||||||
|
description: t('nodes.ipAdapterCollectionDescription'),
|
||||||
|
title: t('nodes.ipAdapterCollection'),
|
||||||
|
},
|
||||||
IPAdapterField: {
|
IPAdapterField: {
|
||||||
color: 'teal.500',
|
color: 'teal.500',
|
||||||
description: 'IP-Adapter info passed between nodes.',
|
description: 'IP-Adapter info passed between nodes.',
|
||||||
@ -288,6 +299,11 @@ export const FIELDS: Record<FieldType, FieldUIConfig> = {
|
|||||||
description: 'IP-Adapter model',
|
description: 'IP-Adapter model',
|
||||||
title: 'IP-Adapter Model',
|
title: 'IP-Adapter Model',
|
||||||
},
|
},
|
||||||
|
IPAdapterPolymorphic: {
|
||||||
|
color: 'teal.500',
|
||||||
|
description: 'IP-Adapter info passed between nodes.',
|
||||||
|
title: 'IP-Adapter Polymorphic',
|
||||||
|
},
|
||||||
LatentsCollection: {
|
LatentsCollection: {
|
||||||
color: 'pink.500',
|
color: 'pink.500',
|
||||||
description: t('nodes.latentsCollectionDescription'),
|
description: t('nodes.latentsCollectionDescription'),
|
||||||
|
@ -100,8 +100,10 @@ export const zFieldType = z.enum([
|
|||||||
'integer',
|
'integer',
|
||||||
'IntegerCollection',
|
'IntegerCollection',
|
||||||
'IntegerPolymorphic',
|
'IntegerPolymorphic',
|
||||||
|
'IPAdapterCollection',
|
||||||
'IPAdapterField',
|
'IPAdapterField',
|
||||||
'IPAdapterModelField',
|
'IPAdapterModelField',
|
||||||
|
'IPAdapterPolymorphic',
|
||||||
'LatentsCollection',
|
'LatentsCollection',
|
||||||
'LatentsField',
|
'LatentsField',
|
||||||
'LatentsPolymorphic',
|
'LatentsPolymorphic',
|
||||||
@ -430,6 +432,24 @@ export type IPAdapterInputFieldValue = z.infer<
|
|||||||
typeof zIPAdapterInputFieldValue
|
typeof zIPAdapterInputFieldValue
|
||||||
>;
|
>;
|
||||||
|
|
||||||
|
export const zIPAdapterPolymorphicInputFieldValue = zInputFieldValueBase.extend(
|
||||||
|
{
|
||||||
|
type: z.literal('IPAdapterPolymorphic'),
|
||||||
|
value: z.union([zIPAdapterField, z.array(zIPAdapterField)]).optional(),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
export type IPAdapterPolymorphicInputFieldValue = z.infer<
|
||||||
|
typeof zT2IAdapterPolymorphicInputFieldValue
|
||||||
|
>;
|
||||||
|
|
||||||
|
export const zIPAdapterCollectionInputFieldValue = zInputFieldValueBase.extend({
|
||||||
|
type: z.literal('IPAdapterCollection'),
|
||||||
|
value: z.array(zIPAdapterField).optional(),
|
||||||
|
});
|
||||||
|
export type IPAdapterCollectionInputFieldValue = z.infer<
|
||||||
|
typeof zIPAdapterCollectionInputFieldValue
|
||||||
|
>;
|
||||||
|
|
||||||
export const zT2IAdapterModel = zModelIdentifier;
|
export const zT2IAdapterModel = zModelIdentifier;
|
||||||
export type T2IAdapterModel = z.infer<typeof zT2IAdapterModel>;
|
export type T2IAdapterModel = z.infer<typeof zT2IAdapterModel>;
|
||||||
|
|
||||||
@ -734,6 +754,8 @@ export const zInputFieldValue = z.discriminatedUnion('type', [
|
|||||||
zIntegerInputFieldValue,
|
zIntegerInputFieldValue,
|
||||||
zIPAdapterInputFieldValue,
|
zIPAdapterInputFieldValue,
|
||||||
zIPAdapterModelInputFieldValue,
|
zIPAdapterModelInputFieldValue,
|
||||||
|
zIPAdapterCollectionInputFieldValue,
|
||||||
|
zIPAdapterPolymorphicInputFieldValue,
|
||||||
zLatentsInputFieldValue,
|
zLatentsInputFieldValue,
|
||||||
zLatentsCollectionInputFieldValue,
|
zLatentsCollectionInputFieldValue,
|
||||||
zLatentsPolymorphicInputFieldValue,
|
zLatentsPolymorphicInputFieldValue,
|
||||||
@ -950,6 +972,19 @@ export type IPAdapterInputFieldTemplate = InputFieldTemplateBase & {
|
|||||||
type: 'IPAdapterField';
|
type: 'IPAdapterField';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type IPAdapterCollectionInputFieldTemplate = InputFieldTemplateBase & {
|
||||||
|
default: undefined;
|
||||||
|
type: 'IPAdapterCollection';
|
||||||
|
item_default?: IPAdapterField;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IPAdapterPolymorphicInputFieldTemplate = Omit<
|
||||||
|
IPAdapterInputFieldTemplate,
|
||||||
|
'type'
|
||||||
|
> & {
|
||||||
|
type: 'IPAdapterPolymorphic';
|
||||||
|
};
|
||||||
|
|
||||||
export type T2IAdapterInputFieldTemplate = InputFieldTemplateBase & {
|
export type T2IAdapterInputFieldTemplate = InputFieldTemplateBase & {
|
||||||
default: undefined;
|
default: undefined;
|
||||||
type: 'T2IAdapterField';
|
type: 'T2IAdapterField';
|
||||||
@ -1088,7 +1123,9 @@ export type InputFieldTemplate =
|
|||||||
| IntegerPolymorphicInputFieldTemplate
|
| IntegerPolymorphicInputFieldTemplate
|
||||||
| IntegerInputFieldTemplate
|
| IntegerInputFieldTemplate
|
||||||
| IPAdapterInputFieldTemplate
|
| IPAdapterInputFieldTemplate
|
||||||
|
| IPAdapterCollectionInputFieldTemplate
|
||||||
| IPAdapterModelInputFieldTemplate
|
| IPAdapterModelInputFieldTemplate
|
||||||
|
| IPAdapterPolymorphicInputFieldTemplate
|
||||||
| LatentsInputFieldTemplate
|
| LatentsInputFieldTemplate
|
||||||
| LatentsCollectionInputFieldTemplate
|
| LatentsCollectionInputFieldTemplate
|
||||||
| LatentsPolymorphicInputFieldTemplate
|
| LatentsPolymorphicInputFieldTemplate
|
||||||
|
@ -60,8 +60,11 @@ import {
|
|||||||
ImageField,
|
ImageField,
|
||||||
LatentsField,
|
LatentsField,
|
||||||
ConditioningField,
|
ConditioningField,
|
||||||
|
IPAdapterField,
|
||||||
IPAdapterInputFieldTemplate,
|
IPAdapterInputFieldTemplate,
|
||||||
IPAdapterModelInputFieldTemplate,
|
IPAdapterModelInputFieldTemplate,
|
||||||
|
IPAdapterPolymorphicInputFieldTemplate,
|
||||||
|
IPAdapterCollectionInputFieldTemplate,
|
||||||
T2IAdapterField,
|
T2IAdapterField,
|
||||||
T2IAdapterInputFieldTemplate,
|
T2IAdapterInputFieldTemplate,
|
||||||
T2IAdapterModelInputFieldTemplate,
|
T2IAdapterModelInputFieldTemplate,
|
||||||
@ -709,6 +712,33 @@ const buildIPAdapterInputFieldTemplate = ({
|
|||||||
return template;
|
return template;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const buildIPAdapterPolymorphicInputFieldTemplate = ({
|
||||||
|
schemaObject,
|
||||||
|
baseField,
|
||||||
|
}: BuildInputFieldArg): IPAdapterPolymorphicInputFieldTemplate => {
|
||||||
|
const template: IPAdapterPolymorphicInputFieldTemplate = {
|
||||||
|
...baseField,
|
||||||
|
type: 'IPAdapterPolymorphic',
|
||||||
|
default: schemaObject.default ?? undefined,
|
||||||
|
};
|
||||||
|
|
||||||
|
return template;
|
||||||
|
};
|
||||||
|
|
||||||
|
const buildIPAdapterCollectionInputFieldTemplate = ({
|
||||||
|
schemaObject,
|
||||||
|
baseField,
|
||||||
|
}: BuildInputFieldArg): IPAdapterCollectionInputFieldTemplate => {
|
||||||
|
const template: IPAdapterCollectionInputFieldTemplate = {
|
||||||
|
...baseField,
|
||||||
|
type: 'IPAdapterCollection',
|
||||||
|
default: schemaObject.default ?? [],
|
||||||
|
item_default: (schemaObject.item_default as IPAdapterField) ?? undefined,
|
||||||
|
};
|
||||||
|
|
||||||
|
return template;
|
||||||
|
};
|
||||||
|
|
||||||
const buildT2IAdapterInputFieldTemplate = ({
|
const buildT2IAdapterInputFieldTemplate = ({
|
||||||
schemaObject,
|
schemaObject,
|
||||||
baseField,
|
baseField,
|
||||||
@ -955,8 +985,10 @@ const TEMPLATE_BUILDER_MAP: {
|
|||||||
integer: buildIntegerInputFieldTemplate,
|
integer: buildIntegerInputFieldTemplate,
|
||||||
IntegerCollection: buildIntegerCollectionInputFieldTemplate,
|
IntegerCollection: buildIntegerCollectionInputFieldTemplate,
|
||||||
IntegerPolymorphic: buildIntegerPolymorphicInputFieldTemplate,
|
IntegerPolymorphic: buildIntegerPolymorphicInputFieldTemplate,
|
||||||
|
IPAdapterCollection: buildIPAdapterCollectionInputFieldTemplate,
|
||||||
IPAdapterField: buildIPAdapterInputFieldTemplate,
|
IPAdapterField: buildIPAdapterInputFieldTemplate,
|
||||||
IPAdapterModelField: buildIPAdapterModelInputFieldTemplate,
|
IPAdapterModelField: buildIPAdapterModelInputFieldTemplate,
|
||||||
|
IPAdapterPolymorphic: buildIPAdapterPolymorphicInputFieldTemplate,
|
||||||
LatentsCollection: buildLatentsCollectionInputFieldTemplate,
|
LatentsCollection: buildLatentsCollectionInputFieldTemplate,
|
||||||
LatentsField: buildLatentsInputFieldTemplate,
|
LatentsField: buildLatentsInputFieldTemplate,
|
||||||
LatentsPolymorphic: buildLatentsPolymorphicInputFieldTemplate,
|
LatentsPolymorphic: buildLatentsPolymorphicInputFieldTemplate,
|
||||||
|
@ -31,8 +31,10 @@ const FIELD_VALUE_FALLBACK_MAP: {
|
|||||||
integer: 0,
|
integer: 0,
|
||||||
IntegerCollection: [],
|
IntegerCollection: [],
|
||||||
IntegerPolymorphic: 0,
|
IntegerPolymorphic: 0,
|
||||||
|
IPAdapterCollection: [],
|
||||||
IPAdapterField: undefined,
|
IPAdapterField: undefined,
|
||||||
IPAdapterModelField: undefined,
|
IPAdapterModelField: undefined,
|
||||||
|
IPAdapterPolymorphic: undefined,
|
||||||
LatentsCollection: [],
|
LatentsCollection: [],
|
||||||
LatentsField: undefined,
|
LatentsField: undefined,
|
||||||
LatentsPolymorphic: undefined,
|
LatentsPolymorphic: undefined,
|
||||||
|
@ -2403,7 +2403,7 @@ export type components = {
|
|||||||
* IP-Adapter
|
* IP-Adapter
|
||||||
* @description IP-Adapter to apply
|
* @description IP-Adapter to apply
|
||||||
*/
|
*/
|
||||||
ip_adapter?: components["schemas"]["IPAdapterField"];
|
ip_adapter?: components["schemas"]["IPAdapterField"] | components["schemas"]["IPAdapterField"][];
|
||||||
/**
|
/**
|
||||||
* T2I-Adapter
|
* T2I-Adapter
|
||||||
* @description T2I-Adapter(s) to apply
|
* @description T2I-Adapter(s) to apply
|
||||||
@ -2617,6 +2617,12 @@ export type components = {
|
|||||||
* @enum {string}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
model_name?: "RealESRGAN_x4plus.pth" | "RealESRGAN_x4plus_anime_6B.pth" | "ESRGAN_SRx4_DF2KOST_official-ff704c30.pth" | "RealESRGAN_x2plus.pth";
|
model_name?: "RealESRGAN_x4plus.pth" | "RealESRGAN_x4plus_anime_6B.pth" | "ESRGAN_SRx4_DF2KOST_official-ff704c30.pth" | "RealESRGAN_x2plus.pth";
|
||||||
|
/**
|
||||||
|
* Tile Size
|
||||||
|
* @description Tile size for tiled ESRGAN upscaling (0=tiling disabled)
|
||||||
|
* @default 400
|
||||||
|
*/
|
||||||
|
tile_size?: number;
|
||||||
/**
|
/**
|
||||||
* Type
|
* Type
|
||||||
* @default esrgan
|
* @default esrgan
|
||||||
@ -9684,18 +9690,24 @@ export type components = {
|
|||||||
/** Ui Order */
|
/** Ui Order */
|
||||||
ui_order?: number;
|
ui_order?: number;
|
||||||
};
|
};
|
||||||
/**
|
|
||||||
* StableDiffusion2ModelFormat
|
|
||||||
* @description An enumeration.
|
|
||||||
* @enum {string}
|
|
||||||
*/
|
|
||||||
StableDiffusion2ModelFormat: "checkpoint" | "diffusers";
|
|
||||||
/**
|
/**
|
||||||
* T2IAdapterModelFormat
|
* T2IAdapterModelFormat
|
||||||
* @description An enumeration.
|
* @description An enumeration.
|
||||||
* @enum {string}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
T2IAdapterModelFormat: "diffusers";
|
T2IAdapterModelFormat: "diffusers";
|
||||||
|
/**
|
||||||
|
* ControlNetModelFormat
|
||||||
|
* @description An enumeration.
|
||||||
|
* @enum {string}
|
||||||
|
*/
|
||||||
|
ControlNetModelFormat: "checkpoint" | "diffusers";
|
||||||
|
/**
|
||||||
|
* StableDiffusion1ModelFormat
|
||||||
|
* @description An enumeration.
|
||||||
|
* @enum {string}
|
||||||
|
*/
|
||||||
|
StableDiffusion1ModelFormat: "checkpoint" | "diffusers";
|
||||||
/**
|
/**
|
||||||
* StableDiffusionOnnxModelFormat
|
* StableDiffusionOnnxModelFormat
|
||||||
* @description An enumeration.
|
* @description An enumeration.
|
||||||
@ -9708,30 +9720,24 @@ export type components = {
|
|||||||
* @enum {string}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
CLIPVisionModelFormat: "diffusers";
|
CLIPVisionModelFormat: "diffusers";
|
||||||
/**
|
|
||||||
* ControlNetModelFormat
|
|
||||||
* @description An enumeration.
|
|
||||||
* @enum {string}
|
|
||||||
*/
|
|
||||||
ControlNetModelFormat: "checkpoint" | "diffusers";
|
|
||||||
/**
|
/**
|
||||||
* StableDiffusionXLModelFormat
|
* StableDiffusionXLModelFormat
|
||||||
* @description An enumeration.
|
* @description An enumeration.
|
||||||
* @enum {string}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
StableDiffusionXLModelFormat: "checkpoint" | "diffusers";
|
StableDiffusionXLModelFormat: "checkpoint" | "diffusers";
|
||||||
|
/**
|
||||||
|
* StableDiffusion2ModelFormat
|
||||||
|
* @description An enumeration.
|
||||||
|
* @enum {string}
|
||||||
|
*/
|
||||||
|
StableDiffusion2ModelFormat: "checkpoint" | "diffusers";
|
||||||
/**
|
/**
|
||||||
* IPAdapterModelFormat
|
* IPAdapterModelFormat
|
||||||
* @description An enumeration.
|
* @description An enumeration.
|
||||||
* @enum {string}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
IPAdapterModelFormat: "invokeai";
|
IPAdapterModelFormat: "invokeai";
|
||||||
/**
|
|
||||||
* StableDiffusion1ModelFormat
|
|
||||||
* @description An enumeration.
|
|
||||||
* @enum {string}
|
|
||||||
*/
|
|
||||||
StableDiffusion1ModelFormat: "checkpoint" | "diffusers";
|
|
||||||
};
|
};
|
||||||
responses: never;
|
responses: never;
|
||||||
parameters: never;
|
parameters: never;
|
||||||
|
Reference in New Issue
Block a user