BFL FLUX.2 [max]: 物體替換
使用 FLUX.2 [max] 進行高品質物體替換,適合產品拍攝與傢俱替換,便於保持場景一致。
下載工作流程在 Cloud 中試用 API 文件
工作流程內部
來源範本的唯讀預覽。請在 Cloud 中開啟,以探索節點並進行變更。
Loading the graph
Open full-size workflow preview- 輸出
- 圖片
- 作者
- ComfyUI
從您的程式碼呼叫此模型
以下請求使用與 Playground 相同的已準備節點圖和設定。每次提交都可能啟動付費執行;若提交結果不明,請勿自動重試提交。
1 取得 API 金鑰 ↗
What you need
- Runs on
- Comfy Cloud
- 金鑰
- COMFY_API_KEY
- 您的檔案
- 由程式碼透過其 URL 上傳
需要付費 Cloud 方案與點數。
下載 API JSONAPI 文件 ↗
# Python 3.10+: pip install comfy-sdk==0.4.0
import os
from comfy_sdk import Comfy
api_key = os.environ.get("COMFY_API_KEY", "").strip()
if not api_key: raise RuntimeError("Set COMFY_API_KEY")
os.environ.setdefault("COMFY_BASE_URL", "https://cloud.comfy.org")
client = Comfy(api_key=api_key)
workflow = client.workflows.from_json({
"1": {
"class_type": "Flux2MaxImageNode",
"inputs": {
"height": [
"14",
1
],
"images": [
"15",
0
],
"prompt": "Replace the two mustard-yellow stools in front of the travertine breakfast bar in Image 1 with a single armchair exactly like the green velvet Victorian armchair in Image 2, keeping its carved mahogany frame, tufted emerald upholstery and brass casters. Place it facing the camera in front of the counter, at a natural scale for the room. Then seat the man from Image 3 in the armchair, relaxed, one arm resting on the armrest and legs crossed, wearing exactly the same rust velvet blazer, patterned shirt, brown flared trousers and platform boots, with the same face and hair. Keep the kitchen from Image 1 completely unchanged: the teak cabinets, green and terracotta tiles, orange refrigerator, copper pendant lamps, the bowl of persimmons, the terracotta floor, the window and the warm morning sunlight. Match the shadows and light on the chair and the man to the room.",
"prompt_upsampling": True,
"seed": 605236935620651,
"width": [
"14",
0
]
},
"_meta": {
"title": "Flux.2 [max] Image"
}
},
"2": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_scene_FILENAME"
},
"_meta": {
"title": "Load Image"
}
},
"3": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_object_FILENAME"
},
"_meta": {
"title": "Load Image"
}
},
"6": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "Flux.2_max",
"images": [
"1",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"10": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_person_FILENAME"
},
"_meta": {
"title": "Load Image"
}
},
"14": {
"class_type": "GetImageSize",
"inputs": {
"image": [
"2",
0
]
},
"_meta": {
"title": "Get Image Size"
}
},
"15": {
"class_type": "BatchImagesNode",
"inputs": {
"images.image0": [
"2",
0
],
"images.image1": [
"3",
0
],
"images.image2": [
"10",
0
]
},
"_meta": {
"title": "Batch Images"
}
}
})
workflow.set_input("3", "image", client.assets.from_url("https://comfy.org/catalog-media/64c1bfd4-464d-4cc9-ae35-c420b8bfeddd/43d99397-6ea4-40fe-afb2-a6fa8e344760"))
workflow.set_input("10", "image", client.assets.from_url("https://comfy.org/catalog-media/24acd8c3-8fc5-46d8-ae81-cd11a36d886b/9a29c56e-2ceb-4c3d-b9fa-4c4dacff4a07"))
workflow.set_input("2", "image", client.assets.from_url("https://comfy.org/catalog-media/4f9ff8de-3ce8-4e16-baa8-9a72972572e0/f4c98111-6bd3-468e-9fab-c3210ecf7e45"))
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)
for output in job.get_outputs("6"):
output.to_file(output.name)試試範例
關於此工作流程
FLUX.2 [max]:物件替換工作流程,能在維持場景一致性與品質下,無縫替換圖像中的物件。核心為 Flux2MaxImageNode,運用先進圖像處理技術,確保物件替換精準。特別適合產品攝影、家具替換等需維持原圖美感的應用。
流程由 LoadImage 節點匯入欲編輯圖像,Flux2MaxImageNode 負責辨識並精準替換目標物件。GetImageSize 節點確保全流程圖像尺寸一致,BatchImagesNode 則支援多圖批次處理,提升大量作業效率。最後以 SaveImage 節點輸出編輯後圖像,適用於各種應用場景。
問答
只要替換物件在尺寸與視角上能與原場景相容,就可以替換任何物件。
可以,透過 BatchImagesNode 可同時處理多張圖片,適合大量編輯。
會。Flux2MaxImageNode 以維持較高影像品質為目標,讓編輯後的圖片維持清晰度。
熟悉 ComfyUI 工作流程會更有幫助,但步驟清楚,新手也能依流程操作。