Light Migration for Character Portrait
Upload a portrait of your character and a reference lighting image. Generate an image with reference lighting applied and character consistency.
简介
The 'Light Migration for Character Portrait' workflow is designed to seamlessly integrate a reference lighting style into a character portrait, while maintaining the character's original features. Utilizing the Qwen-Image-Edit model, this workflow allows users to upload a portrait and a reference image that demonstrates the desired lighting conditions.
The workflow then processes these inputs to generate a new image that applies the reference lighting to the character portrait, ensuring consistency and realism. This is achieved through a series of nodes, including 'LoadImage' for importing images, 'SaveImage' for exporting the final result, and a specialized node for applying the lighting transformation.
Technically, the workflow leverages the Qwen model's capabilities in image editing and transformation. The process begins with loading the character portrait and reference lighting image using the 'LoadImage' node. The Qwen-Image-Edit model then analyzes the lighting conditions in the reference image and applies these to the character portrait. This ensures that the lighting appears natural and coherent with the character's existing features.
The workflow concludes with saving the newly generated image using the 'SaveImage' node. This technique is particularly useful for artists and designers who need to visualize characters under different lighting scenarios without compromising on character integrity.
你需要提供
- 正在读取工作流
在 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:8",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"6": {
"class_type": "LoadImage",
"inputs": {
"image": "woman_with_sunbeam.jpg"
},
"_meta": {
"title": "Load Lighting Image"
}
},
"7": {
"class_type": "LoadImage",
"inputs": {
"image": "women_with_blue_orb.jpg"
},
"_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": "参考色调,移除图1原有的光照并参考图2的光照和色调对图1重新照明, maintain canny edge of interior glass orb.",
"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": "",
"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": 1047952688565236,
"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:8": {
"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)常见问答
Yes, you can use any image that clearly demonstrates the desired lighting conditions. The model will analyze and apply these to your character portrait.
No, the workflow is designed to maintain the character's original features while applying the new lighting, ensuring consistency and realism.
The 'LoadImage' node supports common image formats such as JPEG, PNG, and BMP for both the character portrait and reference lighting image.
Currently, the workflow applies the lighting as detected from the reference image. For custom adjustments, additional editing might be required post-process.