Flux-Kontext开源模型安装与使用>Flux-Kontext安装使用教程

Flux-Kontext安装使用教程

FLUX.1 Kontext是Black Forest Labs推出的突破性多态模型编辑模型,支持文本和图像同时输入,能够智能理解图像上下文并执行精准编辑。其开发版本是一个拥有120亿参数的开源辐射变形模型,具有出色的上下文理解能力和角色一致性保持,即使经过多次迭代编辑,也能确保人物特征、结构图布局等关键要素保持稳定。

一、模型安装

1.1 官方版本安装

扩散模型

模型文件名下载链接特点存放路径
flux1-kontext-dev.safetensors点击下载标准版ComfyUI/models/diffusion_models
flux1-dev-kontext_fp8_scaled.safetensors点击下载显存要求更低ComfyUI/models/diffusion_models

vae模型

模型文件名下载链接备注存放路径
ae.safetensors点击下载如果之前下载过 flux 可复用,无需再次下载ComfyUI/models/vae

文本编码器

模型文件名下载链接备注存放路径
clip_l.safetensors点击下载如果之前下载过 flux 可复用,无需再次下载ComfyUI/models/text_encoders
t5xxl_fp16.safetensors点击下载三选一即可,模型越小显存占用越小ComfyUI/models/text_encoders
t5xxl_fp8_e4m3fn.safetensors点击下载三选一即可,模型越小显存占用越小ComfyUI/models/text_encoders
t5xxl_fp8_e4m3fn_scaled.safetensors点击下载三选一即可,模型越小显存占用越小ComfyUI/models/text_encoders

官方虽然说最低显存20G,实际上16G显存也能用。

1.2 GGUF模型下载

扩散模型下载地址:点击跳转

仓库中提供了多个不同质量等级的 GGUF 格式 Flux 模型。如果你在仓库中不确定该选择哪个版本,可以参考以下简单的选择指南:

  • 模型名称中的 Q 后面的数字越大,代表模型精度越高,生成图片的质量也越好,但同时显存占用也会更大。例如,Q2 占用显存较低但生成质量较一般,而 Q8 则需要更多显存但能提供更高质量的图像输出。
  • 你也可以通过模型文件的大小来辅助判断:通常文件越大,意味着模型精度越高,对应的生成质量和资源需求也会更高。

从中选择一个模型下载后放入ComfyUI/models/unet文件夹

vae模型文本编码器模型则依据上面1.1节中指示下载即可。

1.3 nunchaku模型下载

扩散模型下载地址:HuggingFace或者ModelScope

从中下载一个模型后放入ComfyUI/models/diffusion_models文件夹

vae模型文本编码器模型则依据上面1.1节中指示下载即可。

二、官方工作流示例

2.1 使用前提说明

基础工作流,以下所有示例都是基于该工作流进行操作,只是输入信息,提示词编写会有所不同。(输出图像和输入图层尺寸不一样是因为FluxKontextImageScale节点

FLUX KONTEXT预设分辨率:如果想要输入图像和输出图像保持一致,最好参照以下尺寸,当然,您可以在使用的过程中,把FluxKontextImageScale节点删除也能保持尺寸一致,但最后的效果可能会不太好。

2.2 基础修改

基础修改相当于修改某个物体或人物的某个属性。

比如原图里是一辆蓝色车 → 模型帮你改成红色,提示词Change the car color to red.

修改人物表情,提示词Change the girl's expression to a smile.

修改天气,提示词Change to snow weather.

去除水印,提示词Remove the watermark.,当然,如果要更具体还可以指定方位。

为场景添加元素,

提示词Add modern living room furniture to the empty room, including a grey fabric sofa, a wooden coffee table, a floor lamp, and a soft rug, while keeping the wooden floor and windows visible.

中文意思在空房间中添加现代的客厅家具,包括灰色的沙发,木制咖啡桌,落地灯和柔软的地毯,同时保持木地板和窗户的可见性

操作类型常用动词提示词模板示例
添加元素add, insert, place, createAdd [元素] to [位置/场景], with [细节描述], while keeping [要保留的部分] unchanged.Add a modern grey sofa and a wooden coffee table to the empty room, while keeping the wooden floor and windows visible.
改变元素change, transform, modify, convert, replace, adjustChange [原有元素] to [新状态], while maintaining [要保留的部分].Change the car color to red, while keeping the reflections and background unchanged.
移除元素remove, delete, erase, eliminate, clear, wipeRemove [元素] from [位置], and fill the area to match the surrounding [纹理/风格].Remove the watermark from the bottom right corner and fill the area to match the surrounding photo texture.

2.3 风格转换

在上面2.1节基础工作流中将真人转换为“吉卜力风格”,提示词为Transform to Ghibli style。因此,如果想实现风格转换,提示词模板为Transform to XXX或者change to XXX,但是如果想更好的保持人物一致性,最后好面再加上while maintaining the original composition。因此最终模板为

Transform to [风格] while maintaining the original composition
或者
Change to [风格] while maintaining the original composition

但是如果想描述具体的特征,应按照下面的写法。

风格不够具体的写法 ❌带描述特征的写法 ✅
油画Transform to oil painting.Transform to oil painting with visible brushstrokes, thick paint texture.
铅笔素描Make it a sketch.Convert to pencil sketch with natural graphite lines, cross-hatching, and visible paper texture.
漫画Turn into comic style.Transform to comic style with bold outlines, vivid flat colors, and halftone dots.
数字插画Transform to digital art.Transform to digital illustration with smooth gradients, bright colors, and clean line art.
水彩画Make it watercolor.Transform to watercolor style with soft color bleeding, delicate textures, and light washes of color.
蒸汽波Change to vaporwave.Transform to vaporwave style with pastel neon colors, retro 80s aesthetics, and digital glitch effects.
浮世绘Transform to ukiyo-e.Transform to ukiyo-e style with flat color blocks, traditional Japanese patterns, and bold black outlines.

2.4 文本编辑

文本编辑则是修改图片中的文字。(不支持中文字)

比如把下面的"SVDQuant"换为"Comfyui",提示词Replace 'SVDQant' with 'Comfyui'

如果想更好的保持文字样式的一致性,可以在后面加上while maintaining the same font style

Replace 'SVDQant' with 'Comfyui,while maintaining the same font style

2.5 分步修改

一次修改太多东西,模型容易失控。如下,这里使用提示词一次性替换背景、更换人物头发、更换人物衣服。结果最终的图片没有保持一致性

因此需要分步进行修改。将多个 latent 条件使用 ReferenceLatent 节点串联

  1. 修改背景,Change the background to a beach
  2. 修改人物发色,Change the girl's hair color to honey orange brown
  3. 修改人物穿着,Change the clothes of the woman to a red dress

总结:

Step 1: Change [第一个修改] while maintaining [保留内容].

Step 2: Change [第二个修改] while maintaining [保留内容].

Step 3: Change [第三个修改] while maintaining [保留内容].

Step X: Change [第X个修改] while maintaining [保留内容].

三、GGUF工作流示例

如下,把图像中人物的眼镜移除了,提示词Remove the glasses

四、Nunchaku工作流示例

风格迁移,Using this style, a panda astronaut riding a unicorn

使用nunchaku的Kontext模型运行速度很快,如下,基本是秒出图。

五、多图编辑说明

实际上,目前开源模型在多图编辑方面的能力仍有限。官方论文中提到,未来的研究方向应聚焦于支持多图输入与编辑操作,进一步提升模型的扩展性,并降低推理延迟,以实现实时应用。

更新于:2025/06/28
广告

可加入星球获取所有示例工作流~

广告

微信扫码入群,加入AIGC大家庭吧!

如您有任何疑问和网站建议,也欢迎加入我们的QQ交流群!

QQ群:128763578