虛擬角色試穿 - 四合一
上傳你的角色圖片和一件要試穿的服裝的平鋪圖。在1個Nano Banana提示詞中產生4張圖像。
下載工作流程在 Cloud 中試用 API 文件
工作流程內部
來源範本的唯讀預覽。請在 Cloud 中開啟,以探索節點並進行變更。
Loading the graph
Open full-size workflow preview執行於
- 輸出
- 圖片
- 作者
- Rob
從您的程式碼呼叫此模型
以下請求使用與 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": "LoadImage",
"inputs": {
"image": "UPLOADED_subject_FILENAME"
},
"_meta": {
"title": "Load Subject Image"
}
},
"5": {
"class_type": "PrimitiveStringMultiline",
"inputs": {
"value": "A 2x2 (2 rows, 2 cols) grid of high fashion photoshoot images of the model wearing the outfit from image 2, each grid image should show the a full body shot of the subject in slightly different poses. Ensure that all outfit clothes/accessories are present in each grid image.\n\nDO NOT generate the grid with any visible borders or gutters.\n\nMaintain the exact setting from input image 1."
},
"_meta": {
"title": "Prompt"
}
},
"8": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI-image_stitched",
"images": [
"9",
0
]
},
"_meta": {
"title": "Save Stitched Image"
}
},
"9": {
"class_type": "GeminiImage2Node",
"inputs": {
"aspect_ratio": "auto",
"images": [
"56",
0
],
"model": "gemini-3-pro-image-preview",
"prompt": [
"5",
0
],
"resolution": "4K",
"response_modalities": "IMAGE+TEXT",
"seed": 12345,
"system_prompt": "You are an expert image-generation engine. You must ALWAYS produce an image.\nInterpret all user input—regardless of format, intent, or abstraction—as literal visual directives for image composition.\nIf a prompt is conversational or lacks specific visual details, you must creatively invent a concrete visual scenario that depicts the concept.\nPrioritize generating the visual representation above any text, formatting, or conversational requests."
},
"_meta": {
"title": "Nano Banana Pro (Google Gemini Image)"
}
},
"10": {
"class_type": "PrimitiveInt",
"inputs": {
"value": 0
},
"_meta": {
"title": "Crop Inset Grid Images"
}
},
"12": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI-image_1",
"images": [
"11:47",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"13": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI-image_2",
"images": [
"11:48",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"14": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI-image_3",
"images": [
"11:49",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"15": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI-image_4",
"images": [
"11:50",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"35": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_outfit_FILENAME"
},
"_meta": {
"title": "Load Outfit Image"
}
},
"37": {
"class_type": "ResizeAndPadImage",
"inputs": {
"image": [
"35",
0
],
"interpolation": "area",
"padding_color": "white",
"target_height": [
"38",
1
],
"target_width": [
"38",
0
]
},
"_meta": {
"title": "Resize And Pad Image"
}
},
"38": {
"class_type": "GetImageSize",
"inputs": {
"image": [
"1",
0
]
},
"_meta": {
"title": "Get Image Size"
}
},
"56": {
"class_type": "BatchImagesNode",
"inputs": {
"images.image0": [
"1",
0
],
"images.image1": [
"37",
0
]
},
"_meta": {
"title": "Batch Images"
}
},
"11:16": {
"class_type": "SimpleMath+",
"inputs": {
"a": [
"11:17",
1
],
"b": [
"11:53",
0
],
"value": "(a-2*b) / 2"
},
"_meta": {
"title": "HEIGHT"
}
},
"11:17": {
"class_type": "GetImageSize",
"inputs": {
"image": [
"9",
0
]
},
"_meta": {
"title": "Get Image Size"
}
},
"11:19": {
"class_type": "ImageBatchMulti",
"inputs": {
"image_1": [
"11:47",
0
],
"image_2": [
"11:48",
0
],
"image_3": [
"11:49",
0
],
"image_4": [
"11:50",
0
],
"inputcount": 4
},
"_meta": {
"title": "Image Batch Multi"
}
},
"11:22": {
"class_type": "SimpleMath+",
"inputs": {
"a": [
"11:17",
1
],
"b": 0,
"value": "(a) / 2"
},
"_meta": {
"title": "HEIGHT / 2"
}
},
"11:24": {
"class_type": "SimpleMath+",
"inputs": {
"a": 0,
"b": [
"11:53",
0
],
"value": "b/2"
},
"_meta": {
"title": "Col 1 - X val"
}
},
"11:43": {
"class_type": "SimpleMath+",
"inputs": {
"a": [
"11:17",
0
],
"b": [
"11:53",
0
],
"value": "(a-2*b) / 2"
},
"_meta": {
"title": "WIDTH"
}
},
"11:45": {
"class_type": "SimpleMath+",
"inputs": {
"a": [
"11:17",
0
],
"b": 0,
"value": "(a) / 2"
},
"_meta": {
"title": "WIDTH / 2"
}
},
"11:46": {
"class_type": "ImageResizeKJv2",
"inputs": {
"crop_position": "center",
"device": "cpu",
"divisible_by": 2,
"height": [
"11:22",
0
],
"image": [
"11:19",
0
],
"keep_proportion": "stretch",
"pad_color": "0, 0, 0",
"upscale_method": "nearest-exact",
"width": [
"11:45",
0
]
},
"_meta": {
"title": "Resize Images"
}
},
"11:47": {
"class_type": "ImageCrop",
"inputs": {
"height": [
"11:16",
0
],
"image": [
"9",
0
],
"width": [
"11:43",
0
],
"x": [
"11:24",
0
],
"y": [
"11:24",
0
]
},
"_meta": {
"title": "1"
}
},
"11:48": {
"class_type": "ImageCrop",
"inputs": {
"height": [
"11:16",
0
],
"image": [
"9",
0
],
"width": [
"11:43",
0
],
"x": [
"11:51",
0
],
"y": 0
},
"_meta": {
"title": "2"
}
},
"11:49": {
"class_type": "ImageCrop",
"inputs": {
"height": [
"11:16",
0
],
"image": [
"9",
0
],
"width": [
"11:43",
0
],
"x": [
"11:24",
0
],
"y": [
"11:52",
0
]
},
"_meta": {
"title": "3"
}
},
"11:50": {
"class_type": "ImageCrop",
"inputs": {
"height": [
"11:16",
0
],
"image": [
"9",
0
],
"width": [
"11:43",
0
],
"x": [
"11:51",
0
],
"y": [
"11:52",
0
]
},
"_meta": {
"title": "4"
}
},
"11:51": {
"class_type": "SimpleMath+",
"inputs": {
"a": [
"11:43",
0
],
"b": [
"11:53",
0
],
"value": "a + (b/2)"
},
"_meta": {
"title": "Col 2 - X val"
}
},
"11:52": {
"class_type": "SimpleMath+",
"inputs": {
"a": [
"11:16",
0
],
"b": [
"11:53",
0
],
"value": "a + (b/2)"
},
"_meta": {
"title": "Row 2 - Y val"
}
},
"11:53": {
"class_type": "SimpleMath+",
"inputs": {
"a": [
"10",
0
],
"b": 0,
"value": "a"
},
"_meta": {
"title": "Crop Inset Grid Images Value"
}
}
})
workflow.set_input("35", "image", client.assets.from_url("https://comfy.org/catalog-media/d94d0e7b-6e14-493e-b138-c8fc153f3299/b1a7c52c-6e15-4d8f-9de1-2b39f11b833a"))
workflow.set_input("1", "image", client.assets.from_url("https://comfy.org/catalog-media/7e14163e-ac17-4b5b-a23d-9f03e3d39c3b/e86b187b-7de3-47f1-bbd7-f5981b9c1151"))
# 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("8"):
output.to_file(output.name)
for output in job.get_outputs("12"):
output.to_file(output.name)
for output in job.get_outputs("13"):
output.to_file(output.name)
for output in job.get_outputs("14"):
output.to_file(output.name)
for output in job.get_outputs("15"):
output.to_file(output.name)試試範例
關於此工作流程
這個 ComfyUI 工作流程「虛擬試穿(角色)4 合 1」專為 AI 圖像生成虛擬時尚試穿設計。你可以上傳角色圖與服裝平鋪圖,然後用 Nano Banana Pro 模型在單一提示下生成角色穿著該服裝的四種變化。流程包含 LoadImage 載入圖像、ResizeAndPadImage 調整尺寸、BatchImagesNode 同時處理多張圖。comfyui-kjnodes 與 comfyui_essentials 的自訂節點增強功能,讓整合與處理更順暢。這對時裝設計師、數位藝術家、電商平台等想在無需實體樣品下預覽服裝穿搭非常實用。
問答
流程支援常見圖像格式,如 JPEG、PNG、BMP,無論是角色圖還是服裝圖。
可以,你可用 PrimitiveInt 節點設定想要的變化數量,預設為四張。
可用 ResizeAndPadImage 節點調整圖像尺寸以符合流程需求。
可以,只要圖像能與 Nano Banana Pro 模型相容,任何角色類型皆可使用。