stable-diffusion 3 体验部署流程(ComfyUI)

环境准备

下载及简介

git clone https://huggingface.co/stabilityai/stable-diffusion-3-medium
SD3 checkpoints:

  1. sd3_medium_incl_clips.safetensors (5.5GB)
  2. sd3_medium_incl_clips_t5xxlfp8.safetensors (10.1GB)
  3. sd3_medium.safetensors (4.3GB)

前两个可以像 ComfyUI 中的任何常规checkpoints一样使用。这两个checkpoints之间的区别在于,第一个仅包含 2 个文本编码器:CLIP-L 和 CLIP-G,第二个包含 3 个:CLIP-L、CLIP-G 和 T5XXL。第三个模型不包含文本编码器,必须单独加载它们才能使用该文件。

模型保存

把如下三个模型放在 ComfyUI/models/checkpoints/ 目录中(可以选择其中一个模型体验)

  • sd3_medium_incl_clips.safetensors
  • sd3_medium_incl_clips_t5xxlfp8.safetensors
  • sd3_medium.safetensors
文本编码器保存

从text_encoders目录下载文本编码器,选择其中的一个文件保存到ComfyUI/models/clip/目录中:

  • clip_g.safetensors
  • clip_l.safetensors
  • t5xxl_fp8_e4m3fn.safetensors
  • t5xxl_fp16.safetensors

ComfyUI 测试体验

打开comfyui 界面 导入脚本并执行:

{
  "last_node_id": 272,
  "last_link_id": 599,
  "nodes": [
    {
      "id": 11,
      "type": "TripleCLIPLoader",
      "pos": [
        -1885,
        -49
      ],
      "size": {
        "0": 315,
        "1": 106
      },
      "flags": {},
      "order": 0,
      "mode": 0,
      "outputs": [
        {
          "name": "CLIP",
          "type": "CLIP",
          "links": [
            5,
            94
          ],
          "shape": 3,
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "TripleCLIPLoader"
      },
      "widgets_values": [
        "clip_g.safetensors",
        "clip_l.safetensors",
        "t5xxl_fp8_e4m3fn.safetensors"
      ]
    },
    {
      "id": 71,
      "type": "CLIPTextEncode",
      "pos": [
        -1869.2871546875003,
        560.071803930664
      ],
      "size": {
        "0": 380.4615783691406,
        "1": 102.07693481445312
      },
      "flags": {},
      "order": 6,
      "mode": 0,
      "inputs": [
        {
          "name": "clip",
          "type": "CLIP",
          "link": 94
        }
      ],
      "outputs": [
        {
          "name": "CONDITIONING",
          "type": "CONDITIONING",
          "links": [
            93,
            580
          ],
          "shape": 3,
          "slot_index": 0
        }
      ],
      "title": "CLIP Text Encode (Negative Prompt)",
      "properties": {
        "Node name for S&R": "CLIPTextEncode"
      },
      "widgets_values": [
        "bad quality, poor quality, doll, disfigured, jpg, toy, bad anatomy, missing limbs, missing fingers, 3d, cgi"
      ],
      "color": "#322",
      "bgcolor": "#533"
    },
    {
      "id": 68,
      "type": "ConditioningSetTimestepRange",
      "pos": [
        -1010,
        167
      ],
      "size": {
        "0": 317.4000244140625,
        "1": 82
      },
      "flags": {},
      "order": 10,
      "mode": 0,
      "inputs": [
        {
          "name": "conditioning",
          "type": "CONDITIONING",
          "link": 90
        }
      ],
      "outputs": [
        {
          "name": "CONDITIONING",
          "type": "CONDITIONING",
          "links": [
            91
          ],
          "shape": 3,
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "ConditioningSetTimestepRange"
      },
      "widgets_values": [
        0.1,
        1
      ]
    },
    {
      "id": 70,
      "type": "ConditioningSetTimestepRange",
      "pos": [
        -1006,
        314
      ],
      "size": {
        "0": 317.4000244140625,
        "1": 82
      },
      "flags": {},
      "order": 8,
      "mode": 0,
      "inputs": [
        {
          "name": "conditioning",
          "type": "CONDITIONING",
          "link": 93,
          "slot_index": 0
        }
      ],
      "outputs": [
        {
          "name": "CONDITIONING",
          "type": "CONDITIONING",
          "links": [
            92
          ],
          "shape": 3,
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "ConditioningSetTimestepRange"
      },
      "widgets_values": [
        0,
        0.1
      ]
    },
    {
      "id": 67,
      "type": "ConditioningZeroOut",
      "pos": [
        -1370,
        337
      ],
      "size": {
        "0": 211.60000610351562,
        "1": 26
      },
      "flags": {},
      "order": 9,
      "mode": 0,
      "inputs": [
        {
          "name": "conditioning",
          "type": "CONDITIONING",
          "link": 580
        }
      ],
      "outputs": [
        {
          "name": "CONDITIONING",
          "type": "CONDITIONING",
          "links": [
            90
          ],
          "shape": 3,
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "ConditioningZeroOut"
      }
    },
    {
      "id": 266,
      "type": "Note",
      "pos": [
        -2352,
        576
      ],
      "size": {
        "0": 308.061279296875,
        "1": 102.86902618408203
      },
      "flags": {},
      "order": 1,
      "mode": 0,
      "properties": {
        "text": ""
      },
      "widgets_values": [
        "Resolution should be around 1 megapixel and width/height must be multiple of 64"
      ],
      "color": "#432",
      "bgcolor": "#653"
    },
    {
      "id": 13,
      "type": "ModelSamplingSD3",
      "pos": [
        -974,
        -220
      ],
      "size": {
        "0": 315,
        "1": 58
      },
      "flags": {
        "collapsed": false
      },
      "order": 7,
      "mode": 0,
      "inputs": [
        {
          "name": "model",
          "type": "MODEL",
          "link": 565
        }
      ],
      "outputs": [
        {
          "name": "MODEL",
          "type": "MODEL",
          "links": [
            591
          ],
          "shape": 3,
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "ModelSamplingSD3"
      },
      "widgets_values": [
        3
      ]
    },
    {
      "id": 69,
      "type": "ConditioningCombine",
      "pos": [
        -662,
        165
      ],
      "size": {
        "0": 228.39999389648438,
        "1": 46
      },
      "flags": {},
      "order": 11,
      "mode": 0,
      "inputs": [
        {
          "name": "conditioning_1",
          "type": "CONDITIONING",
          "link": 91
        },
        {
          "name": "conditioning_2",
          "type": "CONDITIONING",
          "link": 92
        }
      ],
      "outputs": [
        {
          "name": "CONDITIONING",
          "type": "CONDITIONING",
          "links": [
            592
          ],
          "shape": 3,
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "ConditioningCombine"
      }
    },
    {
      "id": 233,
      "type": "PreviewImage",
      "pos": [
        535.1143750722272,
        -147.92548481673106
      ],
      "size": {
        "0": 604.7489624023438,
        "1": 592.15576171875
      },
      "flags": {},
      "order": 14,
      "mode": 0,
      "inputs": [
        {
          "name": "images",
          "type": "IMAGE",
          "link": 599
        }
      ],
      "properties": {
        "Node name for S&R": "PreviewImage"
      }
    },
    {
      "id": 231,
      "type": "VAEDecode",
      "pos": [
        141,
        -177
      ],
      "size": {
        "0": 210,
        "1": 46
      },
      "flags": {},
      "order": 13,
      "mode": 0,
      "inputs": [
        {
          "name": "samples",
          "type": "LATENT",
          "link": 596
        },
        {
          "name": "vae",
          "type": "VAE",
          "link": 557
        }
      ],
      "outputs": [
        {
          "name": "IMAGE",
          "type": "IMAGE",
          "links": [
            599
          ],
          "shape": 3,
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "VAEDecode"
      }
    },
    {
      "id": 252,
      "type": "CheckpointLoaderSimple",
      "pos": [
        -2314,
        -203
      ],
      "size": {
        "0": 746.7357788085938,
        "1": 98
      },
      "flags": {},
      "order": 2,
      "mode": 0,
      "outputs": [
        {
          "name": "MODEL",
          "type": "MODEL",
          "links": [
            565
          ],
          "shape": 3,
          "slot_index": 0
        },
        {
          "name": "CLIP",
          "type": "CLIP",
          "links": [],
          "shape": 3,
          "slot_index": 1
        },
        {
          "name": "VAE",
          "type": "VAE",
          "links": [
            557
          ],
          "shape": 3,
          "slot_index": 2
        }
      ],
      "properties": {
        "Node name for S&R": "CheckpointLoaderSimple"
      },
      "widgets_values": [
        "sdv3/2b_1024/sd3_medium.safetensors"
      ]
    },
    {
      "id": 271,
      "type": "KSampler",
      "pos": [
        -269,
        -179
      ],
      "size": {
        "0": 315,
        "1": 446
      },
      "flags": {},
      "order": 12,
      "mode": 0,
      "inputs": [
        {
          "name": "model",
          "type": "MODEL",
          "link": 591
        },
        {
          "name": "positive",
          "type": "CONDITIONING",
          "link": 595
        },
        {
          "name": "negative",
          "type": "CONDITIONING",
          "link": 592
        },
        {
          "name": "latent_image",
          "type": "LATENT",
          "link": 593
        },
        {
          "name": "seed",
          "type": "INT",
          "link": 597,
          "widget": {
            "name": "seed"
          },
          "slot_index": 4
        }
      ],
      "outputs": [
        {
          "name": "LATENT",
          "type": "LATENT",
          "links": [
            596
          ],
          "shape": 3,
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "KSampler"
      },
      "widgets_values": [
        945512652412924,
        "fixed",
        28,
        4.5,
        "dpmpp_2m",
        "sgm_uniform",
        1
      ]
    },
    {
      "id": 135,
      "type": "EmptySD3LatentImage",
      "pos": [
        -2352,
        438
      ],
      "size": {
        "0": 315,
        "1": 106
      },
      "flags": {},
      "order": 3,
      "mode": 0,
      "inputs": [],
      "outputs": [
        {
          "name": "LATENT",
          "type": "LATENT",
          "links": [
            593
          ],
          "shape": 3,
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "EmptySD3LatentImage"
      },
      "widgets_values": [
        1024,
        1024,
        1
      ]
    },
    {
      "id": 6,
      "type": "CLIPTextEncode",
      "pos": [
        -1876.2871546875003,
        284.0718039306641
      ],
      "size": {
        "0": 389.06927490234375,
        "1": 207.84902954101562
      },
      "flags": {},
      "order": 5,
      "mode": 0,
      "inputs": [
        {
          "name": "clip",
          "type": "CLIP",
          "link": 5
        }
      ],
      "outputs": [
        {
          "name": "CONDITIONING",
          "type": "CONDITIONING",
          "links": [
            595
          ],
          "shape": 3,
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "CLIPTextEncode"
      },
      "widgets_values": [
        "a female character with long, flowing hair that appears to be made of ethereal, swirling patterns resembling the Northern Lights or Aurora Borealis. The background is dominated by deep blues and purples, creating a mysterious and dramatic atmosphere. The character's face is serene, with pale skin and striking features. She wears a dark-colored outfit with subtle patterns. The overall style of the artwork is reminiscent of fantasy or supernatural genres"
      ],
      "color": "#232",
      "bgcolor": "#353"
    },
    {
      "id": 272,
      "type": "PrimitiveNode",
      "pos": [
        -2342,
        278
      ],
      "size": {
        "0": 210,
        "1": 82
      },
      "flags": {},
      "order": 4,
      "mode": 0,
      "outputs": [
        {
          "name": "INT",
          "type": "INT",
          "links": [
            597
          ],
          "slot_index": 0,
          "widget": {
            "name": "seed"
          }
        }
      ],
      "title": "Seed",
      "properties": {
        "Run widget replace on values": false
      },
      "widgets_values": [
        945512652412924,
        "fixed"
      ]
    }
  ],
  "links": [
    [
      5,
      11,
      0,
      6,
      0,
      "CLIP"
    ],
    [
      90,
      67,
      0,
      68,
      0,
      "CONDITIONING"
    ],
    [
      91,
      68,
      0,
      69,
      0,
      "CONDITIONING"
    ],
    [
      92,
      70,
      0,
      69,
      1,
      "CONDITIONING"
    ],
    [
      93,
      71,
      0,
      70,
      0,
      "CONDITIONING"
    ],
    [
      94,
      11,
      0,
      71,
      0,
      "CLIP"
    ],
    [
      557,
      252,
      2,
      231,
      1,
      "VAE"
    ],
    [
      565,
      252,
      0,
      13,
      0,
      "MODEL"
    ],
    [
      580,
      71,
      0,
      67,
      0,
      "CONDITIONING"
    ],
    [
      591,
      13,
      0,
      271,
      0,
      "MODEL"
    ],
    [
      592,
      69,
      0,
      271,
      2,
      "CONDITIONING"
    ],
    [
      593,
      135,
      0,
      271,
      3,
      "LATENT"
    ],
    [
      595,
      6,
      0,
      271,
      1,
      "CONDITIONING"
    ],
    [
      596,
      271,
      0,
      231,
      0,
      "LATENT"
    ],
    [
      597,
      272,
      0,
      271,
      4,
      "INT"
    ],
    [
      599,
      231,
      0,
      233,
      0,
      "IMAGE"
    ]
  ],
  "groups": [
    {
      "title": "Load Models",
      "bounding": [
        -2410,
        -339,
        969,
        488
      ],
      "color": "#3f789e",
      "font_size": 24
    },
    {
      "title": "Input",
      "bounding": [
        -2409,
        181,
        972,
        523
      ],
      "color": "#3f789e",
      "font_size": 24
    },
    {
      "title": "Output",
      "bounding": [
        464,
        -273,
        741,
        814
      ],
      "color": "#3f789e",
      "font_size": 24
    }
  ],
  "config": {},
  "extra": {},
  "version": 0.4
}

测试结果展示
image.png
image.png
image.png
image.png
image.png
image.png


【Qinghub Studio 】更适合开发人员的低代码开源开发平台
QingHub企业级应用统一部署
QingHub企业级应用开发管理
QingHub演示
https://qingplus.cn

<think>嗯,用户这次问的是StableDiffusionComfyUI的关系以及集成使用方法。从之前的对话看,用户应该是个刚接触AI绘画的新手,可能已经尝试过WebUI版本,现在想了解更专业的ComfyUI操作方式。用户特意强调要“参考站内引用”,说明ta需要权威的技术解释,但同时又提醒引用只是参考,更关注实际问题解决——这种矛盾说明用户可能被网上零散教程困扰过。仔细看四个引用:引用1定义ComfyUI是模块化界面,引用2强调配置兼容性问题,引用3突出节点式操作优势,引用4其实是广告可以忽略。核心信息链应该是:ComfyUI作为SD的专业前端→通过节点控制生成流程→需要正确配置环境→操作门槛较高但更自由。用户问“关系或结合使用”其实包含两个层次:一是技术架构层面ComfyUI如何调用SD模型(需要解释后台引擎和前端界面的关系),二是实际工作流中如何协同(要说明节点如何对应SD的采样器、提示词等模块)。特别要注意提醒兼容性问题,因为引用2提到不同UI有配置差异,新手最容易在这里踩坑。上次回复时已经给出环境部署和基础工作流的步骤,这次应该侧重关系阐释:用比喻说明SD是引擎、ComfyUI是控制台,再用具体例子展示文本到图像的节点连接逻辑。用户可能更想知道“为什么用ComfyUI而不是WebUI”,需要对比两者在显存占用、流程可控性方面的差异——这正是引用3提到的关键优势。安全提示容易被忽略但很重要,引用2明确提到配置错误会导致结果异常,应该用显式警告框强调模型兼容性检查。最后保留的问答设计成阶梯式:从原理(计算图)到故障排除再到专业控制,这样用户无论处于哪个学习阶段都能找到切入点。</think> 以下是关于**Stable DiffusionComfyUI的集成和使用方法**的完整说明: --- ### **一、核心关系说明** 1. **技术依赖** ComfyUI 是 **Stable Diffusion 的专用操作界面**,类似于汽车的“方向盘和仪表盘”: - Stable Diffusion:图像生成的**底层引擎**(模型算法) - ComfyUI:控制引擎的**可视化操作台**(节点式工作流) > 二者通过配置文件关联,ComfyUI 调用 Stable Diffusion 的模型文件(如 `*.ckpt`, `*.safetensors`)执行生成任务[^1][^3]。 2. **功能定位** | 工具 | 特点 | |---------------------|----------------------------------------------------------------------| | Stable Diffusion Web UI | 交互简单,适合快速生成,但流程不可视化、显存占用高 | | **ComfyUI** | 通过**节点拖拽**定制生成流程,显存优化更好,支持复杂工作流调试与复用[^3] | --- ### **二、集成步骤(以Windows为例)** #### 1. **安装基础环境** ```bash # 安装 Python 3.10+ 和 Git git clone https://github.com/comfyanonymous/ComfyUI.git cd ComfyUI pip install -r requirements.txt ``` #### 2. **关联Stable Diffusion模型** - 将模型文件放入对应文件夹(首次启动自动生成): ``` ComfyUI/ ├── models/ │ ├── checkpoints/ # 放入SD基础模型(xxx.ckpt) │ ├── loras/ # LoRA模型 │ └── vae/ # VAE模型 ``` #### 3. **启动集成服务** ```bash python main.py --port 8188 ``` - 浏览器访问 `http://localhost:8188` 进入操作界面。 --- ### **三、基础工作流演示** 通过节点连接实现文本→图像生成: ![ComfyUI工作流示例](https://example.com/comfyui_workflow.png) *(节点包括:文本提示 → 加载模型 → K采样器 → 图像输出)* 1. **关键操作**: - 右键空白处添加节点(`Load Checkpoint`, `CLIP Text Encode`, `KSampler`等) - 连接节点逻辑线:提示词→模型→采样器→VAE解码→预览 - 调整采样参数(步骤数、CFG值、种子等) 2. **优势场景**: - **批量控制**:串联多个采样器实现图像迭代优化 - **精细化修图**:连接Inpaint节点局部重绘 - **LoRA融合**:并联多个LoRA模型实现风格混合[^2] --- ### **四、常见问题解决** | 问题 | 解决方案 | |-------------------------------|--------------------------------------------------------------------------| | 模型加载失败 | 检查模型格式是否为`.ckpt/.safetensors`,且存放路径正确 | | 生成结果不符预期 | 检查节点连接顺序,确保CLIP文本编码器连接至采样器的"positive"端口 | | 显存不足(<8GB) | 启用`--lowvram`参数启动,或使用`VAE`的`fp16`版本[^3] | > ⚠️ 注意:避免混用不同UI的配置文件(如Web UI的`config.yml`),否则可能导致参数冲突[^2]。 --- ### **五、进阶学习建议** 1. **节点工作流库**: 访问 [ComfyUI Examples](https://github.com/comfyanonymous/ComfyUI_examples) 学习复杂流程(如ControlNet+IPAdapter)。 2. **视频教程**: 推荐实战操作视频(搜索关键词:_"ComfyUI节点式工作流实操"_),直观掌握连接逻辑[^4]。 3. **性能优化**: 使用 `--xformers` 启动加速推理,或导出工作流为JSON模板复用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值