> ## Documentation Index
> Fetch the complete documentation index at: https://dripart-train-lora-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 模型

{/*
description: "了解AI模型及其在ComfyUI中的作用"
*/}

## 模型是必不可少的

模型是媒体生成工作流程的基本构建块。它们可以组合和混合以实现不同的创意效果。

***模型*** 这个词有许多不同的含义。在这里，它指的是一个数据文件，携带节点图执行其工作所需的信息。具体来说，它是一个数据结构，*模型* 某种功能。作为动词，建模某物意味着表示它或提供一个示例。

在ComfyUI中，模型数据文件的主要示例是AI ***扩散模型***。这是一组大型数据，表示文本字符串和图像之间复杂的关系，使得将单词翻译成图片或反之成为可能。其他用于图像生成的常见模型示例包括语言模型，如CLIP，以及图像放大模型，如RealESRGAN。

## 模型文件

模型文件对于生成媒体制作是绝对必要的。如果找不到模型文件，工作流程中将无法进行任何操作。模型不包含在ComfyUI安装中，但ComfyUI通常可以自动下载和安装缺失的模型文件。许多模型可以从**ComfyUI管理器**窗口下载和安装。模型也可以在以下网站找到：[huggingface.co](https://huggingface.co)、[civitai.green](https://civitai.green)和[github.com](https://github.com)。

### 在ComfyUI中使用模型

1. 下载并将其放置在ComfyUI程序目录中
   1. 在**models**文件夹中，您会找到各种类型模型的子文件夹，例如**checkpoints**
   2. **ComfyUI管理器**帮助自动化搜索、下载和安装的过程
   3. 如果ComfyUI正在运行，请重启它
2. 在您的工作流程中，创建适合模型类型的节点，例如**Load Checkpoints**、**Load LoRA**、**Load VAE**
3. 在加载节点中，选择您希望使用的模型
4. 将加载节点连接到工作流程中的其他节点

### Adding External Model Paths

If you downloaded a model but ComfyUI cannot find it, you may need to add an additional model search path to the yaml file.

#### Example scenario

You need to add a motion LoRA and your model is located in `C:\Users\YourUsername\models\animatediff_motion_lora`.

#### Solution

1. Add the below configuration to the `extra_model_paths.yaml` file using the correct model type property name
2. Restart ComfyUI

```yaml
my_custom_config:
  loras: C:\Users\YourUsername\models\animatediff_motion_lora/
```

**Important:** Use the correct property names for different model types:

* `loras` - for LoRA models
* `checkpoints` - for checkpoint models
* `vae` - for VAE models
* `controlnet` - for ControlNet models
* `clip` - for CLIP models
* `upscale_models` - for upscaling models
* `embeddings` - for textual inversion embeddings
* `configs` - for configuration files

For example, to add checkpoint models:

```yaml
my_custom_config:
  checkpoints: C:\Users\YourUsername\models\checkpoints/
```

#### YAML config file location

For standard ComfyUI installations, create the `extra_model_paths.yaml` file directly in your ComfyUI folder (where `main.py` is located).

#### Desktop Application Instructions

If you're using the ComfyUI Desktop application, the config file has a different name and location:

* On Windows: `C:\Users\YourUsername\AppData\Roaming\ComfyUI\extra_models_config.yaml`
  * You can quickly navigate to this by typing `%APPDATA%\ComfyUI` in File Explorer address bar
* On macOS: `~/Library/Application Support/ComfyUI/extra_models_config.yaml`
  * Open Finder, press `Cmd+Shift+G` and enter `~/Library/Application Support/ComfyUI`
* On Linux: `~/.config/ComfyUI/extra_models_config.yaml`
  * Open your file manager and navigate to the hidden folder `~/.config/ComfyUI`

If the file doesn't exist yet, you can create it yourself with any text editor.

### 文件大小

相对于图像文件，模型文件可能非常大。一个典型的未压缩图像可能需要几兆字节的磁盘存储。生成的AI模型可能大到数万倍，单个模型可达数十吉字节。它们占用大量磁盘空间，并且在网络上传输需要很长时间。

## 模型训练和优化

生成AI模型是通过在非常大的数据集上训练机器学习程序创建的，例如图像和文本描述的配对。AI模型并不明确存储训练数据，而是存储数据中隐含的相关性。

像Stability AI和Black Forest Labs这样的组织和公司发布“基础”模型，这些模型携带大量通用信息。这些是通用的生成AI模型。通常，基础模型需要进行***优化***，以获得高质量的生成输出。一个专门的社区致力于优化基础模型。新的优化模型产生更好的输出，提供新的或不同的功能，并/或使用更少的资源。优化后的模型通常可以在计算能力和/或内存较少的系统上运行。

## 辅助模型

模型功能可以通过辅助模型进行扩展。例如，艺术指导文本到图像的工作流程以实现特定结果，单靠扩散模型可能会很困难或不可能。额外的模型可以在工作流程图中优化扩散模型，以产生所需的结果。示例包括**LoRA**（低秩适应），一个针对特定主题训练的小模型；**ControlNet**，一个使用引导图像帮助控制构图的模型；以及**Inpainting**，一个允许某些扩散模型在现有图像中生成新内容的模型。

![辅助模型](https://mintlify.s3.us-west-1.amazonaws.com/dripart-train-lora-docs/images/concepts/core-concepts_auxiliary-model.png)
