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.

10.3 KB
Raw Blame
import type { AnyModelVariant, BaseModelType, ModelFormat, ModelType } from 'features/nodes/types/common';
import {
  type AnyModelConfig,
  isAnimaQwen3EncoderModelConfig,
  isCLIPEmbedModelConfig,
  isCLIPVisionModelConfig,
  isControlLoRAModelConfig,
  isControlNetModelConfig,
  isExternalApiModelConfig,
  isFluxReduxModelConfig,
  isGemma2EncoderModelConfig,
  isGemma4EncoderModelConfig,
  isIPAdapterModelConfig,
  isLLaVAModelConfig,
  isLoRAModelConfig,
  isLTX2DurationHeadModelConfig,
  isMistralEncoderModelConfig,
  isNonRefinerMainModelConfig,
  isPiDDecoderModelConfig,
  isQwen3EncoderModelConfig,
  isQwen3VLEncoderModelConfig,
  isQwenVLEncoderModelConfig,
  isRefinerMainModelModelConfig,
  isSigLipModelConfig,
  isSpandrelImageToImageModelConfig,
  isT2IAdapterModelConfig,
  isT5EncoderModelConfig,
  isTextLLMModelConfig,
  isTIModelConfig,
  isUnknownModelConfig,
  isVAEModelConfig,
  isWanT5EncoderModelConfig,
} from 'services/api/types';
import { objectEntries } from 'tsafe';

import type { ModelCategoryType } from './store/modelManagerV2Slice';

export type ModelCategoryData = {
  category: ModelCategoryType;
  i18nKey: string;
  filter: (config: AnyModelConfig) => boolean;
};

const MODEL_CATEGORIES: Record<ModelCategoryType, ModelCategoryData> = {
  unknown: {
    category: 'unknown',
    i18nKey: 'common.unknown',
    filter: isUnknownModelConfig,
  },
  main: {
    category: 'main',
    i18nKey: 'modelManager.main',
    filter: isNonRefinerMainModelConfig,
  },
  refiner: {
    category: 'refiner',
    i18nKey: 'sdxl.refiner',
    filter: isRefinerMainModelModelConfig,
  },
  lora: {
    category: 'lora',
    i18nKey: 'modelManager.loraModels',
    filter: isLoRAModelConfig,
  },
  embedding: {
    category: 'embedding',
    i18nKey: 'modelManager.textualInversions',
    filter: isTIModelConfig,
  },
  controlnet: {
    category: 'controlnet',
    i18nKey: 'ControlNet',
    filter: isControlNetModelConfig,
  },
  t2i_adapter: {
    category: 't2i_adapter',
    i18nKey: 'common.t2iAdapter',
    filter: isT2IAdapterModelConfig,
  },
  t5_encoder: {
    category: 't5_encoder',
    i18nKey: 'modelManager.t5Encoder',
    filter: isT5EncoderModelConfig,
  },
  qwen3_encoder: {
    category: 'qwen3_encoder',
    i18nKey: 'modelManager.qwen3Encoder',
    filter: (config) => isQwen3EncoderModelConfig(config) || isAnimaQwen3EncoderModelConfig(config),
  },
  qwen_vl_encoder: {
    category: 'qwen_vl_encoder',
    i18nKey: 'modelManager.qwenVLEncoder',
    filter: isQwenVLEncoderModelConfig,
  },
  mistral_encoder: {
    category: 'mistral_encoder',
    i18nKey: 'modelManager.mistralEncoder',
    filter: isMistralEncoderModelConfig,
  },
  qwen3_vl_encoder: {
    category: 'qwen3_vl_encoder',
    i18nKey: 'modelManager.qwen3VLEncoder',
    filter: isQwen3VLEncoderModelConfig,
  },
  wan_t5_encoder: {
    category: 'wan_t5_encoder',
    i18nKey: 'modelManager.wanT5Encoder',
    filter: isWanT5EncoderModelConfig,
  },
  gemma2_encoder: {
    category: 'gemma2_encoder',
    i18nKey: 'modelManager.gemma2Encoder',
    filter: isGemma2EncoderModelConfig,
  },
  gemma4_encoder: {
    category: 'gemma4_encoder',
    i18nKey: 'modelManager.gemma4Encoder',
    filter: isGemma4EncoderModelConfig,
  },
  pid_decoder: {
    category: 'pid_decoder',
    i18nKey: 'modelManager.pidDecoder',
    filter: isPiDDecoderModelConfig,
  },
  ltx2_duration_head: {
    category: 'ltx2_duration_head',
    i18nKey: 'modelManager.ltx2DurationHead',
    filter: isLTX2DurationHeadModelConfig,
  },
  control_lora: {
    category: 'control_lora',
    i18nKey: 'modelManager.controlLora',
    filter: isControlLoRAModelConfig,
  },
  clip_embed: {
    category: 'clip_embed',
    i18nKey: 'modelManager.clipEmbed',
    filter: isCLIPEmbedModelConfig,
  },
  spandrel_image_to_image: {
    category: 'spandrel_image_to_image',
    i18nKey: 'modelManager.spandrelImageToImage',
    filter: isSpandrelImageToImageModelConfig,
  },
  ip_adapter: {
    category: 'ip_adapter',
    i18nKey: 'common.ipAdapter',
    filter: isIPAdapterModelConfig,
  },
  vae: {
    category: 'vae',
    i18nKey: 'VAE',
    filter: isVAEModelConfig,
  },
  clip_vision: {
    category: 'clip_vision',
    i18nKey: 'CLIP Vision',
    filter: isCLIPVisionModelConfig,
  },
  siglip: {
    category: 'siglip',
    i18nKey: 'modelManager.sigLip',
    filter: isSigLipModelConfig,
  },
  flux_redux: {
    category: 'flux_redux',
    i18nKey: 'modelManager.fluxRedux',
    filter: isFluxReduxModelConfig,
  },
  llava_onevision: {
    category: 'llava_onevision',
    i18nKey: 'modelManager.llavaOnevision',
    filter: isLLaVAModelConfig,
  },
  text_llm: {
    category: 'text_llm',
    i18nKey: 'modelManager.textLLM',
    filter: isTextLLMModelConfig,
  },
  external_image_generator: {
    category: 'external_image_generator',
    i18nKey: 'modelManager.externalImageGenerator',
    filter: isExternalApiModelConfig,
  },
};

export const MODEL_CATEGORIES_AS_LIST = objectEntries(MODEL_CATEGORIES).map(([category, { i18nKey, filter }]) => ({
  category,
  i18nKey,
  filter,
}));

/**
 * Mapping of model base to its color
 */
export const MODEL_BASE_TO_COLOR: Record<BaseModelType, string> = {
  any: 'base',
  'sd-1': 'green',
  'sd-2': 'teal',
  'sd-3': 'purple',
  sdxl: 'invokeBlue',
  'sdxl-refiner': 'invokeBlue',
  flux: 'gold',
  flux2: 'gold',
  cogview4: 'red',
  'qwen-image': 'orange',
  'z-image': 'cyan',
  'ernie-image': 'pink',
  'krea-2': 'pink',
  'ideogram-4': 'pink',
  'qwen-image-2-1': 'orange',
  external: 'orange',
  anima: 'invokePurple',
  wan: 'cyan',
  'minimax-h3': 'yellow',
  'ltx-2': 'teal',
  unknown: 'red',
};

/**
 * Mapping of model type to human readable name
 */
export const MODEL_TYPE_TO_LONG_NAME: Record<ModelType, string> = {
  main: 'Main',
  vae: 'VAE',
  lora: 'LoRA',
  llava_onevision: 'LLaVA OneVision',
  control_lora: 'ControlLoRA',
  controlnet: 'ControlNet',
  t2i_adapter: 'T2I Adapter',
  ip_adapter: 'IP Adapter',
  embedding: 'Embedding',
  onnx: 'ONNX',
  clip_vision: 'CLIP Vision',
  spandrel_image_to_image: 'Spandrel (Image to Image)',
  t5_encoder: 'T5 Encoder',
  qwen3_encoder: 'Qwen3 Encoder',
  qwen_vl_encoder: 'Qwen2.5-VL Encoder',
  mistral_encoder: 'Mistral Encoder',
  qwen3_vl_encoder: 'Qwen3-VL Encoder',
  wan_t5_encoder: 'Wan T5 Encoder',
  gemma2_encoder: 'Gemma-2 Encoder',
  gemma4_encoder: 'Gemma-4 Encoder',
  clip_embed: 'CLIP Embed',
  siglip: 'SigLIP',
  flux_redux: 'FLUX Redux',
  prompt_enhancer: 'Prompt Enhancer',
  text_llm: 'Text LLM',
  external_image_generator: 'External Image Generator',
  pid_decoder: 'PiD Decoder',
  ltx2_duration_head: 'LTX-2 Duration Head',
  unknown: 'Unknown',
};

/**
 * Mapping of model base to human readable name
 */
export const MODEL_BASE_TO_LONG_NAME: Record<BaseModelType, string> = {
  any: 'Any',
  'sd-1': 'Stable Diffusion 1.x',
  'sd-2': 'Stable Diffusion 2.x',
  'sd-3': 'Stable Diffusion 3.x',
  sdxl: 'Stable Diffusion XL',
  'sdxl-refiner': 'Stable Diffusion XL Refiner',
  flux: 'FLUX',
  flux2: 'FLUX.2',
  cogview4: 'CogView4',
  'qwen-image': 'Qwen Image',
  'z-image': 'Z-Image',
  'ernie-image': 'ERNIE-Image',
  'krea-2': 'Krea-2',
  'ideogram-4': 'Ideogram 4',
  'qwen-image-2-1': 'Qwen-Image-2.1',
  external: 'External',
  anima: 'Anima',
  wan: 'Wan 2.2',
  'minimax-h3': 'MiniMax H3',
  'ltx-2': 'LTX-2',
  unknown: 'Unknown',
};

/**
 * Mapping of model base to short human readable name
 */
export const MODEL_BASE_TO_SHORT_NAME: Record<BaseModelType, string> = {
  any: 'Any',
  'sd-1': 'SD1.X',
  'sd-2': 'SD2.X',
  'sd-3': 'SD3.X',
  sdxl: 'SDXL',
  'sdxl-refiner': 'SDXLR',
  flux: 'FLUX',
  flux2: 'FLUX.2',
  cogview4: 'CogView4',
  'qwen-image': 'QwenImg',
  'z-image': 'Z-Image',
  'ernie-image': 'ERNIE-Image',
  'krea-2': 'Krea-2',
  'ideogram-4': 'Ideogram4',
  'qwen-image-2-1': 'QwenImg2.1',
  external: 'External',
  anima: 'Anima',
  wan: 'Wan',
  'minimax-h3': 'MiniMax H3',
  'ltx-2': 'LTX-2',
  unknown: 'Unknown',
};

export const MODEL_VARIANT_TO_LONG_NAME: Record<AnyModelVariant, string> = {
  normal: 'Normal',
  inpaint: 'Inpaint',
  depth: 'Depth',
  dev: 'FLUX Dev',
  dev_fill: 'FLUX Dev - Fill',
  schnell: 'FLUX Schnell',
  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',
  turbo: 'Z-Image Turbo',
  zbase: 'Z-Image Base',
  krea2_turbo: 'Krea-2 Turbo',
  krea2_base: 'Krea-2 Raw',
  large: 'CLIP L',
  gigantic: 'CLIP G',
  generate: 'Qwen Image',
  edit: 'Qwen Image Edit',
  qwen_image_21_base: 'Qwen-Image-2.1 Base',
  qwen_image_21_turbo: 'Qwen-Image-2.1 Turbo',
  fl2va: 'MiniMax H3 FL2VA',
  ref2va: 'MiniMax H3 Ref2VA',
  ltx2_dev: 'LTX-2 Dev',
  ltx2_distilled: 'LTX-2 Distilled',
  t2v_a14b: 'Wan 2.2 T2V A14B',
  i2v_a14b: 'Wan 2.2 I2V A14B',
  ti2v_5b: 'Wan 2.2 TI2V 5B',
  a14b: 'Wan 2.2 A14B LoRA',
  '5b': 'Wan 2.2 5B LoRA',
  qwen3_4b: 'Qwen3 4B',
  qwen3_8b: 'Qwen3 8B',
  qwen3_06b: 'Qwen3 0.6B',
  qwen3_vl_4b: 'Qwen3-VL 4B (Krea-2)',
  qwen3_vl_8b: 'Qwen3-VL 8B (Ideogram 4)',
  cow_mistral3_small: 'cow-mistral3-small (FLUX.2)',
  ministral3_3b: 'Ministral 3B (ERNIE-Image)',
  mistral3_24b: 'Mistral Small 3 (24B, FLUX.2)',
  res2k_sr4x: 'PiD 2K (4x SR)',
  res2kto4k_sr4x: 'PiD 4K (4x SR Upscale)',
};

export const MODEL_FORMAT_TO_LONG_NAME: Record<ModelFormat, string> = {
  omi: 'OMI',
  diffusers: 'Diffusers',
  checkpoint: 'Checkpoint',
  lycoris: 'LyCORIS',
  onnx: 'ONNX',
  external_api: 'External API',
  olive: 'Olive',
  embedding_file: 'Embedding (file)',
  embedding_folder: 'Embedding (folder)',
  invokeai: 'InvokeAI',
  t5_encoder: 'T5 Encoder',
  qwen3_encoder: 'Qwen3 Encoder',
  qwen_vl_encoder: 'Qwen2.5-VL Encoder',
  mistral_encoder: 'Mistral Encoder',
  qwen3_vl_encoder: 'Qwen3-VL Encoder',
  wan_t5_encoder: 'Wan T5 Encoder (UMT5-XXL)',
  gemma2_encoder: 'Gemma-2 Encoder',
  gemma4_encoder: 'Gemma-4 Encoder',
  bnb_quantized_int8b: 'BNB Quantized (int8b)',
  bnb_quantized_nf4b: 'BNB Quantized (nf4b)',
  gguf_quantized: 'GGUF Quantized',
  sdnq_quantized: 'SDNQ Quantized',
  unknown: 'Unknown',
};

export const SUPPORTS_OPTIMIZED_DENOISING_BASE_MODELS: BaseModelType[] = ['flux', 'sd-3'];

export const SUPPORTS_REF_IMAGES_BASE_MODELS: BaseModelType[] = [
  'sd-1',
  'sdxl',
  'flux',
  'flux2',
  'qwen-image',
  'wan',
  'minimax-h3',
  'krea-2',
];

export const SUPPORTS_NEGATIVE_PROMPT_BASE_MODELS: BaseModelType[] = [
  'sd-1',
  'sd-2',
  'sdxl',
  'cogview4',
  'qwen-image',
  'sd-3',
  'z-image',
  'anima',
  'krea-2',
  'wan',
];