文生图基础模板

最基础的文生图工作流模板,适合新手学习和使用。

模板概述

工作流结构

节点流程图(Mermaid)

graph TD
    A[CheckpointLoaderSimple] -->|MODEL| B[KSampler]
    A -->|CLIP| C[CLIPTextEncode]
    A -->|CLIP| D[CLIPTextEncode]
    A -->|VAE| E[VAEDecode]

    C -->|CONDITIONING| B
    D -->|CONDITIONING| B

    F[EmptyLatentImage] -->|LATENT| B

    B -->|LATENT| E
    E -->|IMAGE| G[SaveImage]

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

节点连接详解

graph LR
    A[模型加载] --> B[提示词编码]
    B --> C[采样]
    C --> D[解码]
    D --> E[保存]

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

节点配置

1. CheckpointLoaderSimple

{
  "inputs": {
    "ckpt_name": "v1-5-pruned-emaonly.ckpt"
  },
  "class_type": "CheckpointLoaderSimple"
}

2. CLIPTextEncode (正向)

{
  "inputs": {
    "text": "beautiful landscape, mountains, sunset, 4k, detailed",
    "clip": ["1", 1]
  },
  "class_type": "CLIPTextEncode"
}

3. CLIPTextEncode (负向)

{
  "inputs": {
    "text": "ugly, blurry, low quality",
    "clip": ["1", 1]
  },
  "class_type": "CLIPTextEncode"
}

4. EmptyLatentImage

{
  "inputs": {
    "width": 512,
    "height": 512,
    "batch_size": 1
  },
  "class_type": "EmptyLatentImage"
}

5. KSampler

{
  "inputs": {
    "seed": 123456789,
    "steps": 20,
    "cfg": 7.5,
    "sampler_name": "euler",
    "scheduler": "normal",
    "denoise": 1.0,
    "model": ["1", 0],
    "positive": ["2", 0],
    "negative": ["3", 0],
    "latent_image": ["4", 0]
  },
  "class_type": "KSampler"
}

6. VAEDecode

{
  "inputs": {
    "samples": ["5", 0],
    "vae": ["1", 2]
  },
  "class_type": "VAEDecode"
}

7. SaveImage

{
  "inputs": {
    "filename_prefix": "txt2img_",
    "images": ["6", 0]
  },
  "class_type": "SaveImage"
}

完整工作流JSON

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

参数说明

关键参数

graph TD
    A[关键参数] --> B[seed]
    A --> C[steps]
    A --> D[cfg]
    A --> E[分辨率]

    B --> B1[随机种子]
    C --> C1[采样步数]
    D --> D1[提示词相关性]
    E --> E1[图像尺寸]

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

参数推荐值

使用步骤

步骤流程图

graph LR
    A[加载模型] --> B[设置提示词]
    B --> C[创建潜在空间]
    C --> D[采样生成]
    D --> E[解码图像]
    E --> F[保存图像]

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

示例结果

示例1: 风景生成

示例2: 人物生成

常见问题

Q1: 如何修改提示词?

A: 修改CLIPTextEncode节点的text参数。

Q2: 如何调整图像大小?

A: 修改EmptyLatentImage的width和height参数。

Q3: 如何提高质量?

A: 增加steps,调整cfg,改进提示词。

Q4: 如何批量生成?

A: 增加batch_size参数。

Q5: 如何保存工作流?

A: 点击"Save"按钮,保存为JSON文件。

扩展建议

扩展方向

graph TD
    A[基础模板] --> B[添加LoRA]
    A --> C[添加ControlNet]
    A --> D[添加后处理]
    A --> E[批量处理]

    B --> B1[LoraLoader]
    C --> C1[ControlNetApply]
    D --> D1[ImageScale]
    E --> E1[增加batch_size]

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

相关模板

更新日志