本文将介绍如何在 ComfyUI 中使用 Flux.1 Kontext Pro Image API 节点来完成图像编辑功能
FLUX.1 Kontext 是由 Black Forest Labs 开发的一款专业的图像到图像编辑模型,专注于智能理解图像上下文并执行精确编辑。 能够在无需复杂描述的情况下实现多种编辑任务,包括对象修改、风格转换、背景替换、角色一致性编辑和文本编辑等。 Kontext 的核心优势在于其出色的上下文理解能力和角色一致性保持,即使经过多次迭代编辑,也能确保人物特征、构图布局等关键元素保持稳定。
目前,ComfyUI 中支持了 Flux.1 Kontext 的两个模型:
本篇指南,我们将通过对应的工作流来简单介绍如何使用 Flux.1 Kontext 的相关 API 节点来完成图像编辑。
使用 API 节点需要保证你已经正常登录,并在受许可的网络环境下使用,请参考API 节点总览部分文档来了解使用 API 节点的具体使用要求。
如果在加载下面的工作流文件时,你发现存在节点缺失,可能是因为以下情况:
请先确保你已经成功更新 ComfyUI 到最新的开发(nightly)版本, 请查看:如何更新 ComfyUI 部分了解如何更新 ComfyUI。
我们最近更新支持了多图输入工作流,使用新增的 Image Stitch
节点,将允许你将多张图像拼接成一张图像,并使用 Flux.1 Kontext 进行编辑。
下面的图片的metadata
中已经包含工作流信息,请下载并拖入 ComfyUI 中加载对应工作流。
下载下面的图片用于输入或者使用你自己的图片:
你可参考图片中的序号来完成图工作流的运行:
Load image
节点中请分别上传提供的图片Flux.1 Kontext Pro Image
修改必要的参数:
prompt
输入你想要编辑的图像的提示词aspect_ratio
设置原图的高宽比,比例必须在 1:4 到 4:1 之间prompt_upsampling
设置是否使用提示词上采样,如果开启,会自动修改提示词以获得更丰富的结果,但结果是不可重复的Run
按钮,或者使用快捷键 Ctrl(cmd) + Enter(回车)
来执行图像的编辑。Save Image
节点中查看编辑后的图像,对应的图像也会被保存至 ComfyUI/output/
目录下。后续的两个工作流只是使用的 API 节点不同,实际上你只需要基于多图输入工作流修改即可,没有太大的差别
下面的图片的metadata
中已经包含工作流信息,请下载并拖入 ComfyUI 中加载对应工作流。
下载下面的图片用于输入或者使用你自己的图片:
你可参考图片中的序号来完成图工作流的运行:
Load Image
节点中加载需要编辑的图像Flux.1 Kontext Pro Image
修改必要的参数Run
按钮,或者使用快捷键 Ctrl(cmd) + Enter(回车)
来执行图像的编辑。Save Image
节点中查看编辑后的图像,对应的图像也会被保存至 ComfyUI/output/
目录下。下面的图片的metadata
中已经包含工作流信息,请下载并拖入 ComfyUI 中加载对应工作流。
下载下面的图片用于输入或者使用你自己的图片进行演示:
你可参考图片中的序号来完成图工作流的运行:
Load Image
节点中加载需要编辑的图像Flux.1 Kontext Max Image
修改必要的参数Run
按钮,或者使用快捷键 Ctrl(cmd) + Enter(回车)
来执行图像的编辑。Save Image
节点中查看编辑后的图像,对应的图像也会被保存至 ComfyUI/output/
目录下。"Change the car color to red"
"Change to daytime while maintaining the same style of the painting"
原则:
"Transform to Bauhaus art style"
"Transform to oil painting with visible brushstrokes, thick paint texture"
"Change to Bauhaus style while maintaining the original composition"
框架:
"The woman with short black hair"
而非"she"
"while maintaining the same facial features, hairstyle, and expression"
"Replace 'joy' with 'BFL'"
"Replace text while maintaining the same font style"
❌ 错误:"Transform the person into a Viking"
✅ 正确:"Change the clothes to be a viking warrior while preserving facial features"
❌ 错误:"Put him on a beach"
✅ 正确:"Change the background to a beach while keeping the person in the exact same position, scale, and pose"
❌ 错误:"Make it a sketch"
✅ 正确:"Convert to pencil sketch with natural graphite lines, cross-hatching, and visible paper texture"
对象修改:
"Change [object] to [new state], keep [content to preserve] unchanged"
风格转换:
"Transform to [specific style], while maintaining [composition/character/other] unchanged"
背景替换:
"Change the background to [new background], keep the subject in the exact same position and pose"
文本编辑:
"Replace '[original text]' with '[new text]', maintain the same font style"
记住: 越具体越好,Kontext 擅长理解详细指令并保持一致性。