人物肖像重新打光
上傳角色肖像,在保持角色一致性的同時建立多種電影級光照條件。
關於
角色肖像重光是一個精簡的 ComfyUI 工作流程,能將單一肖像圖像渲染出多種電影感光線變化,同時維持角色身份一致。流程僅用三個節點串接:LoadImage 載入原始肖像,GeminiImage2Node 透過外部 API 進行圖像到圖像重光,SaveImage 儲存結果。流程預設於 GeminiImage2Node 內運行 Nano Banana Pro 模型,特別適合寫實肖像。
技術上,重光是根據你上傳的圖像與描述光線配置的文字提示(如「攝影機左側柔光主燈、暖色邊緣光、低填充、電影對比」)進行。GeminiImage2Node 會將圖像與提示送至 API,回傳保留姿勢與臉部結構的重光圖像。若要維持身份一致,建議提高圖像保留(通常為強度或指引設定)。如需多種光線效果,可複製 GeminiImage2Node(每個不同光線提示),並從同一 LoadImage 輸出串接,分別用 SaveImage 儲存各自結果。
您提供的內容
- 正在讀取工作流程
在 ComfyUI 中執行。 此工作流程無法在此頁面上執行。請在已載入所有內容的 Comfy Cloud 中開啟,或下載到您自己的 ComfyUI。
在 Cloud 中試用工作流程內部
節點圖的唯讀預覽。請在 Comfy Cloud 中開啟,或下載後編輯節點。
Loading the graph
Open full-size workflow preview- 作者
- Rob
需要自訂節點
- 正在讀取工作流程
從程式碼使用此工作流程
可行時會根據工作流程圖和輸入內容產生;否則會顯示儲存的範例。執行可能產生費用的程式碼前,請檢查認證資訊和端點。
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({
"124": {
"class_type": "LoadImage",
"inputs": {
"image": "silver_hand.png"
},
"_meta": {
"title": "Load Image"
}
},
"136": {
"class_type": "GeminiImage2Node",
"inputs": {
"aspect_ratio": "auto",
"images": [
"124",
0
],
"model": "Nano Banana 2 (Gemini 3.1 Flash Image)",
"prompt": "Maintain the identity of input image 1, modify the shadows to match the following lighting style: dual rim backlight, no front key, twin hard lights from behind left and right, subject silhouetted at center, glowing edge separation on both sides, dramatic dark fill",
"resolution": "1K",
"response_modalities": "IMAGE+TEXT",
"seed": 194380522768098,
"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)"
}
},
"138": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI-nb_2",
"images": [
"136",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"150": {
"class_type": "GeminiImage2Node",
"inputs": {
"aspect_ratio": "auto",
"images": [
"124",
0
],
"model": "Nano Banana 2 (Gemini 3.1 Flash Image)",
"prompt": "Maintain the identity of input image 1, modify the scene lighting and shadows to match the following lighting style: Hard top-down overhead key, harsh light directly above, deep under-eye and jaw shadows, pronounced brow ridge highlight, strong nose shadow pointing straight down, theatrical and sculpted",
"resolution": "1K",
"response_modalities": "IMAGE+TEXT",
"seed": 31312554729959,
"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)"
}
},
"152": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI-nb_2",
"images": [
"150",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"156": {
"class_type": "GeminiImage2Node",
"inputs": {
"aspect_ratio": "auto",
"images": [
"124",
0
],
"model": "Nano Banana 2 (Gemini 3.1 Flash Image)",
"prompt": "Maintain the identity of input image 1, modify the scene lighting and shadows to match the following lighting style: Split lighting, hard side key at 90°, one half face fully lit, other half near-black, sharp nose shadow line, minimal fill.",
"resolution": "1K",
"response_modalities": "IMAGE+TEXT",
"seed": 337125210981716,
"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)"
}
},
"158": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI-nb_2",
"images": [
"156",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"168": {
"class_type": "GeminiImage2Node",
"inputs": {
"aspect_ratio": "auto",
"images": [
"124",
0
],
"model": "Nano Banana 2 (Gemini 3.1 Flash Image)",
"prompt": "Maintain the identity of input image 1, modify the scene lighting and shadows to match the following lighting style: Rembrandt, side key slightly above, deep falloff, subtle rim separation.",
"resolution": "1K",
"response_modalities": "IMAGE+TEXT",
"seed": 95962613515780,
"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)"
}
},
"170": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI-nb_2",
"images": [
"168",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"180": {
"class_type": "GeminiImage2Node",
"inputs": {
"aspect_ratio": "auto",
"images": [
"124",
0
],
"model": "Nano Banana 2 (Gemini 3.1 Flash Image)",
"prompt": "Maintain the identity of input image 1, modify the scene lighting and shadows to match the following lighting style: Motivated practical, off-axis kicker mimicking an environmental source, strong directional spill, naturalistic shadow logic, atmospheric fill.",
"resolution": "1K",
"response_modalities": "IMAGE+TEXT",
"seed": 16095681705317,
"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)"
}
},
"181": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI-nb_2",
"images": [
"180",
0
]
},
"_meta": {
"title": "Save Image"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)問答
GeminiImage2Node 以圖像到圖像生成,條件為你上傳的肖像。請提高圖像保留/強度設定,避免提示描述臉部特徵或妝容變化,並用乾淨、光線佳的輸入。固定 seed 也有助於重現。
預設輸出解析度與 API 回傳的模型解析度相同(通常與輸入類似)。SaveImage 會儲存 GeminiImage2Node 輸出的原始解析度。如節點有尺寸設定,請於執行前調整。
不需要。GeminiImage2Node 透過外部 API 執行運算,ComfyUI 僅負責發送請求與儲存結果,無需本地 GPU。
本精簡流程未內建遮罩。你可用精確提示詞限制變更範圍,若需精細控制可擴充遮罩/修補步驟,或預先遮罩輸入再用 LoadImage。