Relight Composited Product
Upload a composited image of your product, draw a mask in the mask editor and relight your product into the scene.
About
The 'Relight Composited Product' workflow in ComfyUI is designed to enhance product images by allowing users to adjust the lighting of a specific area within a composited image. This is particularly useful for product photographers and e-commerce businesses looking to create visually appealing images that stand out.
The workflow leverages the Qwen-Image-Edit model, known for its advanced image editing capabilities, to achieve realistic lighting adjustments. By using the 'comfyui-inpaint-cropandstitch' custom node, users can precisely target areas of the image to relight, ensuring seamless integration with the existing scene.
This workflow is beneficial for improving the visual aesthetics of product images without the need for complex photo editing software.
What you provide
- Reading the workflow
Runs in ComfyUI. This workflow can't run on this page. Open it in Comfy Cloud with everything loaded, or download it for your own ComfyUI.
Try in CloudInside the workflow
A read-only preview of the node graph. Open it in Comfy Cloud or download it to edit the nodes.
Loading the graph
Open full-size workflow preview- Author
- Rob
Requires custom nodes
- Reading the workflow
Use this workflow from code
Generated from the workflow graph and inputs when possible; stored examples are shown otherwise. Review credentials and endpoints before running code, which may incur charges.
What you need
- Runs on
- Comfy Cloud
- Key
- COMFY_API_KEY
Needs a paid Cloud plan and credits.
# 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({
"103": {
"class_type": "LoadImage",
"inputs": {
"image": "comfy_cloud_bottle.png"
},
"_meta": {
"title": "Load Image + Draw Square Mask"
}
},
"208": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI",
"images": [
"224:213",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"224:119": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "qwen_image_edit_2509_fp8_e4m3fn.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"224:131": {
"class_type": "LoraLoaderModelOnly",
"inputs": {
"lora_name": "Qwen-Image-Edit-2509-Lightning-4steps-V1.0-bf16.safetensors",
"model": [
"224:89",
0
],
"strength_model": 1
},
"_meta": {
"title": "Load LoRA"
}
},
"224:211": {
"class_type": "TextEncodeQwenImageEditPlus",
"inputs": {
"clip": [
"224:38",
0
],
"image1": [
"224:221",
1
],
"image2": [
"224:221",
1
],
"prompt": "Image blending, correcting the product's perspective angle and light and shadow to integrate the product into the background",
"vae": [
"224:39",
0
]
},
"_meta": {
"title": "Text Encode Qwen Image Edit Plus"
}
},
"224:212": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"224:222",
0
],
"vae": [
"224:39",
0
]
},
"_meta": {
"title": "VAE Decode"
}
},
"224:213": {
"class_type": "InpaintStitchImproved",
"inputs": {
"inpainted_image": [
"224:212",
0
],
"stitcher": [
"224:221",
0
]
},
"_meta": {
"title": "✂️ Inpaint Stitch (Improved)"
}
},
"224:215": {
"class_type": "PreviewImage",
"inputs": {
"images": [
"224:212",
0
]
},
"_meta": {
"title": "Preview Image"
}
},
"224:216": {
"class_type": "TextEncodeQwenImageEditPlus",
"inputs": {
"clip": [
"224:38",
0
],
"image1": [
"224:221",
1
],
"image2": [
"224:221",
1
],
"prompt": "",
"vae": [
"224:39",
0
]
},
"_meta": {
"title": "Text Encode Qwen Image Edit Plus"
}
},
"224:217": {
"class_type": "VAEEncode",
"inputs": {
"pixels": [
"224:221",
1
],
"vae": [
"224:39",
0
]
},
"_meta": {
"title": "VAE Encode"
}
},
"224:218": {
"class_type": "ModelSamplingAuraFlow",
"inputs": {
"model": [
"224:131",
0
],
"sampling": "flow",
"shift": 3
},
"_meta": {
"title": "ModelSamplingAuraFlow"
}
},
"224:219": {
"class_type": "CFGNorm",
"inputs": {
"model": [
"224:218",
0
],
"pre_cfg": False,
"strength": 1
},
"_meta": {
"title": "CFGNorm"
}
},
"224:220": {
"class_type": "PreviewImage",
"inputs": {
"images": [
"224:221",
1
]
},
"_meta": {
"title": "Preview 1024x1024 Crop Image"
}
},
"224:221": {
"class_type": "InpaintCropImproved",
"inputs": {
"context_from_mask_extend_factor": 1,
"downscale_algorithm": "bilinear",
"extend_down_factor": 1,
"extend_for_outpainting": False,
"extend_left_factor": 1,
"extend_right_factor": 1,
"extend_up_factor": 1,
"image": [
"103",
0
],
"mask": [
"103",
1
],
"mask_blend_pixels": 16,
"mask_expand_pixels": 0,
"mask_fill_holes": True,
"mask_hipass_filter": 0.1,
"mask_invert": False,
"output_padding": "0",
"output_resize_to_target_size": True,
"output_target_height": 1024,
"output_target_width": 1024,
"preresize": False,
"preresize_max_height": 16384,
"preresize_max_width": 16384,
"preresize_min_height": 1024,
"preresize_min_width": 1024,
"preresize_mode": "ensure minimum resolution",
"upscale_algorithm": "bicubic"
},
"_meta": {
"title": "✂️ Inpaint Crop (Improved)"
}
},
"224:222": {
"class_type": "KSampler",
"inputs": {
"cfg": 1,
"denoise": 1,
"latent_image": [
"224:217",
0
],
"model": [
"224:219",
0
],
"negative": [
"224:216",
0
],
"positive": [
"224:211",
0
],
"sampler_name": "euler",
"scheduler": "simple",
"seed": 1032597172973225,
"steps": 4
},
"_meta": {
"title": "KSampler"
}
},
"224:223": {
"class_type": "PreviewImage",
"inputs": {
"images": [
"224:213",
0
]
},
"_meta": {
"title": "Preview Image"
}
},
"224:38": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "qwen_2.5_vl_7b_fp8_scaled.safetensors",
"device": "default",
"type": "qwen_image"
},
"_meta": {
"title": "Load CLIP"
}
},
"224:39": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "qwen_image_vae.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"224:89": {
"class_type": "LoraLoaderModelOnly",
"inputs": {
"lora_name": "Qwen-Image-Edit-2509-Fusion.safetensors",
"model": [
"224:119",
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)Questions & answers
While designed for product images, this workflow can be adapted for any composited image where specific relighting is needed.
Ensure that the mask is accurately drawn and make use of the comfyui-inpaint-cropandstitch node to achieve a seamless blend.
Yes, the workflow is user-friendly and does not require advanced photo editing skills, making it accessible for beginners.
The LoadImage node supports common formats like JPEG and PNG, ensuring compatibility with most image files.