- 杨自健 (ORCID: 0009–0006–8301–7634)
在本文中,我们将一步步指导您如何使用FLUX.1。
开源社区迎来了一个新的文本转图像生成模型FLUX.1,继SD 3 Medium和Kolors发布之后。FLUX.1由前Stability AI核心成员开发,其质量远超SD 3,甚至可以与闭源的Midjourney v6.1模型相媲美。这使得FLUX.1成为AI生成艺术的新标杆,并为开源AI艺术的发展注入了新的动力。
FLUX.1 的背后公司是 Black Forest Labs,由 Stable Diffusion 的原团队以及 Stability AI 的几位前研究人员共同创立。与 Stability AI 一样,Black Forest Labs 致力于开发高质量的多模态模型并将其开源。该公司已经完成了 3100 万美元的种子轮融资。
Black Forest Labs官网: https://blackforestlabs.ai/
FLUX.1 提供三个版本:Pro、Dev 和 Schnell。前两个模型在性能上超过了主流模型如 SD3-Ultra,而较小的 FLUX.1 [schnell] 则超过了更大的模型,例如 Midjourney v6.0 和 DALL·E 3。
FLUX.1 与主流模型的 ELO 分数比较
FLUX.1 在文本生成、遵循复杂指令和渲染人类手部方面表现出色。以下是其最强大模型 FLUX.1 [pro] 生成的图像示例。如您所见,即使生成大量文本或多个角色,文本和人类手部等细节也没有任何错误。
FLUX.1 [pro] 生成的图像示例
免费在线试用 FLUX.1这里有一些网站,你可以在这些网站上在线体验FLUX.1模型。如果你只想探索并使用这个强大的文本转图像模型,免费的在线访问是最好的选择。
Hugging Face(免费 | 有限使用频率)FLUX.1-dev:
https://huggingface.co/spaces/black-forest-labs/FLUX.1-dev
FLUX.1-schnell:
https://huggingface.co/spaces/black-forest-labs/FLUX.1-schnell
用户界面:
注意: 目前,FLUX.1 schnell 的使用限制较少,但使用 FLUX.1 dev 生成多个图像后,再次使用之前会有一个冷却期。
一幅细致且充满氛围的老人肖像,他站在一扇破旧的乡村窗户旁。老人穿着一套破旧的深色西装,里面是一件隐约可见的格子衬衫,显得既经典又庄重。他手里拿着一个小物件,可能是打火机,双手显得苍老,显示出岁月的痕迹。他的表情严肃而沉思,深陷的皱纹和眼中静静的反思流露出他的内心世界。光线柔和而散射,自然光透过窗户洒下,柔和的阴影洒在他的脸上和周围陈旧、有质感的墙壁上。整个画面的氛围怀旧而内省,捕捉到了一个在简单却富有感染力的环境中独自沉思的瞬间。
fal.ai (免费 | $1 免费信用)FLUX.1 schnell :
https://fal.ai/models/fal-ai/flux/schnell/playground
FLUX.1 dev :
https://fal.ai/models/fal-ai/flux/dev/playground
FLUX.1 pro:
https://fal.ai/models/fal-ai/flux-pro
登录 GitHub 后,您将获得 1 元信用,可以免费使用 FLUX.1 pro 20 次,FLUX.1 dev 40 次,或 FLUX.1 Schnell 333 次。
这里是 fal.ai 的定价表:
用户界面:
用户界面
一张名为“Finding Emo”(《寻找emo》)的电影海报的数字插图,这是对《寻找尼莫》的恶搞版本,插图中有一条忧郁的卡通小丑鱼,它有着黑色的emo发型、眼线和耳环,表情无聊,游弋在一个黑暗的水下场景中,背景中电影标题以滴水、粗糙的字体呈现,色调为忧郁的蓝色和紫色。
LiblibAI(免费300点 | 中文网站)LiblibAI 提供了两种使用 FLUX.1 的方式,使用提供的 300 分大约可以免费使用 15 次。
方法1:Web UI(每个图像消耗20点)目前,该网站提供了四个版本:
- dev-fp8 版本:最推荐的版本,速度快且稳定。
- dev 版本:也称为 fp16 版本,加载速度稍慢且容易出现内存不足的问题。
- schnell 版本:涡轮版本,性能一般;不推荐。
- VAE 版本
推荐的 WEBUI 使用设置:
- 采样方法:仅支持 FlowMatchEuler。嵌入兼容 SD1.5,但 SDXL 可能会存在问题。
- CFG 官方推荐值:3.5。
- 采样步骤:默认为 20,可根据需要增加。
常规版本至少需要32GB的系统内存。测试显示,4090 GPU可以完全占用其内存。建议使用dev-fp8版本进行本地使用。
用户界面:
一个年轻女子的详细而逼真的肖像,她留着短发,头发呈柔和的粉彩色,带有柔软的凌乱波浪。她穿着一件浅粉色的T恤,上面印有大胆的红色文字“我爱你们”。女子站在户外,背景是明亮清澈的蓝天,远处可以看到大海。光线柔和自然,使她的皮肤呈现出温和的光泽。她脸上带着思考而宁静的表情,目光投向远方,捕捉到了一个平静而内省的瞬间。整体氛围充满活力和清新,她多彩的头发增添了一丝俏皮感。
replicate(非免费)https://replicate.com/black-forest-labs
replicate 提供三种 FLUX.1 模型:FLUX.1-dev、FLUX.1-pro 和 FLUX.1-schnell,所有这些模型都需要付费。
价格表
用户界面:
一张高度详细且充满想象力的独特鸡尾酒图像,设计成类似于水族箱的样子。这款鸡尾酒是透明的,里面含有冰块,在玻璃杯内有模仿水下场景的元素:鲜艳的绿色水生植物、明亮的橙色花朵和一些小装饰物,看起来像是鱼在酒中游动。玻璃杯边缘装饰着一片薄薄的柠檬片,吸管优雅地插入饮料中。背景是一间昏暗而温暖色调的酒吧,柔和的环境灯光营造出一种舒适的氛围。整体构图富有创意且充满趣味,将调酒艺术与活泼且视觉吸引人的水下主题巧妙结合。
Flux AI图像生成器(仅FLUX.1-schnell免费提供 | 100免费积分)https://fluxaiimagegenerator.com/
目前,只有 FLUX.1-schnell 版本可以免费使用,免费生成的图片必须公开分享。注册后,您将获得 100 个免费积分,每天可使用 5 个积分。每生成一张图片会消耗 1 个积分。
价格表
用户界面
一张名为“Breaking Bread”(《烘焙人生》)的电视剧海报,这是一部以著名电视剧《绝命毒师》为灵感的恶搞剧。海报中,一位面带严肃表情的面包师穿着满是面粉的围裙,肩上挂着一根擀面杖,仿佛是武器一般。他站在一个质朴的面包店中央,周围堆满了面包、糕点和面粉袋,这些物品的摆放模仿了原剧标志性的沙漠背景。在他身后,黑板菜单上写着诸如“肉桂卷卡特尔”和“蓝莓松饼甲基苯丙胺”等商品名,暗示即将上演的烹饪混乱。面包师的表情既严肃又滑稽,仿佛他准备用他的面团和决心来征服世界。标题“Breaking Bread”以粗体、风格化的文字显示在顶部,“Breaking”用粗糙、裂纹的字体,“Bread”则用温暖的金色字体,仿佛刚出炉的面包。标语“烘焙是一场危险的游戏”位于下方,增添了充满双关语的幽默感。海报的整体色调是温暖的烘焙色调与原剧的粗糙暗色调的混合,将《绝命毒师》的紧张剧情与《烘焙人生》的轻松烹饪元素巧妙结合。
mystic (免费)提供 FLUX.1-pro、FLUX.1-dev 和 FLUX.1-schnell。
用户界面
详细、杰作、专业、大胆的色彩、令人惊叹、受Jeremy Mann和Kelly McKernan启发的摄影、30mm镜头拍摄、动作场景、HDR、血源主题、史诗氛围、女性战士面对不可能的挑战、阴郁、维多利亚时代、手持充满宇宙魔幻色彩的剑、女性化、受Agnes Cecile启发、刻有花纹的剑、蓝色发光的光环、宇宙之眼
安装 ComfyUI官方的 ComfyUI GitHub 仓库 提供了基本的安装方法指南,包括 Windows、Mac、Linux 和 Jupyter Notebook。
在本文中,我们将一步步演示安装和使用过程,以安装了Nvidia GPU的Windows系统为例。
硬件要求
ComfyUI 官方仓库地址: ComfyUI 的 GitHub 仓库
你可以在仓库的 ReadMe 部分找到 直接下载链接 的蓝色链接,点击即可下载官方整理的集成包。
解压 ComfyUI 安装的集成包到您想要的本地目录。(我推荐使用 7-Zip 来处理压缩文件)。解压后的文件目录应该如下所示:
解释 ComfyUI 目录:
ComfyUI_windows_portable
├── ComfyUI // Comfy UI 主文件夹
│ ├── .git // Git 版本控制文件夹,用于代码版本管理
│ ├── .github // GitHub Actions 工作流文件夹
│ ├── comfy //
│ ├── 📁 comfy_extras //
│ ├── 📁 custom_nodes // ComfyUI 自定义节点文件目录(插件安装目录)
│ ├── 📁 input // ComfyUI 上传文件夹,当你使用加载图像等节点时,相应的上传图像将存储在此文件夹中
│ ├── 📁 models // 对应的模型文件配置文件夹
│ | ├── 📁 checkpoints // 存储大型模型检查点文件的路径
│ | ├── 📁 clip // 存储 CLIP 文件的路径
│ | ├── 📁 clip_vision // 存储 CLIP_vision 文件的路径
│ | ├── 📁 configs
│ | ├── 📁 controlnet // 存储 ControlNet 模型文件的路径
│ | ├── 📁 diffusers
│ | ├── 📁 embedding // 存储嵌入模型文件的路径
│ | ├── 📁 gligen
│ | ├── 📁 hypernetworks // 存储超网络模型的路径
│ | ├── 📁 loras // 存储 Lora 模型文件的路径
│ | ├── 📁 style_models
│ | ├── 📁 unet
│ | ├── 📁 upscale_models // 存储上采样模型文件的路径
│ | ├── 📁 vae // 存储 VAE 模型文件的路径
│ | └── 📁 vae_approx
│ ├── 📁 notebooks
│ ├── 📁 user // ComfyUI 用户信息(如配置文件、工作流信息等)
│ ├── 📁 output // ComfyUI 图像输出文件夹,当你使用保存图像等节点时,生成的图像将存储在此文件夹中
│ ├── extra_model_paths.yaml.example // 额外模型文件路径配置文件,如果你设置了此文件,请删除 .example 后缀并使用文本编辑器编辑
│ └── ... // 其他文件
├── 📁 config // 配置文件夹
├── 📁 Python_embeded // 嵌入的 Python 文件
├── 📁 update
│ ├── update.py // ComfyUI 的 Python 脚本
│ ├── update_comfyUI.bat // ComfyUI 作者推荐的升级 ComfyUI 的批处理命令
│ └── update_comfyui_and_python_dependencies.bat // 当你的 Python 依赖文件出现问题时,请运行此批处理命令
├── comfyui.log // Comfy UI 运行日志文件
├── README_VERY_IMPORTANT.txt // README 文件,包括文件使用方法和解释等
├── run_cpu.bat // 批处理文件,双击运行此文件以启动 ComfyUI(当你的显卡是 A 卡或只有 CPU 时)
└── run_nvidia_gpu.bat // 批处理文件,双击运行此文件以启动 ComfyUI(当你的显卡是 N 卡(Nvidia)时)
让我们来看看不同版本的模型之间的差异并下载我们需要的那个。
一幅细致生动的年轻中国女性肖像,她穿着传统的汉服。她戴着一个精致的银色发冠,上面装饰着复杂的花卉图案和与她的服装相配的粉色花朵。她的头发优雅地盘起,柔软的发丝轻轻环绕着她的脸庞。这位女性面带温暖而优雅的微笑,她的妆容柔和自然,突显了她的青春美丽。她站在一片盛开的薰衣草田中,紫色的花朵营造出梦幻而浪漫的背景。阳光温柔地照亮她的脸庞,为整个宁静而迷人的氛围增添了一抹柔和的金色光泽。
FLUX.1的不同版本这里是对FLUX.1模型的不同版本的详细介绍(本部分旨在帮助您理解各个模型之间的差异;下一节将提供下载说明)
模型下载:
- Flux.1 Pro
不可下载,仅可通过API访问 FLUX.1 [pro] API,Flux.1 Pro Replicate API,Flux.1 Pro FAL AI API,Flux.1 Pro Mystic AI API
- Flux.1-dev
可供下载 Flux.1 Dev GitHub 仓库,Flux.1 Dev Hugging Face,Flux.1 Dev Replicate API,Flux.1 Dev FAL AI API,Mystic AI
- FLUX.1 Schnell
可供下载 Flux.1 Schnell GitHub 仓库、Flux.1 Schnell Hugging Face、Flux.1 Schnell Replicate API、在 FAL AI 上试用 Flux.1 Schnell、Flux.1 Schnell Mystic AI API
如需更多信息,请访问 FLUX.1 仓库:https://github.com/black-forest-labs/flux
详细、大师级、专业、大胆的色彩、令人惊叹、受Jeremy Mann启发的摄影、30毫米镜头拍摄、动作场景、HDR、穿着赛车服的桃公主在沙丘越野车上疾驰、逼真、粗糙、电影感、反乌托邦、真实的皮肤纹理、现实生活中、车前盖上写着“桃公主”、镶嵌的字体、穿着骑行皮衣、驾驶中
下载 FLUX.1 模型您可以选择下载官方原始模型或量化模型。从以下选项中选择符合您需求的一个。
5 个主流的 FLUX.1 模型版本- Black Forest Labs 官方模型
- @Kijia 发布的 FP8 版本
- ComfyUI 发布的 FP8 版本
- @Illyasviel 发布的 NF4 量化版本
- @City96 发布的 GGUF 量化版本
将下载的大型模型放入 ComfyUI\models\unet
目录。
- 如果你有16GB或更多的VRAM,官方模型无疑是最佳选择,提供最佳性能和图像质量。
- 接下来是FP8模型,这些模型比原模型小得多,可以在8GB VRAM上运行,生成关键文本和细节的质量没有明显下降。
- 然后是@lllyasviel发布的NF4量化版本。这些模型更小且生成图像更快。在WebUI forge的共享模式下,它们可以在6GB VRAM上运行。有两个版本,v1和v2,其中v2在细节和速度方面更好。
- 最后是@City96开发的三个GGUF量化版本。Q8版本的图像输出和速度比FP8更好,需要超过12GB的VRAM;Q4版本可以在8GB VRAM上运行,并且生成质量略好于NF4。
- 注意:这些量化版本的使用许可与原模型一致,即Dev不用于商业用途,而Schnell可用于商业用途。
对于大多数用户来说,流畅运行官方模型可能颇具挑战。在这里,我们可以使用其他作者优化的 FLUX.1 模型版本,以获得更好的体验。
https://huggingface.co/Kijai/flux-fp8/tree/main
在这里,我选择下载 FLUX.1 [schnell] fp8 进行测试。你可以根据需要下载模型。
- 下载了
flux1-schnell-fp8.safetensors
- 将下载的模型文件放在
ComfyUI/models/unet/
文件夹中
“fp”是什么意思?
量化是一种用于减少机器学习模型(尤其是大型语言模型)的大小和计算需求的技术。通过将高精度参数(如32位浮点数)转换为较低精度的格式(如8位整数),量化有助于减少内存使用并加速推理,同时不会显著降低模型的准确性。这一过程对于在资源受限的设备(如手机或边缘设备)上部署大型模型至关重要,从而实现更快和更高效的性能。量化通常在各种阶段中使用,包括训练后量化和量化感知训练,以实现模型效率和准确性之间的最佳平衡。
什么是UNet模型?
UNet模型是一种主要用于图像分割的卷积神经网络(CNN),其目标是对图像中的每个像素进行分类。它具有对称的编码器-解码器结构:编码器通过逐步下采样输入图像来捕获上下文信息,而解码器则通过上采样重建图像,以获得精确的像素级细节。该模型的关键创新在于使用了跳过连接,这些连接将编码器和解码器中的相应层链接起来,使其能够保留和结合高层次和低层次的特征,这对于准确的分割和其他像素级预测任务至关重要。
威廉·莎士比亚坐在伦敦南部萨瑟克一座都铎时期的房屋中一间简陋的房间里,他正用鹅毛笔在纸上写作,借着烛光,他的脸上带着自信和满足的表情,确信自己正在创作一部杰作(当然他确实如此),这是16世纪晚期的英格兰,具有真实的历史细节。
下载 ComfyUI CLIP 模型ComfyUI FLUX.1 文本编码器在 Hugging Face
下载链接:
步骤:
- 下载
clip_l.safetensors
- 根据你的VRAM和RAM下载
t5xxl_fp8_e4m3fn.safetensors
或t5xxl_fp16.safetensors
- 将下载的模型文件放入
ComfyUI/models/clip/
文件夹中。
注意:如果你之前使用过SD 3 Medium,你可能已经拥有上述两个模型了。
什么是CLIP?
ComfyUI Clip 是基于阿里云 M6 的开源预训练大型模型,专注于自然语言处理任务,如文本理解、代码分析和生成。在此上下文中,“语义分割”通常指的是模型理解并识别输入文本不同部分含义的能力,例如解析文档结构或在代码块中识别函数和变量名等元素。ComfyUI Clip 利用深度学习技术高效地从文本中提取关键信息,支持各种应用场景中的定制任务。
CLIP(对比语言-图像预训练)是由 OpenAI 在 2021 年发布的预训练视觉-语言模型。该模型通过无监督学习从大量的互联网图像和文本对中学习,即使没有特定领域的标注数据,也能理解图像内容并将其与自然语言描述关联起来。CLIP 模型的核心思想是将图像和文本映射到一个共享的高维向量空间,使得相似的文本描述和相应的图像在这个空间中更接近。
在语义分割任务中,CLIP 可以作为特征提取器,根据文本描述为输入图像生成语义相关的分割图。这种能力在图像理解和自动驾驶等领域非常有用。用户可以利用其跨模态能力来指导分割任务;例如,输入关于“猫”的文本,然后指导如何区分猫脸与其他部分。
什么是T5XXL?
T5XXL 是由 Google 设计的 Text-To-Text Transfer Transformer (T5) 模型的最大变体,适用于各种自然语言处理任务。拥有数十亿参数的 T5XXL 在翻译、摘要、问答、文本生成甚至代码补全等任务中表现出色,通过将所有任务视为文本到文本的问题来实现。其庞大的规模使其能够捕捉语言中的复杂模式和细微差别,使其成为 T5 家族中最强大的模型之一。尽管其资源消耗较大,T5XXL 仍广泛应用于需要高精度和复杂语言理解的研究和工业应用领域,特别是在需要细微语言理解的关键领域。
清晨的竹林中的宁静池塘,太阳刚刚开始从地平线上升起,熊猫在池塘边缘练习太极,晨雾中的大气透视效果,透过阳光的光线,它的动作优雅流畅——营造出和谐与平衡的感觉,池塘平静的水面映照出这一切,让人感到冥想和与自然的连接,霍华德·特彭宁和杰西卡·罗西尔的风格,lora:other/flux_realism_lora:1.0
下载 FLUX.1 VAE 模型- 下载了
ae.safetensors
模型。 - 将下载的模型文件放在
ComfyUI/models/vae
文件夹中。 - 为了便于识别,你可以将其重命名为
flux_ae.safetensors
;
什么是VAE模型?
变分自编码器(VAE)是一种用于生成与给定数据集相似的新数据的深度学习模型。它通过将输入数据压缩成一个表示为概率分布的低维潜在空间,然后从该分布中采样来重构原始数据。这使得VAE能够生成多样化的输出,因此在图像生成、数据插补和异常检测等任务中非常有用。通过学习数据的底层分布,VAE可以以结构化和概率化的方式生成新的、相似的数据点。
一幅令人惊叹的女性肖像,她身穿传统的、装饰华丽的红色和金色服装。她有着长长的、飘逸的黑色长发,上面装饰着精致的金色发饰。一条雄伟的红色巨龙缠绕在她的身上,龙头靠近她的肩膀,散发出一种力量和神秘的气息。巨龙的鳞片细节丰富,闪耀着光芒,它的眼睛闪烁着强烈的绿色光芒。背景应该暗淡而忧郁,突显场景的戏剧性和庄严氛围,而女性的表情则流露出平静的自信。
在 ComfyUI 上运行 FLUX.1在 ComfyUI_windows_portable
目录中,你可以看到两个文件 run_cpu.bat
和 run_nvidia_gpu.bat
,你可以根据以下说明选择运行。
ComfyUI_windows_portable
├── ...其他文件被省略
├── run_cpu.bat // 双击运行它,在你使用的是集成显卡或仅使用CPU时启动ComfyUI
└── run_nvidia_gpu.bat // 双击运行它,在你使用的是N卡(Nvidia显卡)时启动ComfyUI
如果你遇到以下错误:
PermissionError: [Errno 13] 在尝试绑定到地址 ('127.0.0.1', 8188) 时出错:尝试以其访问权限禁止的方式访问套接字
你可以尝试以管理员权限打开CMD并执行以下命令:
net stop winnat
net start winnat
然后再次运行启动脚本。
如上图所示,当你看到“要查看GUI,请访问:http://127.0.0.1:8188”
这意味着 ComfyUI 已成功启动。如果浏览器没有正常启动,可以通过浏览器直接访问 To See the GUI go to:
后面的网址,例如上面的例子中应该是 http://127.0.0.1:8188。
打开的网页如下:
这是默认的工作流程。让我们先不要关闭任何页面,继续进行下一步。
美丽的25岁女性,拥有晒黑的皮肤和深邃的特征,站在雨中的桥上,背景是赛博朋克的城市景观,穿着黑色高领毛衣和蓝色皮夹克,白色牛仔裤,绿色和橙色的水花,角色周围有粗线条
选择 FLUX.1 ComfyUI 工作流示例在 ComfyUI 中构建工作流是一个需要花费大量时间和学习的过程。如果你更喜欢一种更直接且易于使用的体验,使用模板是最好的选择。本文不会深入讲解如何构建工作流,而是会提供一些可以直接运行的示例。
从下面选择你需要的工作流示例,复制代码,并将其保存为 json
文件(你可以将代码粘贴到 txt
文件中,保存后将文件扩展名从 txt
改为 json
)。如果你不确定选择哪一个,可以选择第一个。
回到你之前打开的工作流界面网页(如果没有打开,请参阅之前的章节)。在主界面上,点击右侧的 加载
按钮以加载工作流文件。
后来在文章中,我们还将包含预设好的 LoRA 和 ControlNet 工作流。
查找更多工作流示例,请访问: https://openart.ai/workflows/all?keyword=flux
FLUX.1 Dev ComfyUI 工作流示例 {"last_node_id":37,"last_link_id":116,"nodes":
[{"id":11,"type":"DualCLIPLoader","pos":[48,288],"size":
{"0":315,"1":106},"flags":{},"order":0,"mode":0,"outputs":
[{"name":"CLIP","type":"CLIP","links":
[10],"shape":3,"slot_index":0,"label":"CLIP"}],"properties":{"Node
name for S&R":"DualCLIPLoader"},"widgets_values":
["t5xxl_fp16.safetensors","clip_l.safetensors","flux"]},
{"id":17,"type":"BasicScheduler","pos":[480,1008],"size":{"0":315,"1":106},"flags":{},"order":13,"mode":0,"inputs":[{"name":"model","type":"MODEL","link":55,"slot_index":0,"label":"model"}],"outputs":[{"name":"SIGMAS","type":"SIGMAS","links":[20],"shape":3,"label":"SIGMAS"}],"properties":{"Node name for S&R":"BasicScheduler"},"widgets_values":["simple",20,1]},{"id":16,"type":"KSamplerSelect","pos":[480,912],"size":{"0":315,"1":58},"flags":{},"order":1,"mode":0,"outputs":[{"name":"SAMPLER","type":"SAMPLER","links":[19],"shape":3,"label":"SAMPLER"}],"properties":{"Node name for S&R":"KSamplerSelect"},"widgets_values":["euler"]},{"id":26,"type":"FluxGuidance","pos":[480,144],"size":{"0":317.4000244140625,"1":58},"flags":{},"order":12,"mode":0,"inputs":[{"name":"conditioning","type":"CONDITIONING","link":41,"label":"conditioning"}],"outputs":[{"name":"CONDITIONING","type":"CONDITIONING","links":[42],"shape":3,"slot_index":0,"label":"CONDITIONING"}],"properties":{"Node name for S&R":"FluxGuidance"},"widgets_values":[3.5],"color":"#233","bgcolor":"#355"},{"id":22,"type":"BasicGuider","pos":[576,48],"size":{"0":222.3482666015625,"1":46},"flags":{},"order":14,"mode":0,"inputs":[{"name":"model","type":"MODEL","link":54,"slot_index":0,"label":"model"},{"name":"conditioning","type":"CONDITIONING","link":42,"slot_index":1,"label":"conditioning"}],"outputs":[{"name":"GUIDER","type":"GUIDER","links":[30],"shape":3,"slot_index":0,"label":"GUIDER"}],"properties":{"Node name for S&R":"BasicGuider"}},{"id":13,"type":"SamplerCustomAdvanced","pos":[864,192],"size":{"0":272.3617858886719,"1":124.53733825683594},"flags":{},"order":15,"mode":0,"inputs":[{"name":"noise","type":"NOISE","link":37,"slot_index":0,"label":"noise"},{"name":"guider","type":"GUIDER","link":30,"slot_index":1,"label":"guider"},{"name":"sampler","type":"SAMPLER","link":19,"slot_index":2,"label":"sampler"},{"name":"sigmas","type":"SIGMAS","link":20,"slot_index":3,"label":"sigmas"},{"name":"latent_image","type":"LATENT","link":116,"slot_index":4,"label":"latent_image"}],"outputs":[{"name":"output","type":"LATENT","links":[24],"shape":3,"slot_index":0,"label":"output"},{"name":"denoised_output","type":"LATENT","links":null,"shape":3,"label":"denoised_output"}],"properties":{"Node name for S&R":"SamplerCustomAdvanced"}},{"id":25,"type":"RandomNoise","pos":[480,768],"size":{"0":315,"1":82},"flags":{},"order":2,"mode":0,"outputs":[{"name":"NOISE","type":"NOISE","links":[37],"shape":3,"label":"NOISE"}],"properties":{"Node name for S&R":"RandomNoise"},"widgets_values":[219670278747233,"randomize"],"color":"#2a363b","bgcolor":"#3f5159"},{"id":8,"type":"VAEDecode","pos":[866,367],"size":{"0":210,"1":46},"flags":{},"order":16,"mode":0,"inputs":[{"name":"samples","type":"LATENT","link":24,"label":"samples"},{"name":"vae","type":"VAE","link":12,"label":"vae"}],"outputs":[{"name":"IMAGE","type":"IMAGE","links":[9],"slot_index":0,"label":"IMAGE"}],"properties":{"Node name for S&R":"VAEDecode"}},{"id":6,"type":"CLIPTextEncode","pos":[384,240],"size":{"0":422.84503173828125,"1":164.31304931640625},"flags":{},"order":9,"mode":0,"inputs":[{"name":"clip","type":"CLIP","link":10,"label":"clip"}],"outputs":[{"name":"CONDITIONING","type":"CONDITIONING","links":[41],"slot_index":0,"label":"CONDITIONING"}],"title":"CLIP Text Encode (Positive Prompt)","properties":{"Node name for S&R":"CLIPTextEncode"},"widgets_values":["cute anime girl with massive fluffy fennec ears and a big fluffy tail blonde messy long hair blue eyes wearing a maid outfit with a long black gold leaf pattern dress and a white apron mouth open holding a fancy black forest cake with candles on top in the kitchen of an old dark Victorian mansion lit by candlelight with a bright window to the foggy forest and very expensive stuff everywhere"],"color":"#232","bgcolor":"#353"},{"id":30,"type":"ModelSamplingFlux","pos":[480,1152],"size":{"0":315,"1":130},"flags":{},"order":11,"mode":0,"inputs":[{"name":"model","type":"MODEL","link":56,"slot_index":0,"label":"model"},{"name":"width","type":"INT","link":115,"widget":{"name":"width"},"slot_index":1,"label":"width"},{"name":"height","type":"INT","link":114,"widget":{"name":"height"},"slot_index":2,"label":"height"}],"outputs":[{"name":"MODEL","type":"MODEL","links":[54,55],"shape":3,"slot_index":0,"label":"MODEL"}],"properties":{"Node name for S&R":"ModelSamplingFlux"},"widgets_values":[1.15,0.5,1024,1024]},{"id":27,"type":"EmptySD3LatentImage","pos":[480,624],"size":{"0":315,"1":106},"flags":{},"order":10,"mode":0,"inputs":[{"name":"width","type":"INT","link":112,"widget":{"name":"width"},"label":"width"},{"name":"height","type":"INT","link":113,"widget":{"name":"height"},"label":"height"}],"outputs":[{"name":"LATENT","type":"LATENT","links":[116],"shape":3,"slot_index":0,"label":"LATENT"}],"properties":{"Node name for S&R":"EmptySD3LatentImage"},"widgets_values":[1024,1024,1]},{"id":34,"type":"PrimitiveNode","pos":[432,480],"size":{"0":210,"1":82},"flags":{},"order":3,"mode":0,"outputs":[{"name":"INT","type":"INT","links":[112,115],"slot_index":0,"widget":{"name":"width"},"label":"INT"}],"title":"width","properties":{"Run widget replace on values":false},"widgets_values":[1024,"fixed"],"color":"#323","bgcolor":"#535"},{"id":35,"type":"PrimitiveNode","pos":[672,480],"size":{"0":210,"1":82},"flags":{},"order":4,"mode":0,"outputs":[{"name":"INT","type":"INT","links":[113,114],"widget":{"name":"height"},"slot_index":0,"label":"INT"}],"title":"height","properties":{"Run widget replace on values":false},"widgets_values":[1024,"fixed"],"color":"#323","bgcolor":"#535"},{"id":12,"type":"UNETLoader","pos":[48,144],"size":{"0":315,"1":82},"flags":{},"order":5,"mode":0,"outputs":[{"name":"MODEL","type":"MODEL","links":[56],"shape":3,"slot_index":0,"label":"MODEL"}],"properties":{"Node name for S&R":"UNETLoader"},"widgets_values":["flux1-dev.safetensors","default"],"color":"#223","bgcolor":"#335"},{"id":9,"type":"SaveImage","pos":[1155,196],"size":{"0":985.3012084960938,"1":1060.3828125},"flags":{},"order":17,"mode":0,"inputs":[{"name":"images","type":"IMAGE","link":9,"label":"images"}],"properties":{},"widgets_values":["ComfyUI"]},{"id":37,"type":"Note","pos":[480,1344],"size":{"0":314.99755859375,"1":117.98363494873047},"flags":{},"order":6,"mode":0,"properties":{"text":""},"widgets_values":["The reference sampling implementation auto adjusts the shift value based on the resolution, if you don't want this you can just bypass (CTRL-B) this ModelSamplingFlux node.\n"],"color":"#432","bgcolor":"#653"},{"id":10,"type":"VAELoader","pos":[48,432],"size":{"0":311.81634521484375,"1":60.429901123046875},"flags":{},"order":7,"mode":0,"outputs":[{"name":"VAE","type":"VAE","links":[12],"shape":3,"slot_index":0,"label":"VAE"}],"properties":{"Node name for S&R":"VAELoader"},"widgets_values":["ae.safetensors"]},{"id":28,"type":"Note","pos":[48,576],"size":{"0":336,"1":288},"flags":{},"order":8,"mode":0,"properties":{"text":""},"widgets_values":["If you get an error in any of the nodes above make sure the files are in the correct directories.\n\nSee the top of the examples page for the links : https://comfyanonymous.github.io/ComfyUI_examples/flux/\n\nflux1-dev.safetensors goes in: ComfyUI/models/unet/\n\nt5xxl_fp16.safetensors and clip_l.safetensors go in: ComfyUI/models/clip/\n\nae.safetensors goes in: ComfyUI/models/vae/\n\n\nTip: You can set the weight_dtype above to one of the fp8 types if you have memory issues."],"color":"#432","bgcolor":"#653"}],"links":[[9,8,0,9,0,"IMAGE"],[10,11,0,6,0,"CLIP"],[12,10,0,8,1,"VAE"],[19,16,0,13,2,"SAMPLER"],[20,17,0,13,3,"SIGMAS"],[24,13,0,8,0,"LATENT"],[30,22,0,13,1,"GUIDER"],[37,25,0,13,0,"NOISE"],[41,6,0,26,0,"CONDITIONING"],[42,26,0,22,1,"CONDITIONING"],[54,30,0,22,0,"MODEL"],[55,30,0,17,0,"MODEL"],[56,12,0,30,0,"MODEL"],[112,34,0,27,0,"INT"],[113,35,0,27,1,"INT"],[114,35,0,30,2,"INT"],[115,34,0,30,1,"INT"],[116,27,0,13,4,"LATENT"]],"groups":[],"config":{},"extra":{"ds":{"scale":1.1,"offset":[-0.17937541249087297,2.2890951150661545]},"groupNodes":{}},"version":0.4}
FLUX.1 Schnell ComfyUI 工作流示例
{"last_node_id":36,"last_link_id":58,"nodes":[{"id":33,"type":"CLIPTextEncode","pos":[390,400],"size":{"0":422.84503173828125,"1":164.31304931640625},"flags":{"collapsed":true},"order":4,"mode":0,"inputs":[{"name":"clip","type":"CLIP","link":54,"slot_index":0,"label":"clip"}],"outputs":[{"name":"CONDITIONING","type":"CONDITIONING","links":[55],"slot_index":0,"label":"CONDITIONING"}],"title":"CLIP 文本编码(负提示)","properties":{"Node name for S&R":"CLIPTextEncode"},"widgets_values":[""],"color":"#322","bgcolor":"#533"},{"id":27,"type":"EmptySD3LatentImage","pos":[471,455],"size":{"0":315,"1":106},"flags":{},"order":0,"mode":0,"outputs":[{"name":"LATENT","type":"LATENT","links":[51],"shape":3,"slot_index":0,"label":"LATENT"}],"properties":{"Node name for S&R":"EmptySD3LatentImage"},"widgets_values":[1024,1024,1],"color":"#323","bgcolor":"#535"},{"id":8,"type":"VAEDecode","pos":[1151,195],"size":{"0":210,"1":46},"flags":{},"order":6,"mode":0,"inputs":[{"name":"samples","type":"LATENT","link":52,"label":"samples"},{"name":"vae","type":"VAE","link":46,"label":"vae"}],"outputs":[{"name":"IMAGE","type":"IMAGE","links":[9],"slot_index":0,"label":"IMAGE"}],"properties":{"Node name for S&R":"VAEDecode"}},{"id":9,"type":"SaveImage","pos":[1375,194],"size":{"0":985.3012084960938,"1":1060.3828125},"flags":{},"order":7,"mode":0,"inputs":[{"name":"images","type":"IMAGE","link":9,"label":"images"}],"properties":{},"widgets_values":["ComfyUI"]},{"id":31,"type":"KSampler","pos":[816,192],"size":{"0":315,"1":262},"flags":{},"order":5,"mode":0,"inputs":[{"name":"model","type":"MODEL","link":47,"label":"model"},{"name":"positive","type":"CONDITIONING","link":58,"label":"positive"},{"name":"negative","type":"CONDITIONING","link":55,"label":"negative"},{"name":"latent_image","type":"LATENT","link":51,"label":"latent_image"}],"outputs":[{"name":"LATENT","type":"LATENT","links":[52],"shape":3,"slot_index":0,"label":"LATENT"}],"properties":{"Node name for S&R":"KSampler"},"widgets_values":[173805153958730,"randomize",4,1,"euler","simple",1]},{"id":30,"type":"CheckpointLoaderSimple","pos":[48,192],"size":{"0":315,"1":98},"flags":{},"order":1,"mode":0,"outputs":[{"name":"MODEL","type":"MODEL","links":[47],"shape":3,"slot_index":0,"label":"MODEL"},{"name":"CLIP","type":"CLIP","links":[45,54],"shape":3,"slot_index":1,"label":"CLIP"},{"name":"VAE","type":"VAE","links":[46],"shape":3,"slot_index":2,"label":"VAE"}],"properties":{"Node name for S&R":"CheckpointLoaderSimple"},"widgets_values":["flux1-schnell-fp8.safetensors"]},{"id":6,"type":"CLIPTextEncode","pos":[384,192],"size":{"0":422.84503173828125,"1":164.31304931640625},"flags":{},"order":3,"mode":0,"inputs":[{"name":"clip","type":"CLIP","link":45,"label":"clip"}],"outputs":[{"name":"CONDITIONING","type":"CONDITIONING","links":[58],"slot_index":0,"label":"CONDITIONING"}],"title":"CLIP 文本编码(正提示)","properties":{"Node name for S&R":"CLIPTextEncode"},"widgets_values":["一个装有美丽彩虹星系的瓶子放在现代厨房中央的木桌上,旁边放着一盘蔬菜和蘑菇,以及一个装有地球的酒杯,酒杯里放着一个未吃完的苹果派"],"color":"#232","bgcolor":"#353"},{"id":34,"type":"Note","pos":[831,501],"size":{"0":282.8617858886719,"1":164.08004760742188},"flags":{},"order":2,"mode":0,"properties":{"text":""},"widgets_values":["注意,FLUX dev 和 schnell 没有负提示,因此 CFG 应设置为 1.0。将 CFG 设置为 1.0 意味着负提示将被忽略。\n\nschnell 模型是一个经过蒸馏的模型,仅需 4 步即可生成良好的图像。"],"color":"#432","bgcolor":"#653"}],"links":[[9,8,0,9,0,"IMAGE"],[45,30,1,6,0,"CLIP"],[46,30,2,8,1,"VAE"],[47,30,0,31,0,"MODEL"],[51,27,0,31,3,"LATENT"],[52,31,0,8,0,"LATENT"],[54,30,1,33,0,"CLIP"],[55,33,0,31,2,"CONDITIONING"],[58,6,0,31,1,"CONDITIONING"]],"groups":[],"config":{},"extra":{"ds":{"scale":1.1,"offset":[1.1666219579074508,1.8290357611967831]}},"version":0.4}
一旦工作流加载完毕,它将看起来像下面的图片:
请注意,工作流模板中的配置可能与您的实际设置不同。请仔细检查并编辑图像下方左侧的 加载扩散模型
、DualCLIPLoader
和 加载VAE
部分中的模型选择信息,以确保您使用的是刚刚下载的版本。
在右侧的绿色框中输入您的提示,然后点击浮动工具栏上的 Queue Prompt
开始生成图像。如果有任何错误,请检查变红的节点的配置以确保它们正确无误。
此时,您可以使用各种版本的FLUX模型来生成图像。下面展示了一个使用FLUX Schnell FP8模型生成的图像示例:
一个超现实的场景,一个男人骑在鲨鱼背上快速穿越海洋。男人悠然自得地吃着汉堡,同时紧紧抓住鲨鱼。视角应该来自望远镜,给人一种遥远且被放大了的感觉。海洋应该广阔无垠,波浪在快速游动的鲨鱼周围翻滚,天空应该晴朗明亮,增添了这一不寻常且充满冒险的时刻的对比感。
双曝光照片中,一只脆弱的蝴蝶在抽象、超现实的背景中浮现。蝴蝶的翅膀以生动逼真的细节呈现,翅膀上的细小脉络和花纹在背景的漩涡和线条中清晰可见。背景本身具有梦幻般的质感,色彩和形状交织成既混乱又迷人的景象。
LoRA(高级用法)这里有一个网站,你可以在线体验 FLUX.1 LoRA 模型:
https://huggingface.co/spaces/multimodalart/flux-lora-the-explorer
LoRA(低秩适应)在文本到图像生成中用于对像Stable Diffusion这样的大型预训练模型进行微调,而所需的计算成本要小得多。通过仅修改模型参数中的一小部分低秩子集,LoRA使模型能够根据提供的文本提示适应特定的风格、主题或领域,而无需重新训练整个模型。
假设你有一个预训练的文本到图像模型,并希望它生成特定艺术风格的图像,比如“梵高风格的风景画”。而不是重新训练整个模型,这会耗费大量资源,你可以使用LoRA在一组较小的梵高风格图像和相关文本描述的数据集上进行微调。这使得模型能够学习这种风格的细微差别,并将其应用于新的文本提示,从而生成具有所需艺术特征的图像。
下载LoRA模型FLUX.1 LoRA 和其他资源,你可以在这里下载:
在这里,我们选择由 XLabs-AI 团队创建的 LoRA:
https://huggingface.co/XLabs-AI/flux-lora-collection/tree/main
目前,XLabs 已经发布了 7 个适用于 FLUX.1 的 LoRA 模型,包括 Anime、Art、Disney、MJV6、Plush、Realistic 和 Scenery。使用 comfy_converted
下载所需的 LoRA 模型文件,并将其放置在 ComfyUI\models\loras
目录中。
LoRA 工作流对于没有
_comfy_converted_
的LoRA模型,你需要安装_x-flux-comfyui_
插件,并将它们放在_ComfyUI/models/xlabs/loras_
目录中以使用它们。
当在 ComfyUI 中使用 FLUX.1 LoRA 时,有两种不同的工作流程可供选择:一种是基于原生工作流程,其中主模型存储在 Unet 文件夹中;另一种是简化的工作流程,适用于 ComfyUI 发布的 fp8 模型,其中主模型放置在 checkpoints 文件夹中。
原生工作流:
{"last_node_id":89,"last_link_id":125,"nodes":[{"id":12,"type":"UNETLoader","pos":[44,101],"size":[326.5508155800454,82],"flags":{},"order":0,"mode":0,"outputs":[{"name":"MODEL","type":"MODEL","links":[107],"slot_index":0,"shape":3,"label":"MODEL"}],"properties":{"Node name for S&R":"UNETLoader"},"widgets_values":["flux1-dev-fp8-kijai.safetensors","fp8_e4m3fn"]},{"id":11,"type":"DualCLIPLoader","pos":[37,245],"size":[324.94479196498867,106.7058248015365],"flags":{},"order":1,"mode":0,"outputs":[{"name":"CLIP","type":"CLIP","links":[108],"slot_index":0,"shape":3,"label":"CLIP"}],"properties":{"Node name for S&R":"DualCLIPLoader"},"widgets_values":["t5xxl_fp8_e4m3fn.safetensors","clip_l.safetensors","flux"]},{"id":85,"type":"CR SDXL Aspect Ratio","pos":[34,408],"size":{"0":329.5428161621094,"1":278.98809814453125},"flags":{},"order":2,"mode":0,"outputs":[{"name":"width","type":"INT","links":[122],"slot_index":0,"shape":3,"label":"width"},{"name":"height","type":"INT","links":[123],"slot_index":1,"shape":3,"label":"height"},{"name":"upscale_factor","type":"FLOAT","links":null,"shape":3,"label":"upscale_factor"},{"name":"batch_size","type":"INT","links":null,"shape":3,"label":"batch_size"},{"name":"empty_latent","type":"LATENT","links":[124],"slot_index":4,"shape":3,"label":"empty_latent"},{"name":"show_help","type":"STRING","links":null,"shape":3,"label":"show_help"}],"properties":{"Node name for S&R":"CR SDXL Aspect Ratio"},"widgets_values":[512,768,"custom","Off",1,1]},{"id":25,"type":"RandomNoise","pos":[1022,95],"size":{"0":285.3142395019531,"1":83.42333221435547},"flags":{},"order":3,"mode":0,"outputs":[{"name":"NOISE","type":"NOISE","links":[37],"shape":3,"label":"NOISE"}],"properties":{"Node name for S&R":"RandomNoise"},"widgets_values":[599336083703690,"randomize"]},{"id":22,"type":"BasicGuider","pos":[1028,225],"size":{"0":260,"1":60},"flags":{"collapsed":false},"order":12,"mode":0,"inputs":[{"name":"model","type":"MODEL","link":94,"slot_index":0,"label":"model"},{"name":"conditioning","type":"CONDITIONING","link":87,"slot_index":1,"label":"conditioning"}],"outputs":[{"name":"GUIDER","type":"GUIDER","links":[30],"slot_index":0,"shape":3,"label":"GUIDER"}],"properties":{"Node name for S&R":"BasicGuider"}},{"id":16,"type":"KSamplerSelect","pos":[1033,332],"size":{"0":260,"1":60},"flags":{},"order":4,"mode":0,"outputs":[{"name":"SAMPLER","type":"SAMPLER","links":[19],"shape":3,"label":"SAMPLER"}],"properties":{"Node name for S&R":"KSamplerSelect"},"widgets_values":["dpmpp_2m"]},{"id":10,"type":"VAELoader","pos":[1338,102],"size":{"0":230,"1":60},"flags":{},"order":5,"mode":0,"outputs":[{"name":"VAE","type":"VAE","links":[12],"slot_index":0,"shape":3,"label":"VAE"}],"properties":{"Node name for S&R":"VAELoader"},"widgets_values":["flux_ae.sft"]},{"id":88,"type":"Reroute","pos":[509,400],"size":[75,26],"flags":{},"order":8,"mode":0,"inputs":[{"name":"","type":"*","link":124,"label":""}],"outputs":[{"name":"","type":"LATENT","links":[125],"slot_index":0,"label":""}],"properties":{"showOutputText":false,"horizontal":false}},{"id":13,"type":"SamplerCustomAdvanced","pos":[1339,223],"size":{"0":240,"1":326},"flags":{},"order":13,"mode":0,"inputs":[{"name":"noise","type":"NOISE","link":37,"slot_index":0,"label":"noise"},{"name":"guider","type":"GUIDER","link":30,"slot_index":1,"label":"guider"},{"name":"sampler","type":"SAMPLER","link":19,"slot_index":2,"label":"sampler"},{"name":"sigmas","type":"SIGMAS","link":20,"slot_index":3,"label":"sigmas"},{"name":"latent_image","type":"LATENT","link":125,"slot_index":4,"label":"latent_image"}],"outputs":[{"name":"output","type":"LATENT","links":[24],"slot_index":0,"shape":3,"label":"output"},{"name":"denoised_output","type":"LATENT","links":null,"shape":3,"label":"denoised_output"}],"properties":{"Node name for S&R":"SamplerCustomAdvanced"}},{"id":8,"type":"VAEDecode","pos":[1367,603],"size":{"0":140,"1":50},"flags":{},"order":14,"mode":0,"inputs":[{"name":"samples","type":"LATENT","link":24,"label":"samples"},{"name":"vae","type":"VAE","link":12,"label":"vae"}],"outputs":[{"name":"IMAGE","type":"IMAGE","links":[9],"slot_index":0,"label":"IMAGE"}],"properties":{"Node name for S&R":"VAEDecode"}},{"id":9,"type":"SaveImage","pos":[484,480],"size":[438.85816905239017,570.8073824148398],"flags":{},"order":15,"mode":0,"inputs":[{"name":"images","type":"IMAGE","link":9,"label":"images"}],"properties":{"Node name for S&R":"SaveImage"},"widgets_values":["MarkuryFLUX"]},{"id":60,"type":"FluxGuidance","pos":[750,309],"size":{"0":211.60000610351562,"1":60},"flags":{},"order":10,"mode":0,"inputs":[{"name":"conditioning","type":"CONDITIONING","link":86,"label":"conditioning"}],"outputs":[{"name":"CONDITIONING","type":"CONDITIONING","links":[87],"slot_index":0,"shape":3,"label":"CONDITIONING"}],"properties":{"Node name for S&R":"FluxGuidance"},"widgets_values":[3.5],"color":"#323","bgcolor":"#535"},{"id":61,"type":"ModelSamplingFlux","pos":[746,116],"size":{"0":240,"1":122},"flags":{},"order":9,"mode":0,"inputs":[{"name":"model","type":"MODEL","link":106,"label":"model"},{"name":"width","type":"INT","link":122,"widget":{"name":"width"},"label":"width"},{"name":"height","type":"INT","link":123,"widget":{"name":"height"},"label":"height"}],"outputs":[{"name":"MODEL","type":"MODEL","links":[93,94],"slot_index":0,"shape":3,"label":"MODEL"}],"properties":{"Node name for S&R":"ModelSamplingFlux"},"widgets_values":[1.15,0.5,1024,1024]},{"id":17,"type":"BasicScheduler","pos":[998,477],"size":{"0":260,"1":110},"flags":{},"order":11,"mode":0,"inputs":[{"name":"model","type":"MODEL","link":93,"slot_index":0,"label":"model"}],"outputs":[{"name":"SIGMAS","type":"SIGMAS","links":[20],"shape":3,"label":"SIGMAS"}],"properties":{"Node name for S&R":"BasicScheduler"},"widgets_values":["sgm_uniform",25,1]},{"id":72,"type":"LoraLoaderModelOnly","pos":[407,109],"size":{"0":310,"1":82},"flags":{},"order":6,"mode":0,"inputs":[{"name":"model","type":"MODEL","link":107,"label":"model"}],"outputs":[{"name":"MODEL","type":"MODEL","links":[106],"slot_index":0,"shape":3,"label":"MODEL"}],"properties":{"Node name for S&R":"LoraLoaderModelOnly"},"widgets_values":["flux_realism_lora.safetensors",0.6]},{"id":6,"type":"CLIPTextEncode","pos":[411,269],"size":[294.2174415566078,103.19063606418729],"flags":{"collapsed":false},"order":7,"mode":0,"inputs":[{"name":"clip","type":"CLIP","link":108,"label":"clip"}],"outputs":[{"name":"CONDITIONING","type":"CONDITIONING","links":[86],"slot_index":0,"label":"CONDITIONING"}],"properties":{"Node name for S&R":"CLIPTextEncode"},"widgets_values":["a dog in the park, in the style of TOK a trtcrd, tarot style"],"color":"#232","bgcolor":"#353"}],"links":[[9,8,0,9,0,"IMAGE"],[12,10,0,8,1,"VAE"],[19,16,0,13,2,"SAMPLER"],[20,17,0,13,3,"SIGMAS"],[24,13,0,8,0,"LATENT"],[30,22,0,13,1,"GUIDER"],[37,25,0,13,0,"NOISE"],[86,6,0,60,0,"CONDITIONING"],[87,60,0,22,1,"CONDITIONING"],[93,61,0,17,0,"MODEL"],[94,61,0,22,0,"MODEL"],[106,72,0,61,0,"MODEL"],[107,12,0,72,0,"MODEL"],[108,11,0,6,0,"CLIP"],[122,85,0,61,1,"INT"],[123,85,1,61,2,"INT"],[124,85,4,88,0,"*"],[125,88,0,13,4,"LATENT"]],"groups":[],"config":{},"extra":{"ds":{"scale":1.1,"offset":[259.026128468271,8.068685322077368]}},"version":0.4}
此工作流需要使用https://github.com/pythongosssss/ComfyUI-Custom-Scripts。
克隆仓库: git clone https://github.com/pythongosssss/ComfyUI-Custom-Scripts.git
到你的 ComfyUI custom_nodes
目录。脚本将会自动安装所有自定义脚本和节点。它将尝试使用符号链接和连接来避免复制文件并保持文件的最新状态。
克隆完成后,重启 ComfyUI 以使更改生效。
简化工作流:
{"last_node_id":20,"last_link_id":23,"nodes":[{"id":10,"type":"CLIPTextEncode","pos":[98,-17],"size":{"0":285.6000061035156,"1":135.63133239746094},"flags":{},"order":5,"mode":0,"inputs":[{"name":"clip","type":"CLIP","link":22,"label":"clip"}],"outputs":[{"name":"CONDITIONING","type":"CONDITIONING","links":[19],"slot_index":0,"label":"CONDITIONING"}],"title":"CLIP 文本编码(正向提示)","properties":{"Node name for S&R":"CLIPTextEncode"},"widgets_values":["一个可口可乐罐 \"神圣的圣水\" 阿卡纳,以TOK的风格,trtcrd,塔罗牌风格"],"color":"#232","bgcolor":"#353"},{"id":11,"type":"VAEDecode","pos":[882,-390],"size":{"0":210,"1":46},"flags":{},"order":8,"mode":0,"inputs":[{"name":"samples","type":"LATENT","link":11,"label":"samples"},{"name":"vae","type":"VAE","link":12,"label":"vae"}],"outputs":[{"name":"IMAGE","type":"IMAGE","links":[13],"slot_index":0,"label":"IMAGE"}],"properties":{"Node name for S&R":"VAEDecode"}},{"id":12,"type":"SaveImage","pos":[751,-266],"size":{"0":377.812744140625,"1":626.8323974609375},"flags":{},"order":9,"mode":0,"inputs":[{"name":"images","type":"IMAGE","link":13,"label":"images"}],"properties":{},"widgets_values":["ComfyUI"]},{"id":13,"type":"EmptySD3LatentImage","pos":[468,-273],"size":{"0":218.44395446777344,"1":106},"flags":{},"order":0,"mode":0,"outputs":[{"name":"LATENT","type":"LATENT","links":[17],"slot_index":0,"shape":3,"label":"LATENT"}],"properties":{"Node name for S&R":"EmptySD3LatentImage"},"widgets_values":[512,768,1],"color":"#323","bgcolor":"#535"},{"id":14,"type":"CheckpointLoaderSimple","pos":[102,-386],"size":{"0":307.93389892578125,"1":98},"flags":{},"order":1,"mode":0,"outputs":[{"name":"MODEL","type":"MODEL","links":[20],"slot_index":0,"shape":3,"label":"MODEL"},{"name":"CLIP","type":"CLIP","links":[18,23],"slot_index":1,"shape":3,"label":"CLIP"},{"name":"VAE","type":"VAE","links":[12],"slot_index":2,"shape":3,"label":"VAE"}],"properties":{"Node name for S&R":"CheckpointLoaderSimple"},"widgets_values":["flux1-dev-fp8.safetensors"]},{"id":15,"type":"KSampler","pos":[438,-108],"size":{"0":272.14605712890625,"1":473.0747985839844},"flags":{},"order":7,"mode":0,"inputs":[{"name":"model","type":"MODEL","link":21,"label":"model"},{"name":"positive","type":"CONDITIONING","link":15,"label":"positive"},{"name":"negative","type":"CONDITIONING","link":16,"label":"negative"},{"name":"latent_image","type":"LATENT","link":17,"label":"latent_image"}],"outputs":[{"name":"LATENT","type":"LATENT","links":[11],"slot_index":0,"shape":3,"label":"LATENT"}],"properties":{"Node name for S&R":"KSampler"},"widgets_values":[1096960124364403,"randomize",20,1,"euler","simple",1]},{"id":16,"type":"CLIPTextEncode","pos":[103,167],"size":{"0":422.84503173828125,"1":164.31304931640625},"flags":{"collapsed":true},"order":3,"mode":0,"inputs":[{"name":"clip","type":"CLIP","link":18,"slot_index":0,"label":"clip"}],"outputs":[{"name":"CONDITIONING","type":"CONDITIONING","links":[16],"slot_index":0,"label":"CONDITIONING"}],"title":"CLIP 文本编码(负向提示)","properties":{"Node name for S&R":"CLIPTextEncode"},"widgets_values":[""],"color":"#322","bgcolor":"#533"},{"id":17,"type":"Note","pos":[103,227],"size":{"0":285.57025146484375,"1":116.68089294433594},"flags":{},"order":2,"mode":0,"properties":{"text":""},"widgets_values":["注意,Flux dev 和 schnell 没有任何负向提示,因此 CFG 应设置为 1.0。将 CFG 设置为 1.0 意味着负向提示将被忽略。"],"color":"#432","bgcolor":"#653"},{"id":18,"type":"FluxGuidance","pos":[475,-393],"size":{"0":211.60000610351562,"1":58},"flags":{},"order":6,"mode":0,"inputs":[{"name":"conditioning","type":"CONDITIONING","link":19,"label":"conditioning"}],"outputs":[{"name":"CONDITIONING","type":"CONDITIONING","links":[15],"slot_index":0,"shape":3,"label":"CONDITIONING"}],"properties":{"Node name for S&R":"FluxGuidance"},"widgets_values":[3.5]},{"id":19,"type":"LoraLoader|pysssss","pos":[92,-220],"size":{"0":324.5400390625,"1":150},"flags":{},"order":4,"mode":0,"inputs":[{"name":"model","type":"MODEL","link":20,"label":"model"},{"name":"clip","type":"CLIP","link":23,"label":"clip"}],"outputs":[{"name":"MODEL","type":"MODEL","links":[21],"slot_index":0,"shape":3,"label":"MODEL"},{"name":"CLIP","type":"CLIP","links":[22],"slot_index":1,"shape":3,"label":"CLIP"}],"properties":{"Node name for S&R":"LoraLoader|pysssss"},"widgets_values":[{"content":"flux_tarot_v1_lora.safetensors","image":null},1,1,"[none]"]}],"links":[[11,15,0,11,0,"LATENT"],[12,14,2,11,1,"VAE"],[13,11,0,12,0,"IMAGE"],[15,18,0,15,1,"CONDITIONING"],[16,16,0,15,2,"CONDITIONING"],[17,13,0,15,3,"LATENT"],[18,14,1,16,0,"CLIP"],[19,10,0,18,0,"CONDITIONING"],[20,14,0,19,0,"MODEL"],[21,19,0,15,0,"MODEL"],[22,19,1,10,0,"CLIP"],[23,14,1,19,1,"CLIP"]],"groups":[],"config":{},"extra":{"ds":{"scale":1.1,"offset":[349.4297446644178,525.8645990478523]}},"version":0.4}
此工作流需要使用https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes。
克隆仓库: git clone https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes.git
到你的 ComfyUI custom_nodes
目录。
重启 ComfyUI。
按照之前的步骤,将代码保存为 json
文件,并导入到 ComfyUI 中使用。
在这里,我们使用原生工作流进行测试,结果如下:
创建一个迪士尼风格的魔法场景,在一个被施了魔法的森林中,一位年轻公主站在那里。她的眼睛闪烁着光芒,金色的长发随风飘扬。她周围环绕着友好的森林生物,如兔子、小鸟和鹿,所有这些生物都以柔和、梦幻的风格绘制。公主穿着一件美丽的长裙,上面有精致的花卉图案,她的微笑散发着温暖和善良。背景中有着高大的古树,树枝上挂着柔和发光的灯,远处的城堡在雾中隐约可见,为场景增添了一丝童话般的奇妙。
ControlNet(高级用法)ControlNet 用于让用户对图像生成过程有更精确的控制,特别是在使用像 Stable Diffusion 这样的模型时。例如,如果用户希望根据文本提示生成图像,但同时也希望生成的图像遵循特定的结构或轮廓(如特定的姿态或形状),ControlNet 允许将这些结构整合到模型的决策过程中。这使得生成的图像不仅符合文本描述,还能遵循特定的视觉约束,例如角色的轮廓或场景的布局。
GitHub: lllyasviel/ControlNet
下载ControlNet模型目前,开源社区中有两个团队训练了适用于 FLUX.1 的 ControlNet 模型。这些模型既兼容官方的 FLUX.1 模型,也兼容 fp8 模型。它们的 VRAM 需求也较高,需要 12GB 或更多的显存才能流畅生成。
FLUX.1 ControlNet 集合:
https://huggingface.co/XLabs-AI/flux-controlnet-collections
InstanX FLUX.1 Controlnet 联合:
[InstantX/FLUX.1-dev-Controlnet-Union · Hugging Face我们正致力于通过开源和开放科学来推进和普及人工智能。huggingface.com](https://huggingface.co/InstantX/FLUX.1-dev-Controlnet-Union-alpha?source=post_page-----067fc053fedd--------------------------------)
在这里,我们以 XLabs 开发的 ControlNet 为例。首先,你需要安装依赖项:
- 访问
ComfyUI/custom_nodes
- 克隆此仓库:
git clone <https://github.com/XLabs-AI/x-flux-comfyui.git>
- 访问
ComfyUI/custom_nodes/x-flux-comfyui/
并运行python setup.py
- 重启 ComfyUI
第一次启动后,ComfyUI/models/xlabs/loras
和 ComfyUI/models/xlabs/controlnets
文件夹将会自动创建。
所以,要使用 LoRA 或 ControlNet,只需将模型放入这些文件夹中。
接下来,我们需要安装ComfyUI-Manager。同样地,进入 ComfyUI/custom_nodes
目录并运行 git clone https://github.com/ltdrdata/ComfyUI-Manager.git
,然后重启 ComfyUI。
点击主菜单上的“Manager”按钮
如果你点击“安装自定义节点”或“安装模型”,将会打开一个安装对话框。
点击中间列的第一个 自定义节点管理器
,搜索“ControlNet”,你会看到作者 Fannovel16 的 [comfyui_controlnet_aux](https://github.com/Fannovel16/comfyui_controlnet_aux)
项目。点击进行安装。安装完成后,点击重启。依赖项的安装将在后台运行,完成后,ComfyUI 会打开一个新的浏览器标签页。
Canny ControlNet(版本2)
深度ControlNet(版本2)
HED ControlNet(版本 1)
ControlNet 工作流您可以在 ComfyUI\custom_nodes\x-flux-comfyui\workflows
或以下链接中找到 XLabs ControlNet 工作流:
https://github.com/XLabs-AI/x-flux-comfyui/tree/main/workflows
使用Canny的示例:
低内存模式你可以使用12GB VRAM内存来启动FLUX.1。
- 按照 repo https://github.com/city96/ComfyUI-GGUF 中的说明进行安装
- 使用 repo https://github.com/city96/ComfyUI-GGUF 中的 flux1-dev-Q4_0.gguf
- 使用参数启动 ComfyUI:
python3 main.py --lowvram --preview-method auto --use-split-cross-attention
在我们的工作流中,将“加载扩散模型”节点替换为“Unet Loader (GGUF)”
FLUX.1 LoRA 在线训练工具Replicate 提供了一个名为 “ostris/flux-dev-lora-trainer” 的训练工具,允许你用最少仅需 10 张图片来训练自己的 Lora 风格的模型。你可以试一试。
- 价格:此模型的训练在 Nvidia H100 GPU 硬件上运行,每秒费用为 $0.001528。
- 如何训练:阅读此 文档
- 许可证:所有 FLUX.1-Dev LoRAs 的许可证与 FLUX.1-dev 原始基础模型的许可证相同。
总之,这份关于FLUX.1的全面指南为用户提供了必要的工具和知识,以充分利用这一尖端图像生成模型。从安装和设置通过ComfyUI到使用LoRA和ControlNet的高级用法,本指南涵盖了有效利用FLUX.1所需的所有方面。该模型在生成高质量图像方面的灵活性,以及其开源可用性,使其成为艺术家、开发者和AI爱好者的重要资产。无论您是创建复杂的视觉效果还是微调模型以满足特定需求,FLUX.1都在不断变化的AI生成艺术领域中脱颖而出,成为强大且易于访问的选择。随着社区的支持和模型训练的进步,FLUX.1将继续成为高质量、可定制图像生成的标准。
参考资料- “Flux.1 ComfyUI 指南、工作流和示例 — ComfyUI-WIKI。” Comfyui-Wiki.com , 2024, comfyui-wiki.com/tutorial/advanced/flux1-comfyui-guide-workflow-and-examples#flux1-%E7%AE%80%E4%B9%8B。访问于 2024年8月25日。
共同学习,写下你的评论
评论加载中...
作者其他优质文章