Skip to content

Flux Kontext:曾经的自然语言编辑图像王者

功能介绍

通过自然语言编辑图像,是黑森林官方开源的自然语言图像编辑模型,在 qwen-image-edit 出现之前,是自然语言编辑图像的王者。

Flux Kontext 版本

  • FLUX.1 Kontext [pro] - 商业版本,专注快速迭代编辑,可通过 api 调用
  • FLUX.1 Kontext [max] - 实验版本,更强的提示遵循能力,可通过 api 调用
  • FLUX.1 Kontext [dev] - 开源版本,12B参数,可本地调用

全面测试

下面进行 7 个场景的测试,左边为原图,右边为编辑后的图。模型使用 flux1-kontext-dev

整体结论:从整体上来讲,除了物体删除和对英文字体的支持就好之外,各方面都要弱于 qwen-image-edit-2509,例如细节/人物的自然程度不及 qwen,不支持直接获取图片的 controlNet 图和根据 controlNet 图生成图片,不支持中文字体的生成。

具体例子如下:

物体删除

img.png

prompt: remove watermark

效果:观察图片右下角的水印,去除的很完美。

物体修改

img.png

prompt:replace the girl's clothes with a sports top and jeans

效果:从审美角度来看,比 qwen-image-edit-2509 要差一些。

物体新增

img_1.png

prompt:A rose-shaped tattoo is added to the left abdomen of the girl

效果:细节上要比 qwen-image-edit-2509 要差一些。

物体三视图生成(物体旋转)

img_2.png

prompt:Obtain the rear view, keep the subject in the exact same pose

效果:同样无法保持原本的姿势下获得旋转视图。

风格转换

动漫转真人 img_3.png

prompt:Transform into realistic style

真人转动漫 img_6.png

prompt:Transform into Chibi style

效果:不使用 Lora 的情况下,动漫转真人效果 kontext 优于 qwen-image-edit-2509,后者使用 Lora 的情况下,后者效果强;真人转动漫效果不如 qwen-image-edit-2509

语义编辑

语义编辑:在保持原始图像视觉语义不变的前提下,对图像内容进行修改。 img_4.png

prompt:The girl made a heart-shaped shape with both hands

效果:自然程度不如 qwen-image-edit-2509

文字生成

img_5.png

prompt:Change the girl's clothes to pure white, with the words' “qwen 不错” 'written on the chest of the top

效果:部分完美。(英文完美,中文不支持)

模型下载

  1. 下载 clip 模型文件:从 这里 下载以下两个文件,下载完成之后,将其放置到 ComfyUI/models/clip/ 下

    • clip_l.safetensors
    • t5xxl_fp8_e4m3fn.safetensors(低于32G内存用这个),t5xxl_fp16.safetensors(高于32G内存用这个,推荐)
  2. 下载 vae 模型文件:下载 ae.safetensors 文件 ,之后为了方便使用,重命名为 flux_ae.safetensors,放置到 ComfyUI/models/vae/flux/ 下

  3. 下载 diffusion 模型文件: 二选一

  4. (可选)下载 nunchaku 推理加速模型,之后放置到 ComfyUI/models/diffusion_models/ 下

显存占用

  • flux1-kontext-dev.safetensors 官方介绍需要 32G 显存,实测 23G 即可;
  • flux1-dev-kontext_fp8_scaled.safetensors 官方介绍需要 20G 显存,实测 16G 即可;

使用

基础工作流

img.png

工作流下载地址:百度网盘

使用 nunchaku 加速工作流

前提:如果之前未安装过 ComfyUI-nunchaku 插件,请参考 高速推理引擎 nunchaku 进行安装,如果已经安装过,则将 ComfyUI-nunchaku 插件更新到至少 0.3.3 版本,同时需要更新轮子到适配版本。 轮子的安装与更新参考 安装推理加速引擎 nunchaku

img_4.png

工作流下载地址:百度网盘,基础工作流需要 26s,nunchaku 加速工作流仅需5s,实现5倍提速。

推荐的提示语编写规则和模板

编写原则:

  1. 具体明确 - 使用精确描述,避免模糊词汇
  2. 分步编辑 - 复杂修改分为多个简单步骤
  3. 明确保留 - 说明哪些要保持不变

四种模板:

  1. 对象修改: "Change [object] to [new state], keep [content to preserve] unchanged"
  2. 风格转换: "Transform to [specific style], while maintaining [composition/character/other] unchanged"
  3. 背景替换: "Change the background to [new background], keep the subject in the exact same position and pose"
  4. 文本编辑: "Replace '[original text]' with '[new text]', maintain the same font style"

文章的最后,如果您觉得本文对您有用,请打赏一杯咖啡!感谢!