1. 首页
  2. Ai

ComfyUI 安装包文件夹详解,及自定义模型位置

安装目录部分文件作用解析

📁ComfyUI_windows_portable
├── 📁ComfyUI                                          // comfy UI主要文件夹
│  ├── .git                                            // Git版本控制文件夹,代码版本管理用
│  ├── .github                                         // GitHub Actions 工作流文件夹
│  ├── 📁 comfy                                        // 
│  ├── 📁 comfy_extras                                 // 
│  ├── 📁 custom_nodes                                 // comfyUI 自定义节点文件目录(插件安装目录)
│  ├── 📁 input                                        // comfyUI上传文件夹,当你使用了如**load image**节点,对应上传的图片会存储到这个文件夹
│  ├── 📁 models                                       // 对应模型文件配置文件夹
│  |  ├── 📁 checkpoints                               // 检查点大模型文件存放路径
│  |  ├── 📁 clip                                      // CLIP文件存放路径
│  |  ├── 📁 clip_vision                               // CLIP_vision文件存放路径
│  |  ├── 📁 configs                                   
│  |  ├── 📁 controlnet                                // ControlNet 模型存放路径
│  |  ├── 📁 diffusers                                 
│  |  ├── 📁 embedding                                 // embedding 模型存放路径
│  |  ├── 📁 gligen                                
│  |  ├── 📁 hypernetworks                             // 超网络模型
│  |  ├── 📁 loras                                     // Lora 模型存放路径
│  |  ├── 📁 style_models                                
│  |  ├── 📁 unet                               
│  |  ├── 📁 upscale_models                            // upscale_models 放大模型存放路径
│  |  ├── 📁 vae                                       // VAE 模型存放路径
│  |  └── 📁 vae_approx                               
│  ├── 📁 notebooks
│  ├── 📁 user                                         // comfyUI 用户信息(如配置文件,工作流信息等)
│  |    ├── 📁 default                                 // 默认 comfyUI 用户文件夹
│  |    |    ├─ 📁 workflow                            // 用户保存的 workflow 文件
│  |    |    ├─ 📄 xxx.json                            // 用户的配置文件
│  |    |    └── ... xxx.json                          // 其它配置文件
│  |    └── ...[username]                              // 如果你启用了多用户且存在多用户则会显示对应不同用户的名称
│  ├── 📁 output                                       // comfyUI图片输出文件夹,当使用类似 ** save image** 节点时,生成的图片会存储到这个文件夹
│  |    ├── 📁 checkpoints                             // 如果有使用模型合并节点,和保存合并后的模型相关功能,则合并后的模型会输出到这里
│  |    └── ... xxx.png                                // 运行过程中生成的文件会保存到这里
│  ├── extra_model_paths.yaml.example                  //  额外模型文件路径配置文件,如设置此项,请删除**.example** 后缀用记事本进行编辑
│  └── ...                                             // 其它文件
├── config                                             // 配置文件夹
├── 📁 Python_embeded                                  // 嵌入的python 文件
├──📁 update                               
│  ├── update.py                                       // 用于comfyUI的 python 脚本
│  ├── update_comfyUI.bat                              // comfyUI作者推荐使用此批处理命令对 ComfyUI 进行升级
│  └── update_comfyui_and_python_dependencies.bat      // 只有当你的 python 依赖文件存在问题时才需要运行此批处理命令
├── comfyui.log                                        // Comfy UI运行日志文件
├── README_VERY_IMPORTANT.txt                          // README 文件,包含了文件使用的方法和说明等等
├── run_cpu.bat                                        // 批处理文件,当你的显卡为A卡或只有 CPU 时,双击运行它启动 ComfyUI
└── run_nvidia_gpu.bat                                 // 批处理文件,当你的显卡为N卡(Nvidia)时,双击运行它启动 ComfyUI

自定义模型位置

Windows 系统下 查找 ComfyUI 目录下的extra_model_paths.yaml 文件

建议复制一份备份然后对原始文件进行修改

对应原始文件内容示例如下:

# ComfyUI extra_model_paths.yaml for win32
comfyui_desktop:
  is_default: "true"
  checkpoints: models\checkpoints\
  classifiers: models\classifiers\
  clip: models\clip\
  clip_vision: models\clip_vision\
  configs: models\configs\
  controlnet: models\controlnet\
  diffusers: models\diffusers\
  diffusion_models: models\diffusion_models\
  embeddings: models\embeddings\
  gligen: models\gligen\
  hypernetworks: models\hypernetworks\
  loras: models\loras\
  photomaker: models\photomaker\
  style_models: models\style_models\
  unet: models\unet\
  upscale_models: models\upscale_models\
  vae: models\vae\
  vae_approx: models\vae_approx\
  animatediff_models: models\animatediff_models\
  animatediff_motion_lora: models\animatediff_motion_lora\
  animatediff_video_formats: models\animatediff_video_formats\
  ipadapter: models\ipadapter\
  liveportrait: models\liveportrait\
  insightface: models\insightface\
  layerstyle: models\layerstyle\
  LLM: models\LLM\
  Joy_caption: models\Joy_caption\
  sams: models\sams\
  blip: models\blip\
  CogVideo: models\CogVideo\
  xlabs: models\xlabs\
  instantid: models\instantid\
  custom_nodes: custom_nodes/
  download_model_base: models
  base_path: D:\ComfyUI

如何修改配置

下面是对于 yaml 文件的配置说明:

模型类型

配置键名 (必须,不能修改)

默认相对路径(可以修改)

是否默认配置 (只能有一个)

is_default

true/false

Checkpoint 模型

checkpoints

models/checkpoints/

LoRA 模型

loras

models/loras/

VAE 模型

vae

models/vae/

控制网络

controlnet

models/controlnet/

文本编码器

clip

models/clip/

图像编码器

clip_vision

models/clip_vision/

放大模型

upscale_models

models/upscale_models/

嵌入模型

embeddings

models/embeddings/

超网络

hypernetworks

models/hypernetworks/

风格模型

style_models

models/style_models/

照片制作器

photomaker

models/photomaker/

IP适配器

ipadapter

models/ipadapter/

动画模型

animatediff_models

models/animatediff_models/

动画LoRA

animatediff_motion_lora

models/animatediff_motion_lora/

分类器

classifiers

models/classifiers/

生成模型

diffusers

models/diffusers/

自定义节点

custom_nodes

custom_nodes/

下载模型基础

download_model_base

models/

基础路径(必须)

base_path

D:/ComfyUI

💡 请注意,对应的表格只是说明可能的模型类型保存文件夹位置,并不是所有的模型文件都要按这个表格的位置来进行保存,对于模型保存位置,你需要参考对应具体的教程或者自定义节点的说明。 因为不同自定义节点的作者可能会偏好使用不同的模型存放位置!

如果下面是我提供的自定义的模型配置文件示例

comfyui_desktop:
  is_default: "true"
  checkpoints: models\checkpoints\
  classifiers: models\classifiers\
  clip: models\clip\
  clip_vision: models\clip_vision\
  configs: models\configs\
  controlnet: models\controlnet\
  diffusers: models\diffusers\
  diffusion_models: models\diffusion_models\
  embeddings: models\embeddings\
  gligen: models\gligen\
  hypernetworks: models\hypernetworks\
  loras: models\loras\
  photomaker: models\photomaker\
  style_models: models\style_models\
  unet: models\unet\
  upscale_models: models\upscale_models\
  vae: models\vae\
  vae_approx: models\vae_approx\
  animatediff_models: models\animatediff_models\
  animatediff_motion_lora: models\animatediff_motion_lora\
  animatediff_video_formats: models\animatediff_video_formats\
  ipadapter: models\ipadapter\
  liveportrait: models\liveportrait\
  insightface: models\insightface\
  layerstyle: models\layerstyle\
  LLM: models\LLM\
  Joy_caption: models\Joy_caption\
  sams: models\sams\
  blip: models\blip\
  CogVideo: models\CogVideo\
  xlabs: models\xlabs\
  instantid: models\instantid\
  custom_nodes: custom_nodes/
  download_model_base: models
  base_path: D:\ComfyUI
 
custom_models:
  base_path: E:\
  checkpoints: models\checkpoints\
  classifiers: models\classifiers\
  clip: models\clip\
  # ... 其他模型路径 ...
a1111:
  base_path: D:\stable-diffusion-webui
  checkpoints: models/Stable-diffusion
  # ... 其他模型路径 ...
  • base_path 这个是在每个配置里面都是有新增自定义的

  • 每个配置节点的名称你可以自定义比如custom_models 或者a1111 等等,但是不能重复,否则会报错

  • is_default 这个是用来指定这个配置文件是否是默认的配置文件,只能有一个,如果设置为true,那么这个配置文件就会成为默认的配置文件,否则就会成为非默认的配置文件

  • 键名需要与原始的配置文件一致,文件夹为你实际的文件夹

  • 请注意custom_nodes 这个文件夹是用来存放自定义的插件的路径的这是在原本Portable 便携版中没有的,在桌面版中是有的,最好保持默认

ComfyUI Portable 便携版如何配置与 A1111 共享绘图模型

在对应ComfyUI Portable的安装目录里都可以找到extra_model_paths.yaml.example 这个文件,路径如下

ComfyUI_windows_portable
├──ComfyUI
│  ├── extra_model_paths.yaml.example   // 此文件为配置文件                                    
│  └──    ...省略其它文件
└──       ...省略其它文件

找到以上文件后修改文件名extra_model_paths.yaml.exampleextra_model_paths.yaml,然后用记事本软件进行编辑

对应原始文件内容如下:

#Rename this to extra_model_paths.yaml and ComfyUI will load it
 
 
#config for a1111 ui
#all you have to do is change the base_path to where yours is installed
a111:
    base_path: path/to/stable-diffusion-webui/
 
    checkpoints: models/Stable-diffusion
    configs: models/Stable-diffusion
    vae: models/VAE
    loras: |
         models/Lora
         models/LyCORIS
    upscale_models: |
                  models/ESRGAN
                  models/RealESRGAN
                  models/SwinIR
    embeddings: embeddings
    hypernetworks: models/hypernetworks
    controlnet: models/ControlNet
 
#config for comfyui
#your base path should be either an existing comfy install or a central folder where you store all of your models, loras, etc.
 
#comfyui:
#     base_path: path/to/comfyui/
#     checkpoints: models/checkpoints/
#     clip: models/clip/
#     clip_vision: models/clip_vision/
#     configs: models/configs/
#     controlnet: models/controlnet/
#     embeddings: models/embeddings/
#     loras: models/loras/
#     upscale_models: models/upscale_models/
#     vae: models/vae/
 
#other_ui:
#    base_path: path/to/ui
#    checkpoints: models/checkpoints
#    gligen: models/gligen
#    custom_nodes: path/custom_nodes

你可以看到在a111:的设置部分有 base_path: 用来指定 WebUI 根目录所在路径,你可以把此处修改为你的 WebUI 或者自定义的模型文件夹位置所在的路径,记得在: 后需要有一个空格,修改完成后保存对应文件,重启ComfyUI即可。

  • 你需要确保在base_path:路径之下的文件路径是正确的

  • 注意在不同系统比如Mac 或者 Linux 系统下,路径的格式可能有所不同

  • 如果假设WebUI安装路径为D:\stable-diffusion-webui\vae 在上方配置文件设置下对应路径vae 模型文件路径最终会是应该为D:\stable-diffusion-webui\models\VAE,请检查对应文件夹其它类似checkpointsloras,也请检查对应的配置。

如果你重启以后发现你的checkpoints或者 VAE等没有顺利加载,请检查你的配置是否正确。

对于其它UI 你也可以参考上方配置文件进行修改,比如other_ui:等,你可以取消代码前的#注释来增加对应UI的设置,然后修改base_path:和对应各类绘图模型的路径即可


TOP