LoRA工作流

LoRA工作流使用LoRA(Low-Rank Adaptation)模型增强图像生成,可以添加特定风格、改善细节、定制效果。

工作流概述

工作流信息

功能特点

适用场景

工作流结构

LoRA使用指南

下图展示了LoRA的类型和强度设置建议:

这个图展示了: - 风格LoRA: 用于改变整体艺术风格(强度0.5-1.0) - 人物LoRA: 用于特定角色或人物(强度0.7-1.2) - 概念LoRA: 用于特定概念或效果(强度0.5-0.9) - 常见问题: 解决LoRA使用中的问题

节点流程图(Mermaid)

graph TD
    A[CheckpointLoaderSimple] -->|MODEL| B[LoraLoader]
    A -->|CLIP| B

    B -->|MODEL| C[KSampler]
    B -->|CLIP| D[CLIPTextEncode]
    B -->|CLIP| E[CLIPTextEncode]

    A -->|VAE| F[VAEDecode]

    D -->|CONDITIONING| C
    E -->|CONDITIONING| C

    G[EmptyLatentImage] -->|LATENT| C

    C -->|LATENT| F
    F -->|IMAGE| H[SaveImage]

    style A fill:#e1f5ff
    style B fill:#fff4e1
    style C fill:#fff4e1
    style D fill:#ffe1f5
    style E fill:#ffe1f5
    style F fill:#e1ffe1
    style G fill:#e1ffe1
    style H fill:#ffe1e1

节点连接详解

graph LR
    A[CheckpointLoaderSimple] -->|MODEL| B[LoraLoader]
    A -->|CLIP| B
    B -->|MODEL| C[KSampler]
    B -->|CLIP| D[CLIPTextEncode]

    style A fill:#e1f5ff
    style B fill:#fff4e1
    style C fill:#fff4e1
    style D fill:#ffe1f5
graph LR
    A[CheckpointLoaderSimple] -->|MODEL,CLIP| B[LoraLoader 1]
    B -->|MODEL,CLIP| C[LoraLoader 2]
    C -->|MODEL,CLIP| D[KSampler]

    style A fill:#e1f5ff
    style B fill:#fff4e1
    style C fill:#fff4e1
    style D fill:#fff4e1
graph LR
    A[CLIPTextEncode] -->|CONDITIONING| B[KSampler]
    C[CLIPTextEncode] -->|CONDITIONING| B
    D[EmptyLatentImage] -->|LATENT| B
    B -->|LATENT| E[VAEDecode]
    E -->|IMAGE| F[SaveImage]

    style A fill:#ffe1f5
    style B fill:#fff4e1
    style C fill:#ffe1f5
    style D fill:#e1ffe1
    style E fill:#e1ffe1
    style F fill:#ffe1e1

核心节点说明

使用步骤

步骤1: 准备工作

  1. 下载LoRA模型
  2. 将LoRA模型放入 models/lora/ 目录
  3. 确保主模型已加载

步骤2: 加载工作流

  1. 打开ComfyUI
  2. 点击"Load"按钮
  3. 选择工作流JSON文件

步骤3: 配置参数

ckpt_name: v1-5-pruned-emaonly.ckpt
lora_name: detail_tweaker.safetensors
strength_model: 0.8
strength_clip: 0.8
text: beautiful landscape, mountains, sunset, 4k, detailed
text: ugly, blurry, low quality
seed: 123456789
steps: 20
cfg: 8
sampler_name: euler
scheduler: normal
denoise: 1.0

步骤4: 执行工作流

  1. 点击"Queue Prompt"按钮
  2. 等待执行完成
  3. 查看生成的图像

工作流JSON

单LoRA工作流

{
  "3": {
    "inputs": {
      "seed": 123456789,
      "steps": 20,
      "cfg": 8,
      "sampler_name": "euler",
      "scheduler": "normal",
      "denoise": 1.0,
      "model": ["11", 0],
      "positive": ["6", 0],
      "negative": ["7", 0],
      "latent_image": ["5", 0]
    },
    "class_type": "KSampler"
  },
  "4": {
    "inputs": {
      "ckpt_name": "v1-5-pruned-emaonly.ckpt"
    },
    "class_type": "CheckpointLoaderSimple"
  },
  "5": {
    "inputs": {
      "width": 512,
      "height": 512,
      "batch_size": 1
    },
    "class_type": "EmptyLatentImage"
  },
  "6": {
    "inputs": {
      "text": "beautiful landscape, mountains, sunset, 4k, detailed",
      "clip": ["11", 1]
    },
    "class_type": "CLIPTextEncode"
  },
  "7": {
    "inputs": {
      "text": "ugly, blurry, low quality",
      "clip": ["11", 1]
    },
    "class_type": "CLIPTextEncode"
  },
  "8": {
    "inputs": {
      "samples": ["3", 0],
      "vae": ["4", 2]
    },
    "class_type": "VAEDecode"
  },
  "9": {
    "inputs": {
      "filename_prefix": "lora_",
      "images": ["8", 0]
    },
    "class_type": "SaveImage"
  },
  "11": {
    "inputs": {
      "lora_name": "detail_tweaker.safetensors",
      "strength_model": 0.8,
      "strength_clip": 0.8,
      "model": ["4", 0],
      "clip": ["4", 1]
    },
    "class_type": "LoraLoader"
  }
}

多LoRA工作流

{
  "3": {
    "inputs": {
      "seed": 123456789,
      "steps": 20,
      "cfg": 8,
      "sampler_name": "euler",
      "scheduler": "normal",
      "denoise": 1.0,
      "model": ["16", 0],
      "positive": ["6", 0],
      "negative": ["7", 0],
      "latent_image": ["5", 0]
    },
    "class_type": "KSampler"
  },
  "4": {
    "inputs": {
      "ckpt_name": "v1-5-pruned-emaonly.ckpt"
    },
    "class_type": "CheckpointLoaderSimple"
  },
  "5": {
    "inputs": {
      "width": 512,
      "height": 512,
      "batch_size": 1
    },
    "class_type": "EmptyLatentImage"
  },
  "6": {
    "inputs": {
      "text": "beautiful landscape, mountains, sunset, 4k, detailed",
      "clip": ["16", 1]
    },
    "class_type": "CLIPTextEncode"
  },
  "7": {
    "inputs": {
      "text": "ugly, blurry, low quality",
      "clip": ["16", 1]
    },
    "class_type": "CLIPTextEncode"
  },
  "8": {
    "inputs": {
      "samples": ["3", 0],
      "vae": ["4", 2]
    },
    "class_type": "VAEDecode"
  },
  "9": {
    "inputs": {
      "filename_prefix": "lora_multi_",
      "images": ["8", 0]
    },
    "class_type": "SaveImage"
  },
  "11": {
    "inputs": {
      "lora_name": "detail_tweaker.safetensors",
      "strength_model": 0.6,
      "strength_clip": 0.6,
      "model": ["4", 0],
      "clip": ["4", 1]
    },
    "class_type": "LoraLoader"
  },
  "16": {
    "inputs": {
      "lora_name": "add_more_details.safetensors",
      "strength_model": 0.5,
      "strength_clip": 0.5,
      "model": ["11", 0],
      "clip": ["11", 1]
    },
    "class_type": "LoraLoader"
  }
}

LoRA类型

1. 细节增强类

2. 风格化类

3. 人物类

4. 场景类

参数配置指南

关键参数说明

示例结果

示例1: 细节增强

示例2: 风格化

示例3: 多LoRA组合

LoRA组合策略

策略1: 主次分明

graph LR
    A[主模型] --> B[主LoRA<br/>strength: 0.8] --> C[次LoRA<br/>strength: 0.5] --> D[采样器]

    style A fill:#e1f5ff
    style B fill:#fff4e1
    style C fill:#fff4e1
    style D fill:#fff4e1

策略2: 功能互补

graph LR
    A[主模型] --> B[细节LoRA<br/>strength: 0.6] --> C[风格LoRA<br/>strength: 0.5] --> D[采样器]

    style A fill:#e1f5ff
    style B fill:#fff4e1
    style C fill:#fff4e1
    style D fill:#fff4e1

策略3: 渐进增强

graph LR
    A[主模型] --> B[LoRA1<br/>strength: 0.5] --> C[LoRA2<br/>strength: 0.4] --> D[LoRA3<br/>strength: 0.3] --> E[采样器]

    style A fill:#e1f5ff
    style B fill:#fff4e1
    style C fill:#fff4e1
    style D fill:#fff4e1
    style E fill:#fff4e1

优化建议

效果优化

性能优化

质量优化

常见问题

Q1: LoRA strength设置多少合适?

A: 从0.8开始,根据效果调整,通常0.5-1.0之间。

Q2: 可以使用多个LoRA吗?

A: 可以,串联多个LoraLoader节点,但总强度不宜过高。

Q3: LoRA和主模型有什么区别?

A: LoRA是轻量级模型,用于增强主模型,不能单独使用。

Q4: 如何选择LoRA?

A: 根据需求选择,细节增强用detail类,风格化用风格类。

Q5: LoRA效果不明显怎么办?

A: 增加strength值,检查LoRA是否正确加载,尝试其他LoRA。

变体工作流

变体1: 单LoRA

变体2: 双LoRA

变体3: 多LoRA

相关工作流

扩展阅读

更新日志