Portrait Relight
Upload your target image and a reference lighting image. Relights your target image.
概要
The 'Portrait Relight' workflow in ComfyUI is designed to enhance your images by altering their lighting based on a reference image. This workflow utilizes the Qwen-Image-Edit model to intelligently adjust the lighting of a target image, making it appear as if it was lit under the conditions of the reference image.
The process involves several key nodes, including the LoadImage node for importing images, and the SaveImage node for exporting the final result. The workflow is particularly useful for photographers and digital artists looking to achieve consistent lighting across different images or to experiment with creative lighting effects without the need for physical lighting equipment.
入力するもの
- ワークフローを読み込み中
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({
"5": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI-light_migration",
"images": [
"1:76",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"6": {
"class_type": "LoadImage",
"inputs": {
"image": "input_2-relight.png"
},
"_meta": {
"title": "Load Lighting Image"
}
},
"7": {
"class_type": "LoadImage",
"inputs": {
"image": "input_1-relight.png"
},
"_meta": {
"title": "Load Subject Image"
}
},
"1:101": {
"class_type": "LoraLoaderModelOnly",
"inputs": {
"lora_name": "Qwen-Image-Edit-2509-Light-Migration.safetensors",
"model": [
"1:89",
0
],
"strength_model": 1
},
"_meta": {
"title": "Load LoRA"
}
},
"1:102": {
"class_type": "TextEncodeQwenImageEditPlus",
"inputs": {
"clip": [
"1:38",
0
],
"image1": [
"1:104",
0
],
"image2": [
"1:105",
0
],
"prompt": "",
"vae": [
"1:39",
0
]
},
"_meta": {
"title": "Text Encode Qwen Image Edit Plus"
}
},
"1:103": {
"class_type": "TextEncodeQwenImageEditPlus",
"inputs": {
"clip": [
"1:38",
0
],
"image1": [
"1:104",
0
],
"image2": [
"1:105",
0
],
"prompt": "参考色调,移除图1原有的光照并参考图2的光照和色调对图1重新照明",
"vae": [
"1:39",
0
]
},
"_meta": {
"title": "Text Encode Qwen Image Edit Plus"
}
},
"1:104": {
"class_type": "ImageScaleToTotalPixels",
"inputs": {
"image": [
"7",
0
],
"megapixels": 1,
"resolution_steps": 1,
"upscale_method": "lanczos"
},
"_meta": {
"title": "Scale Image to Total Pixels"
}
},
"1:105": {
"class_type": "ImageScaleToTotalPixels",
"inputs": {
"image": [
"6",
0
],
"megapixels": 1,
"resolution_steps": 1,
"upscale_method": "nearest-exact"
},
"_meta": {
"title": "Scale Image to Total Pixels"
}
},
"1:108": {
"class_type": "RepeatLatentBatch",
"inputs": {
"amount": 1,
"samples": [
"1:88",
0
]
},
"_meta": {
"title": "Repeat Latent Batch"
}
},
"1:3": {
"class_type": "KSampler",
"inputs": {
"cfg": 1,
"denoise": 1,
"latent_image": [
"1:108",
0
],
"model": [
"1:75",
0
],
"negative": [
"1:103",
0
],
"positive": [
"1:102",
0
],
"sampler_name": "euler",
"scheduler": "simple",
"seed": 260787325020957,
"steps": 8
},
"_meta": {
"title": "KSampler"
}
},
"1:37": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "qwen_image_edit_2509_fp8_e4m3fn.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"1:38": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "qwen_2.5_vl_7b_fp8_scaled.safetensors",
"device": "default",
"type": "qwen_image"
},
"_meta": {
"title": "Load CLIP"
}
},
"1:39": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "qwen_image_vae.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"1:66": {
"class_type": "ModelSamplingAuraFlow",
"inputs": {
"model": [
"1:101",
0
],
"sampling": "flow",
"shift": 3
},
"_meta": {
"title": "ModelSamplingAuraFlow"
}
},
"1:75": {
"class_type": "CFGNorm",
"inputs": {
"model": [
"1:66",
0
],
"pre_cfg": False,
"strength": 1
},
"_meta": {
"title": "CFGNorm"
}
},
"1:76": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"1:3",
0
],
"vae": [
"1:39",
0
]
},
"_meta": {
"title": "VAE Decode"
}
},
"1:88": {
"class_type": "VAEEncode",
"inputs": {
"pixels": [
"1:104",
0
],
"vae": [
"1:39",
0
]
},
"_meta": {
"title": "VAE Encode"
}
},
"1:89": {
"class_type": "LoraLoaderModelOnly",
"inputs": {
"lora_name": "Qwen-Image-Edit-2509-Lightning-8steps-V1.0-bf16.safetensors",
"model": [
"1:37",
0
],
"strength_model": 1
},
"_meta": {
"title": "Load LoRA"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)よくある質問
Portrait images with clear lighting and shadow details tend to work best, as the model can effectively adjust these elements to match the reference lighting.
Yes, while optimized for portraits, the workflow can be applied to any image where lighting adjustments are desired.
No special hardware is required, but a GPU will significantly speed up the processing time, especially for high-resolution images.
You can append additional image edit prompt instructions in the workflow to maintain specific details, such as edges, during the relighting process.