ComfyUI - 使用 ComfyUI 部署与测试 FLUX.1 图像生成模型 教程
前言
FLUX.1 是由 Black Forest Labs 推出的文本到图像生成模型,已成为 AI 绘画领域的高品质模型。该模型由 Stability AI 的前核心成员开发,具备强大的生成能力和高质量的图像输出。目前,Flux 的相关模型:
- Flux & AE 模型:https://huggingface.co/black-forest-labs/FLUX.1-dev
- CLIP 模型:https://huggingface.co/stabilityai/stable-diffusion-3-medium
FP8 模型地址:https://huggingface.co/Kijai/flux-fp8/tree/main
安装 HuggingFace 下载工具,使用镜像下载速度明显加快:
所有的AI设计工具,模型和插件,都已经整理好了,👇获取~
export HF_ENDPOINT="https://hf-mirror.com"
pip install -U huggingface_hub hf-transfer
下载 HuggingFace 脚本,如下:
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 地址来源于,全部勾选即可生成。
其中,完全版是 FP16 的版本 flux1-dev.safetensors
,大约 23G,即:
FLUX.1-dev/flux1-dev.safetensors
bypy upload flux1-dev.safetensors /stable_diffusion/flux_data/flux1-dev.safetensors
AE 模型:
FLUX.1-dev/ae.safetensors
CLIP 是两个模型:
stable-diffusion-3-medium/text_encoders/clip_l.safetensors
stable-diffusion-3-medium/text_encoders/t5xxl_fp16.safetensors
将 Flux 的相关模型,放入相应的位置:
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
{"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
}
这里分享给大家一份Adobe大神整理的《AIGC全家桶学习笔记》,相信大家会对AIGC有着更深入、更系统的理解。
有需要的朋友,可以点击下方免费领取!
AIGC所有方向的学习路线思维导图
这里为大家提供了总的路线图。它的用处就在于,你可以按照上面的知识点去找对应的学习资源,保证自己学得较为全面。如果下面这个学习路线能帮助大家将AI利用到自身工作上去,那么我的使命也就完成了:
AIGC工具库
AIGC工具库是一个利用人工智能技术来生成应用程序的代码和内容的工具集合,通过使用AIGC工具库,能更加快速,准确的辅助我们学习AIGC
有需要的朋友,可以点击下方卡片免费领取!
精品AIGC学习书籍手册
书籍阅读永不过时,阅读AIGC经典书籍可以帮助读者提高技术水平,开拓视野,掌握核心技术,提高解决问题的能力,同时也可以借鉴他人的经验,结合自身案例融会贯通。
AI绘画视频合集
我们在学习的时候,往往书籍源码难以理解,阅读困难,这时候视频教程教程是就很适合了,生动形象加上案例实战,科学有趣才能更方便的学习下去。