ComfyUI - 在 ComfyUI 配置与测试图像生成 Flux 模型教程

欢迎关注我的CSDN:https://spike.blog.csdn.net/

本文地址:https://spike.blog.csdn.net/article/details/141201307

免责声明:本文来源于个人知识与公开资料,仅用于学术交流,欢迎讨论,不支持转载。


Flux 是由 Black Forest Labs 推出的最新文本到图像生成模型,已成为 AI 绘画领域的高品质模型。该模型由 Stability AI 的前核心成员开发,具备强大的生成能力和高质量的图像输出。目前,Flux 的相关模型:

FP8 模型地址:https://huggingface.co/Kijai/flux-fp8/tree/main

安装 HuggingFace 下载工具,使用镜像下载速度明显加快:

bash 复制代码
export HF_ENDPOINT="https://hf-mirror.com"
pip install -U huggingface_hub hf-transfer

下载 HuggingFace 脚本,如下:

bash 复制代码
huggingface-cli download --token [your toekn] black-forest-labs/FLUX.1-dev --local-dir FLUX.1-dev --include "flux1-dev.safetensors" 
huggingface-cli download --token [your toekn] black-forest-labs/FLUX.1-dev --local-dir FLUX.1-dev --include "ae.safetensors"
huggingface-cli download --token [your toekn] stabilityai/stable-diffusion-3-medium --local-dir stable-diffusion-3-medium 

下载之前需要申请权限,Token 地址来源于:https://huggingface.co/settings/tokens,全部勾选即可生成。

其中,完全版是 FP16 的版本 flux1-dev.safetensors,大约 23G,即:

bash 复制代码
FLUX.1-dev/flux1-dev.safetensors 
bypy upload flux1-dev.safetensors /stable_diffusion/flux_data/flux1-dev.safetensors

AE 模型:

bash 复制代码
FLUX.1-dev/ae.safetensors

CLIP 是两个模型:

bash 复制代码
stable-diffusion-3-medium/text_encoders/clip_l.safetensors
stable-diffusion-3-medium/text_encoders/t5xxl_fp16.safetensors

将 Flux 的相关模型,放入相应的位置:

bash 复制代码
ComfyUI/models/unet/flux1-dev.safetensors
ComfyUI/models/vae/ae.safetensors
ComfyUI/models/clip/clip_l.safetensors
ComfyUI/models/clip/t5xxl_fp16.safetensors

搭建 Flux 流程:

相关提示词:

A queen sits on a throne, looking at the camera with arrogance, legs crossed, wearing high heels and white stockings.

The palace is bright, highlighting the queen's majesty.

Low POV (Point of View), tilted shot from below.

A Chinese queen sits on a very high throne in bright palace, looking at the camera, legs crossed, wearing golden high heels and black stockings.

very low POV, tilted shot from below.

A woman empress of China sits on a very high throne in the bright palace. She is looking at the camera, legs crossed, wearing golden high heels and black stockings.

very low POV, tilted shot from very below.

very high quality.

原图:

重绘图像:

ComfyUI Pipeline Json

json 复制代码
{
  "last_node_id": 66,
  "last_link_id": 110,
  "nodes": [
    {
      "id": 8,
      "type": "UNETLoader",
      "pos": [
        -372,
        -138
      ],
      "size": {
        "0": 315,
        "1": 82
      },
      "flags": {},
      "order": 0,
      "mode": 0,
      "outputs": [
        {
          "name": "MODEL",
          "type": "MODEL",
          "links": [
            73
          ],
          "shape": 3,
          "label": "模型",
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "UNETLoader"
      },
      "widgets_values": [
        "flux1-dev.safetensors",
        "default"
      ]
    },
    {
      "id": 9,
      "type": "DualCLIPLoader",
      "pos": [
        -372,
        164
      ],
      "size": {
        "0": 315,
        "1": 106
      },
      "flags": {},
      "order": 1,
      "mode": 0,
      "outputs": [
        {
          "name": "CLIP",
          "type": "CLIP",
          "links": [
            81
          ],
          "shape": 3,
          "label": "CLIP",
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "DualCLIPLoader"
      },
      "widgets_values": [
        "t5xxl_fp16.safetensors",
        "clip_l.safetensors",
        "flux"
      ]
    },
    {
      "id": 12,
      "type": "CLIPTextEncodeFlux",
      "pos": [
        5,
        165
      ],
      "size": {
        "0": 246.04954528808594,
        "1": 111.51980590820312
      },
      "flags": {},
      "order": 11,
      "mode": 0,
      "inputs": [
        {
          "name": "clip",
          "type": "CLIP",
          "link": 81,
          "label": "CLIP"
        },
        {
          "name": "clip_l",
          "type": "STRING",
          "link": 34,
          "widget": {
            "name": "clip_l"
          },
          "label": "CLIP_L",
          "slot_index": 1
        },
        {
          "name": "t5xxl",
          "type": "STRING",
          "link": 35,
          "widget": {
            "name": "t5xxl"
          },
          "label": "T5XXL"
        }
      ],
      "outputs": [
        {
          "name": "CONDITIONING",
          "type": "CONDITIONING",
          "links": [
            14
          ],
          "shape": 3,
          "label": "条件",
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "CLIPTextEncodeFlux"
      },
      "widgets_values": [
        "A queen sits on a throne, looking at the camera with arrogance, legs crossed, wearing high heels and black stockings.\nLow POV, tilted shot from below.\nThe palace is bathed in natural light.",
        "A queen sits on a throne, looking at the camera with arrogance, legs crossed, wearing high heels and black stockings.\nLow POV, tilted shot from below.\nThe palace is bathed in natural light.",
        3.5,
        true,
        true
      ]
    },
    {
      "id": 15,
      "type": "LatentFromBatch",
      "pos": [
        317,
        135
      ],
      "size": {
        "0": 315,
        "1": 82
      },
      "flags": {},
      "order": 9,
      "mode": 0,
      "inputs": [
        {
          "name": "samples",
          "type": "LATENT",
          "link": 13,
          "label": "Latent"
        }
      ],
      "outputs": [
        {
          "name": "LATENT",
          "type": "LATENT",
          "links": [
            18
          ],
          "shape": 3,
          "label": "Latent",
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "LatentFromBatch"
      },
      "widgets_values": [
        0,
        1
      ]
    },
    {
      "id": 5,
      "type": "EmptyLatentImage",
      "pos": [
        -372,
        -291
      ],
      "size": {
        "0": 315,
        "1": 106
      },
      "flags": {},
      "order": 2,
      "mode": 0,
      "outputs": [
        {
          "name": "LATENT",
          "type": "LATENT",
          "links": [
            13
          ],
          "shape": 3,
          "label": "Latent",
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "EmptyLatentImage"
      },
      "widgets_values": [
        1280,
        800,
        1
      ]
    },
    {
      "id": 16,
      "type": "BasicScheduler",
      "pos": [
        317,
        279
      ],
      "size": {
        "0": 315,
        "1": 106
      },
      "flags": {},
      "order": 12,
      "mode": 0,
      "inputs": [
        {
          "name": "model",
          "type": "MODEL",
          "link": 79,
          "label": "模型"
        }
      ],
      "outputs": [
        {
          "name": "SIGMAS",
          "type": "SIGMAS",
          "links": [
            20
          ],
          "shape": 3,
          "label": "Sigmas",
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "BasicScheduler"
      },
      "widgets_values": [
        "normal",
        25,
        1
      ]
    },
    {
      "id": 11,
      "type": "ModelSamplingFlux",
      "pos": [
        -372,
        -10
      ],
      "size": {
        "0": 315,
        "1": 130
      },
      "flags": {},
      "order": 8,
      "mode": 0,
      "inputs": [
        {
          "name": "model",
          "type": "MODEL",
          "link": 73,
          "label": "模型"
        }
      ],
      "outputs": [
        {
          "name": "MODEL",
          "type": "MODEL",
          "links": [
            78,
            79,
            99
          ],
          "shape": 3,
          "label": "模型",
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "ModelSamplingFlux"
      },
      "widgets_values": [
        1.15,
        0.5,
        1024,
        1024
      ]
    },
    {
      "id": 61,
      "type": "Reroute",
      "pos": [
        997,
        -64
      ],
      "size": [
        75,
        26
      ],
      "flags": {},
      "order": 13,
      "mode": 0,
      "inputs": [
        {
          "name": "",
          "type": "*",
          "link": 99
        }
      ],
      "outputs": [
        {
          "name": "",
          "type": "MODEL",
          "links": [
            100
          ],
          "slot_index": 0
        }
      ],
      "properties": {
        "showOutputText": false,
        "horizontal": false
      }
    },
    {
      "id": 17,
      "type": "BasicGuider",
      "pos": [
        317,
        -58
      ],
      "size": {
        "0": 241.79998779296875,
        "1": 46
      },
      "flags": {},
      "order": 14,
      "mode": 0,
      "inputs": [
        {
          "name": "model",
          "type": "MODEL",
          "link": 78,
          "label": "模型"
        },
        {
          "name": "conditioning",
          "type": "CONDITIONING",
          "link": 14,
          "label": "条件"
        }
      ],
      "outputs": [
        {
          "name": "GUIDER",
          "type": "GUIDER",
          "links": [
            17,
            101
          ],
          "shape": 3,
          "label": "引导",
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "BasicGuider"
      }
    },
    {
      "id": 14,
      "type": "KSamplerSelect",
      "pos": [
        317,
        29
      ],
      "size": {
        "0": 315,
        "1": 58
      },
      "flags": {},
      "order": 3,
      "mode": 0,
      "outputs": [
        {
          "name": "SAMPLER",
          "type": "SAMPLER",
          "links": [
            19,
            103
          ],
          "shape": 3,
          "label": "采样器",
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "KSamplerSelect"
      },
      "widgets_values": [
        "euler"
      ]
    },
    {
      "id": 19,
      "type": "VAEDecode",
      "pos": [
        717,
        -64
      ],
      "size": {
        "0": 210,
        "1": 46
      },
      "flags": {
        "collapsed": false
      },
      "order": 17,
      "mode": 0,
      "inputs": [
        {
          "name": "samples",
          "type": "LATENT",
          "link": 93,
          "label": "Latent"
        },
        {
          "name": "vae",
          "type": "VAE",
          "link": 22,
          "label": "VAE"
        }
      ],
      "outputs": [
        {
          "name": "IMAGE",
          "type": "IMAGE",
          "links": [
            89
          ],
          "shape": 3,
          "label": "图像",
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "VAEDecode"
      }
    },
    {
      "id": 10,
      "type": "VAELoader",
      "pos": [
        -372,
        321
      ],
      "size": {
        "0": 315,
        "1": 58
      },
      "flags": {},
      "order": 4,
      "mode": 0,
      "outputs": [
        {
          "name": "VAE",
          "type": "VAE",
          "links": [
            22,
            104
          ],
          "shape": 3,
          "slot_index": 0,
          "label": "VAE"
        }
      ],
      "properties": {
        "Node name for S&R": "VAELoader"
      },
      "widgets_values": [
        "flux_ae.safetensors"
      ]
    },
    {
      "id": 63,
      "type": "Reroute",
      "pos": [
        999,
        -33
      ],
      "size": [
        75,
        26
      ],
      "flags": {},
      "order": 10,
      "mode": 0,
      "inputs": [
        {
          "name": "",
          "type": "*",
          "link": 104
        }
      ],
      "outputs": [
        {
          "name": "",
          "type": "VAE",
          "links": [
            105
          ],
          "slot_index": 0
        }
      ],
      "properties": {
        "showOutputText": false,
        "horizontal": false
      }
    },
    {
      "id": 62,
      "type": "VAEDecode",
      "pos": [
        1135,
        92
      ],
      "size": {
        "0": 210,
        "1": 46
      },
      "flags": {
        "collapsed": false
      },
      "order": 21,
      "mode": 0,
      "inputs": [
        {
          "name": "samples",
          "type": "LATENT",
          "link": 106,
          "label": "Latent"
        },
        {
          "name": "vae",
          "type": "VAE",
          "link": 105,
          "label": "VAE"
        }
      ],
      "outputs": [
        {
          "name": "IMAGE",
          "type": "IMAGE",
          "links": [
            107
          ],
          "shape": 3,
          "label": "图像",
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "VAEDecode"
      }
    },
    {
      "id": 66,
      "type": "RandomNoise",
      "pos": [
        1458,
        -350
      ],
      "size": {
        "0": 315,
        "1": 82
      },
      "flags": {},
      "order": 5,
      "mode": 0,
      "outputs": [
        {
          "name": "NOISE",
          "type": "NOISE",
          "links": [
            110
          ],
          "shape": 3,
          "label": "噪波生成",
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "RandomNoise"
      },
      "widgets_values": [
        858548031216041,
        "randomize"
      ]
    },
    {
      "id": 18,
      "type": "SamplerCustomAdvanced",
      "pos": [
        713,
        -219
      ],
      "size": {
        "0": 355.20001220703125,
        "1": 106
      },
      "flags": {},
      "order": 16,
      "mode": 0,
      "inputs": [
        {
          "name": "noise",
          "type": "NOISE",
          "link": 16,
          "label": "噪波生成"
        },
        {
          "name": "guider",
          "type": "GUIDER",
          "link": 17,
          "label": "引导"
        },
        {
          "name": "sampler",
          "type": "SAMPLER",
          "link": 19,
          "label": "采样器"
        },
        {
          "name": "sigmas",
          "type": "SIGMAS",
          "link": 20,
          "label": "Sigmas"
        },
        {
          "name": "latent_image",
          "type": "LATENT",
          "link": 18,
          "label": "Latent"
        }
      ],
      "outputs": [
        {
          "name": "output",
          "type": "LATENT",
          "links": [
            93,
            108
          ],
          "shape": 3,
          "label": "输出",
          "slot_index": 0
        },
        {
          "name": "denoised_output",
          "type": "LATENT",
          "links": [],
          "shape": 3,
          "label": "降噪输出",
          "slot_index": 1
        }
      ],
      "properties": {
        "Node name for S&R": "SamplerCustomAdvanced"
      },
      "color": "#322",
      "bgcolor": "#533"
    },
    {
      "id": 13,
      "type": "RandomNoise",
      "pos": [
        317,
        -186
      ],
      "size": {
        "0": 315,
        "1": 82
      },
      "flags": {},
      "order": 6,
      "mode": 0,
      "outputs": [
        {
          "name": "NOISE",
          "type": "NOISE",
          "links": [
            16
          ],
          "shape": 3,
          "label": "噪波生成",
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "RandomNoise"
      },
      "widgets_values": [
        3,
        "fixed"
      ]
    },
    {
      "id": 37,
      "type": "StringFunction|pysssss",
      "pos": [
        -373,
        442
      ],
      "size": {
        "0": 403.92303466796875,
        "1": 274
      },
      "flags": {},
      "order": 7,
      "mode": 0,
      "outputs": [
        {
          "name": "STRING",
          "type": "STRING",
          "links": [
            34,
            35
          ],
          "shape": 3,
          "label": "字符串",
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "StringFunction|pysssss"
      },
      "widgets_values": [
        "append",
        "yes",
        "A woman empress of China sits on a very high throne in the bright palace. She is looking at the camera, legs crossed, wearing golden high heels and black stockings.\n",
        "very low POV, tilted shot from very below.\nvery high quality.",
        "",
        "A woman empress of China sits on a very high throne in the bright palace. She is looking at the camera, legs crossed, wearing golden high heels and black stockings.\n, very low POV, tilted shot from very below.\nvery high quality."
      ]
    },
    {
      "id": 65,
      "type": "LatentUpscaleBy",
      "pos": [
        1127,
        -350
      ],
      "size": {
        "0": 315,
        "1": 82
      },
      "flags": {},
      "order": 18,
      "mode": 0,
      "inputs": [
        {
          "name": "samples",
          "type": "LATENT",
          "link": 108,
          "label": "Latent"
        }
      ],
      "outputs": [
        {
          "name": "LATENT",
          "type": "LATENT",
          "links": [
            109
          ],
          "shape": 3,
          "label": "Latent",
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "LatentUpscaleBy"
      },
      "widgets_values": [
        "nearest-exact",
        1.5
      ]
    },
    {
      "id": 59,
      "type": "SamplerCustomAdvanced",
      "pos": [
        1126,
        -219
      ],
      "size": {
        "0": 355.20001220703125,
        "1": 106
      },
      "flags": {},
      "order": 20,
      "mode": 0,
      "inputs": [
        {
          "name": "noise",
          "type": "NOISE",
          "link": 110,
          "label": "噪波生成"
        },
        {
          "name": "guider",
          "type": "GUIDER",
          "link": 101,
          "label": "引导"
        },
        {
          "name": "sampler",
          "type": "SAMPLER",
          "link": 103,
          "label": "采样器"
        },
        {
          "name": "sigmas",
          "type": "SIGMAS",
          "link": 98,
          "label": "Sigmas"
        },
        {
          "name": "latent_image",
          "type": "LATENT",
          "link": 109,
          "label": "Latent"
        }
      ],
      "outputs": [
        {
          "name": "output",
          "type": "LATENT",
          "links": [
            106
          ],
          "shape": 3,
          "label": "输出",
          "slot_index": 0
        },
        {
          "name": "denoised_output",
          "type": "LATENT",
          "links": [],
          "shape": 3,
          "label": "降噪输出",
          "slot_index": 1
        }
      ],
      "properties": {
        "Node name for S&R": "SamplerCustomAdvanced"
      },
      "color": "#322",
      "bgcolor": "#533"
    },
    {
      "id": 60,
      "type": "BasicScheduler",
      "pos": [
        1130,
        -63
      ],
      "size": {
        "0": 315,
        "1": 106
      },
      "flags": {},
      "order": 15,
      "mode": 0,
      "inputs": [
        {
          "name": "model",
          "type": "MODEL",
          "link": 100,
          "label": "模型",
          "slot_index": 0
        }
      ],
      "outputs": [
        {
          "name": "SIGMAS",
          "type": "SIGMAS",
          "links": [
            98
          ],
          "shape": 3,
          "label": "Sigmas",
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "BasicScheduler"
      },
      "widgets_values": [
        "normal",
        20,
        0.5
      ]
    },
    {
      "id": 7,
      "type": "PreviewImage",
      "pos": [
        716,
        30
      ],
      "size": {
        "0": 359.57421875,
        "1": 249.54296875
      },
      "flags": {},
      "order": 19,
      "mode": 0,
      "inputs": [
        {
          "name": "images",
          "type": "IMAGE",
          "link": 89,
          "label": "图像"
        }
      ],
      "properties": {
        "Node name for S&R": "PreviewImage"
      }
    },
    {
      "id": 64,
      "type": "PreviewImage",
      "pos": [
        1137,
        190
      ],
      "size": {
        "0": 359.57421875,
        "1": 249.54296875
      },
      "flags": {},
      "order": 22,
      "mode": 0,
      "inputs": [
        {
          "name": "images",
          "type": "IMAGE",
          "link": 107,
          "label": "图像"
        }
      ],
      "properties": {
        "Node name for S&R": "PreviewImage"
      }
    }
  ],
  "links": [
    [
      13,
      5,
      0,
      15,
      0,
      "LATENT"
    ],
    [
      14,
      12,
      0,
      17,
      1,
      "CONDITIONING"
    ],
    [
      16,
      13,
      0,
      18,
      0,
      "NOISE"
    ],
    [
      17,
      17,
      0,
      18,
      1,
      "GUIDER"
    ],
    [
      18,
      15,
      0,
      18,
      4,
      "LATENT"
    ],
    [
      19,
      14,
      0,
      18,
      2,
      "SAMPLER"
    ],
    [
      20,
      16,
      0,
      18,
      3,
      "SIGMAS"
    ],
    [
      22,
      10,
      0,
      19,
      1,
      "VAE"
    ],
    [
      34,
      37,
      0,
      12,
      1,
      "STRING"
    ],
    [
      35,
      37,
      0,
      12,
      2,
      "STRING"
    ],
    [
      73,
      8,
      0,
      11,
      0,
      "MODEL"
    ],
    [
      78,
      11,
      0,
      17,
      0,
      "MODEL"
    ],
    [
      79,
      11,
      0,
      16,
      0,
      "MODEL"
    ],
    [
      81,
      9,
      0,
      12,
      0,
      "CLIP"
    ],
    [
      89,
      19,
      0,
      7,
      0,
      "IMAGE"
    ],
    [
      93,
      18,
      0,
      19,
      0,
      "LATENT"
    ],
    [
      98,
      60,
      0,
      59,
      3,
      "SIGMAS"
    ],
    [
      99,
      11,
      0,
      61,
      0,
      "*"
    ],
    [
      100,
      61,
      0,
      60,
      0,
      "MODEL"
    ],
    [
      101,
      17,
      0,
      59,
      1,
      "GUIDER"
    ],
    [
      103,
      14,
      0,
      59,
      2,
      "SAMPLER"
    ],
    [
      104,
      10,
      0,
      63,
      0,
      "*"
    ],
    [
      105,
      63,
      0,
      62,
      1,
      "VAE"
    ],
    [
      106,
      59,
      0,
      62,
      0,
      "LATENT"
    ],
    [
      107,
      62,
      0,
      64,
      0,
      "IMAGE"
    ],
    [
      108,
      18,
      0,
      65,
      0,
      "LATENT"
    ],
    [
      109,
      65,
      0,
      59,
      4,
      "LATENT"
    ],
    [
      110,
      66,
      0,
      59,
      0,
      "NOISE"
    ]
  ],
  "groups": [],
  "config": {},
  "extra": {
    "ds": {
      "scale": 1.4864362802414455,
      "offset": [
        -818.3005016409714,
        -63.35849743821387
      ]
    }
  },
  "version": 0.4
}
相关推荐
火山引擎边缘云5 小时前
创新实践:基于边缘智能+扣子的智慧婴儿监控解决方案
物联网·aigc·边缘计算
算家云5 小时前
如何在算家云搭建Aatrox-Bert-VITS2(音频生成)
人工智能·深度学习·aigc·模型搭建·音频生成·算家云
AI绘画小3311 小时前
【comfyui教程】comfyui古风一键线稿上色,效果还挺惊艳!
人工智能·ai作画·stable diffusion·aigc·comfyui
AI绘画月月12 小时前
【comfyui教程】ComfyUI有趣工作流推荐:快速换脸,创意随手掌握!
人工智能·ai作画·stable diffusion·aigc·comfyui
AI绘画咪酱13 小时前
【AI绘画】AI绘图教程|stable diffusion(SD)图生图涂鸦超详细攻略,教你快速上手
人工智能·ai作画·stable diffusion·aigc·midjourney
GPUStack13 小时前
制作并量化GGUF模型上传到HuggingFace和ModelScope
大模型·huggingface·modelscope·genai·gguf
过去式的马马马13 小时前
文多多AIPPT
ai作画·aigc·文心一言·ai编程·dall·e 2
逐星ing16 小时前
【AIGC】腾讯云语音识别(ASR)服务在Spring Boot项目中的集成与实践
aigc·腾讯云·语音识别
花千树-0101 天前
Milvus - GPU 索引类型及其应用场景
运维·人工智能·aigc·embedding·ai编程·milvus
DisonTangor1 天前
腾讯混元3D-1.0:文本到三维和图像到三维生成的统一框架
人工智能·3d·aigc