大頭照產生器
上傳自拍照,選擇服裝與背景,生成專業品質的大頭照肖像。
關於
這個大頭照產生器工作流程讓你上傳自拍照,選擇服裝與背景,產出精緻、專業的肖像。它結合文字控制與圖像條件設定,確保臉部特徵保留,同時服裝與背景可重新設計。你的自拍照會由 LoadImage 載入,並導入核心生成節點(ID: d4c06663-cb1a-4a41-a36b-f09c93e55e7e)進行實際合成。PreviewAny 可快速預覽,SaveImage 則將最終結果寫入磁碟。
服裝與背景由文字節點管理,你可以從預設選擇或自由輸入說明。PrimitiveStringMultiline 儲存一小段 JSON 預設,JsonExtractString 從該 JSON 擷取 outfit 與 backdrop 等欄位。ComfySwitchNode 讓你在預設文字與自訂提示詞路徑間切換。StringConcatenate 組合生成器看到的最終說明文字(例如:基本大頭照提示詞加上你選的服裝與背景)。CustomCombo 節點封裝了流程中的輔助部分,讓模型載入與採樣器細節保持整潔,同時保留你需要的主要輸入以便快速調整。
您提供的內容
- 正在讀取工作流程
在 ComfyUI 中執行。 此工作流程無法在此頁面上執行。請在已載入所有內容的 Comfy Cloud 中開啟,或下載到您自己的 ComfyUI。
在 Cloud 中試用工作流程內部
節點圖的唯讀預覽。請在 Comfy Cloud 中開啟,或下載後編輯節點。
從程式碼使用此工作流程
可行時會根據工作流程圖和輸入內容產生;否則會顯示儲存的範例。執行可能產生費用的程式碼前,請檢查認證資訊和端點。
What you need
- Runs on
- Comfy Cloud
- 金鑰
- COMFY_API_KEY
需要付費 Cloud 方案與點數。
# 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({
"132": {
"class_type": "LoadImage",
"inputs": {
"image": "30c332ffe0857813d284f963528c35e38b31234a681dfebe21db55c766f5cfa8.png"
},
"_meta": {
"title": "Load Image"
}
},
"197": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "Qwen_Edit_2511",
"images": [
"196:175",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"234": {
"class_type": "StringConcatenate",
"inputs": {
"delimiter": " ",
"string_a": "Keep the exact same facial identity as the original photo. Headshot portrait.",
"string_b": [
"258",
0
]
},
"_meta": {
"title": "Assemble Prompt"
}
},
"235": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"234",
0
]
},
"_meta": {
"title": "Preview as Text"
}
},
"252": {
"class_type": "CustomCombo",
"inputs": {
"choice": "Black Suit and Tie"
},
"_meta": {
"title": "Outfit"
}
},
"253": {
"class_type": "JsonExtractString",
"inputs": {
"json_string": "{\n \"Black Suit and Tie\": \"The subject wears a black tailored suit, a crisp white dress shirt, and a black silk tie.\",\n \"Charcoal Suit and Tie\": \"The subject wears a charcoal gray tailored suit, a light blue dress shirt, and a burgundy silk tie.\",\n \"Navy Suit, No Tie\": \"The subject wears a navy blue tailored suit over a crisp white dress shirt, top button open, no tie.\",\n \"Navy Blazer, White Shirt\": \"The subject wears a navy blue blazer over a white open-collar shirt, smart business-casual.\",\n \"Black Tuxedo and Bow Tie\": \"The subject wears a black tuxedo with satin lapels, a white dress shirt, and a black bow tie.\",\n \"Black Turtleneck\": \"The subject wears a fitted black merino turtleneck, clean and modern.\",\n \"White Button-Up\": \"The subject wears a crisp white button-up shirt, top button open, neatly pressed.\",\n \"Light Blue Button-Up\": \"The subject wears a light blue oxford button-up shirt, crisp and approachable.\",\n \"Gray Crewneck Sweater\": \"The subject wears a heather-gray crewneck sweater over a white collared shirt.\",\n \"Cream Knit Sweater\": \"The subject wears a cream cable-knit sweater, warm and relaxed.\",\n \"Black Leather Jacket\": \"The subject wears a black leather jacket over a plain white t-shirt.\",\n \"Blue Denim Shirt\": \"The subject wears a mid-wash blue denim button-up shirt, relaxed and casual.\",\n \"Red Floral Shirt\": \"The subject wears a red tropical floral short-sleeve shirt, playful and confident.\",\n \"Camel Overcoat\": \"The subject wears a tailored camel overcoat over a black crewneck sweater.\",\n \"Brown Tweed Blazer\": \"The subject wears a brown tweed blazer with a cream shirt and a dark knit tie.\"\n}",
"key": [
"252",
0
]
},
"_meta": {
"title": "Outfit Prompt (JSON)"
}
},
"254": {
"class_type": "CustomCombo",
"inputs": {
"choice": "Studio Gray"
},
"_meta": {
"title": "Backdrop"
}
},
"255": {
"class_type": "JsonExtractString",
"inputs": {
"json_string": "{\n \"Studio Gray\": \"Set against a seamless mid-gray studio backdrop with polished three-point lighting and a soft rim light.\",\n \"Studio White\": \"Set against a seamless pure-white studio backdrop with bright, airy high-key lighting.\",\n \"Studio Black\": \"Set against a seamless deep-black studio backdrop with a dramatic soft key and subtle rim light.\",\n \"Studio Pink\": \"Set against a seamless pastel-pink studio backdrop with bright, even, flattering light.\",\n \"Studio Blue\": \"Set against a seamless soft steel-blue gradient studio backdrop with clean directional lighting.\",\n \"Studio Beige\": \"Set against a seamless warm beige studio backdrop with soft golden key light.\",\n \"Modern Office\": \"Set in a softly blurred modern office interior with bright natural window light and gentle bokeh.\",\n \"Conference Room\": \"Set in a softly blurred glass-walled conference room with cool professional daylight.\",\n \"Bookshelf Office\": \"Set in a softly blurred office with warm wooden bookshelves and gentle window light.\",\n \"Exposed Brick Loft\": \"Set in a softly blurred exposed red-brick loft with warm ambient tungsten light.\",\n \"Outdoor Golden Hour\": \"Set against a softly blurred leafy outdoor background in warm golden-hour sunlight with creamy bokeh.\",\n \"Overcast Street\": \"Set on a softly blurred city street under even overcast daylight with muted gray-blue tones.\",\n \"Garden Greenery\": \"Set against softly blurred lush green garden foliage in bright natural daylight.\",\n \"City Skyline\": \"Set before a softly blurred floor-to-ceiling window overlooking a city skyline in cool daylight.\",\n \"Rooftop Sunset\": \"Set on a softly blurred rooftop terrace at sunset with warm orange-and-violet sky tones.\"\n}",
"key": [
"254",
0
]
},
"_meta": {
"title": "Backdrop Prompt (JSON)"
}
},
"256": {
"class_type": "StringConcatenate",
"inputs": {
"delimiter": " ",
"string_a": [
"253",
0
],
"string_b": [
"255",
0
]
},
"_meta": {
"title": "Outfit + Backdrop"
}
},
"257": {
"class_type": "PrimitiveStringMultiline",
"inputs": {
"value": "The subject wears a black tailored suit with a white shirt. Set against a seamless dark teal studio backdrop with soft dramatic lighting."
},
"_meta": {
"title": "Custom Prompt Text"
}
},
"258": {
"class_type": "ComfySwitchNode",
"inputs": {
"on_false": [
"256",
0
],
"on_true": [
"257",
0
],
"switch": False
},
"_meta": {
"title": "Custom Prompt?"
}
},
"196:152": {
"class_type": "CFGNorm",
"inputs": {
"model": [
"196:155",
0
],
"pre_cfg": False,
"strength": 1
},
"_meta": {
"title": "CFGNorm"
}
},
"196:155": {
"class_type": "ModelSamplingAuraFlow",
"inputs": {
"model": [
"196:166",
0
],
"sampling": "flow",
"shift": 3.1
},
"_meta": {
"title": "ModelSamplingAuraFlow"
}
},
"196:156": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "qwen_image_vae.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"196:161": {
"class_type": "TextEncodeQwenImageEditPlus",
"inputs": {
"clip": [
"196:167",
0
],
"image1": [
"196:176",
0
],
"prompt": [
"235",
0
],
"vae": [
"196:156",
0
]
},
"_meta": {
"title": "TextEncodeQwenImageEditPlus (Positive)"
}
},
"196:162": {
"class_type": "LoraLoaderModelOnly",
"inputs": {
"lora_name": "Qwen-Image-Edit-2511-Lightning-4steps-V1.0-bf16.safetensors",
"model": [
"196:152",
0
],
"strength_model": 1
},
"_meta": {
"title": "Load LoRA"
}
},
"196:163": {
"class_type": "PrimitiveFloat",
"inputs": {
"value": 4
},
"_meta": {
"title": "CFG"
}
},
"196:164": {
"class_type": "PrimitiveFloat",
"inputs": {
"value": 1
},
"_meta": {
"title": "CFG"
}
},
"196:165": {
"class_type": "VAEEncode",
"inputs": {
"pixels": [
"196:176",
0
],
"vae": [
"196:156",
0
]
},
"_meta": {
"title": "VAE Encode"
}
},
"196:166": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "qwen_image_edit_2511_bf16.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"196:167": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "qwen_2.5_vl_7b_fp8_scaled.safetensors",
"device": "default",
"type": "qwen_image"
},
"_meta": {
"title": "Load CLIP"
}
},
"196:168": {
"class_type": "ComfySwitchNode",
"inputs": {
"on_false": [
"196:152",
0
],
"on_true": [
"196:162",
0
],
"switch": [
"196:171",
0
]
},
"_meta": {
"title": "Switch (Model)"
}
},
"196:169": {
"class_type": "PrimitiveInt",
"inputs": {
"value": 6
},
"_meta": {
"title": "Steps"
}
},
"196:170": {
"class_type": "PrimitiveInt",
"inputs": {
"value": 30
},
"_meta": {
"title": "Steps"
}
},
"196:171": {
"class_type": "PrimitiveBoolean",
"inputs": {
"value": True
},
"_meta": {
"title": "Enable 4steps LoRA?"
}
},
"196:172": {
"class_type": "ComfySwitchNode",
"inputs": {
"on_false": [
"196:163",
0
],
"on_true": [
"196:164",
0
],
"switch": [
"196:171",
0
]
},
"_meta": {
"title": "Switch (CFG)"
}
},
"196:173": {
"class_type": "ComfySwitchNode",
"inputs": {
"on_false": [
"196:170",
0
],
"on_true": [
"196:169",
0
],
"switch": [
"196:171",
0
]
},
"_meta": {
"title": "Switch (Steps)"
}
},
"196:174": {
"class_type": "KSampler",
"inputs": {
"cfg": [
"196:172",
0
],
"denoise": 1,
"latent_image": [
"196:244",
0
],
"model": [
"196:168",
0
],
"negative": [
"196:229",
0
],
"positive": [
"196:161",
0
],
"sampler_name": "euler",
"scheduler": "simple",
"seed": 111,
"steps": [
"196:173",
0
]
},
"_meta": {
"title": "KSampler"
}
},
"196:175": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"196:174",
0
],
"vae": [
"196:156",
0
]
},
"_meta": {
"title": "VAE Decode"
}
},
"196:176": {
"class_type": "FluxKontextImageScale",
"inputs": {
"image": [
"132",
0
]
},
"_meta": {
"title": "FluxKontextImageScale"
}
},
"196:229": {
"class_type": "TextEncodeQwenImageEditPlus",
"inputs": {
"clip": [
"196:167",
0
],
"image1": [
"196:176",
0
],
"prompt": "",
"vae": [
"196:156",
0
]
},
"_meta": {
"title": "Text Encode Qwen Image Edit Plus"
}
},
"196:244": {
"class_type": "EmptyLatentImage",
"inputs": {
"batch_size": 1,
"height": [
"196:245",
1
],
"width": [
"196:245",
0
]
},
"_meta": {
"title": "Empty Latent Image"
}
},
"196:245": {
"class_type": "ResolutionSelector",
"inputs": {
"aspect_ratio": "1:1 (Square)",
"megapixels": 1,
"multiple": 8
},
"_meta": {
"title": "Resolution Selector"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)問答
打開 PrimitiveStringMultiline 編輯 JSON。包含 JsonExtractString 節點預期的鍵(通常為 "outfit" 與 "backdrop")。範例:{"outfit": "深藍西裝外套、白襯衫", "backdrop": "柔灰色攝影棚背景"}。執行流程即可套用。
請使用清晰、光線充足、正面自拍,臉部完整可見且背景簡單。裁切至頭肩為主。如果 CustomCombo/核心節點有圖像影響力/強度控制,略為提高該值,讓自拍優先於風格化。
可以。將 ComfySwitchNode 切換到自訂提示路徑,直接輸入清楚的單行或多行描述(如:「專業大頭照,炭灰色西裝,淺灰無縫背景」)。流程會將該文字直接送入生成器。
PreviewAny 可快速檢查,SaveImage 寫入最終圖像。如果 CustomCombo 或核心生成器節點有解析度、步數、引導等參數,可在那裡調整。若未顯示,請展開 CustomCombo 查看內部設定。