ComfyUI Flux.1 Kontext Pro Image API 节点 ComfyUI 官方示例
本文将介绍如何在 ComfyUI 中使用 Flux.1 Kontext Pro Image API 节点来完成图像编辑功能
FLUX.1 Kontext 是由 Black Forest Labs 开发的一款专业的图像到图像编辑模型,专注于智能理解图像上下文并执行精确编辑。 能够在无需复杂描述的情况下实现多种编辑任务,包括对象修改、风格转换、背景替换、角色一致性编辑和文本编辑等。 Kontext 的核心优势在于其出色的上下文理解能力和角色一致性保持,即使经过多次迭代编辑,也能确保人物特征、构图布局等关键元素保持稳定。
目前,ComfyUI 中支持了 Flux.1 Kontext 的两个模型:
- Kontext Pro 适合编辑、合成和混音。
- Kontext Max 在排版、提示词精确度和速度方面突破极限。
本篇指南,我们将通过对应的工作流来简单介绍如何使用 Flux.1 Kontext 的相关 API 节点来完成图像编辑。
使用 API 节点需要保证你已经正常登录,并在受许可的网络环境下使用,请参考API 节点总览部分文档来了解使用 API 节点的具体使用要求。
Flux.1 Kontext Pro Image API 节点 工作流
1. 工作流文件下载
下面的图片的metadata
中已经包含工作流信息,请下载并拖入 ComfyUI 中加载对应工作流。
下载下面的图片用于输入或者使用你自己的图片:
2. 按步骤完成工作流的运行
你可参考图片中的序号来完成图工作流的运行:
- 在
Load Image
节点中加载需要编辑的图像 - 在
Flux.1 Kontext Pro Image
修改必要的参数:prompt
输入你想要编辑的图像的提示词aspect_ratio
设置原图的高宽比,比例必须在 1:4 到 4:1 之间prompt_upsampling
设置是否使用提示词上采样,如果开启,会自动修改提示词以获得更丰富的结果,但结果是不可重复的
- 点击
Run
按钮,或者使用快捷键Ctrl(cmd) + Enter(回车)
来执行图像的编辑。 - 等待 API 返回结果后,你可在
Save Image
节点中查看编辑后的图像,对应的图像也会被保存至ComfyUI/output/
目录下。
Flux.1 Kontext Max Image API 节点 工作流
1. 工作流文件下载
下面的图片的metadata
中已经包含工作流信息,请下载并拖入 ComfyUI 中加载对应工作流。
下载下面的图片用于输入或者使用你自己的图片进行演示:
2. 按步骤完成工作流的运行
你可参考图片中的序号来完成图工作流的运行:
- 在
Load Image
节点中加载需要编辑的图像 - 在
Flux.1 Kontext Max Image
修改必要的参数:prompt
输入你想要编辑的图像的提示词aspect_ratio
设置原图的高宽比,比例必须在 1:4 到 4:1 之间prompt_upsampling
设置是否使用提示词上采样,如果开启,会自动修改提示词以获得更丰富的结果,但结果是不可重复的
- 点击
Run
按钮,或者使用快捷键Ctrl(cmd) + Enter(回车)
来执行图像的编辑。 - 等待 API 返回结果后,你可在
Save Image
节点中查看编辑后的图像,对应的图像也会被保存至ComfyUI/output/
目录下。
Flux Kontext 提示词技巧
1. 基础修改
- 简单直接:
"Change the car color to red"
- 保持风格:
"Change to daytime while maintaining the same style of the painting"
2. 风格转换
原则:
- 明确命名风格:
"Transform to Bauhaus art style"
- 描述特征:
"Transform to oil painting with visible brushstrokes, thick paint texture"
- 保留构图:
"Change to Bauhaus style while maintaining the original composition"
3. 角色一致性
框架:
- 具体描述:
"The woman with short black hair"
而非"she"
- 保留特征:
"while maintaining the same facial features, hairstyle, and expression"
- 分步修改:先改背景,再改动作
4. 文本编辑
- 使用引号:
"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”、“replace”而非”transform”
最佳实践模板
对象修改:
"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 擅长理解详细指令并保持一致性。