Color Match (Masked)
The fix for that hue shift your inpaint keeps giving you
- target
- reference
- exclude_mask
- image
If you've inpainted anything and noticed the whole image comes back slightly warmer, cooler, darker, or more saturated than what you started with - even in parts you didn't touch - this is the node for that. It's not fixing your mask edges; it's correcting a global color/brightness drift that VAE encode-decode round-trips and some newer edit models are notorious for introducing across the entire frame, mask or no mask.
Why this keeps happening
The mechanism is simple once you know it: the model's VAE isn't perfectly lossless, so every encode/decode cycle nudges color and brightness a little. Normally that's invisible. But it becomes a real problem with newer editing-style models - this is genuinely worse on things like Flux 2 Klein, where people report hue and lighting shifts on almost every generation, sometimes subtle enough you only notice next to the original. The README calls this out directly: it's particularly useful for refinements or edits done with Flux 2 Klein.
How it works
You give it target (your generated/denoised output) and reference (the original input image), plus a strength (0–1, default 1). The trick is the optional exclude_mask: hand it the same mask you used for inpainting, and the node analyzes the color shift using only the unmasked region - the part that's supposed to be identical between reference and target - then applies that correction across the entire image. The logic is: whatever shift happened outside the mask (where nothing was supposed to change) is a good estimate of the same shift happening inside it too.
This node is built on kijai's KJNodes color-match implementation, extended with the exclude-mask behavior specifically for this use case.
Inputs and outputs
- target - your denoised/generated result.
- reference - the original image before inpainting.
- strength (FLOAT, 0–1, default 1) - how much of the computed correction to apply.
- exclude_mask (optional MASK) - your inpaint mask, so the correction is computed from the region that should have stayed unchanged.
Output is a single corrected image.
Installing it
Standard pack install - ComfyUI Manager (search "ComfyUI Inpaint Nodes"), or:
cd ComfyUI/custom_nodes
git clone https://github.com/Acly/comfyui-inpaint-nodes.git
Restart ComfyUI. No model download for this one.
Common issues
It's an improvement, not a cure. Real-world feedback on this exact node against Flux 2 Klein is candid about that: it helps a lot but isn't perfect, especially on strong shifts. Don't expect it to fully undo aggressive hue drift on its own - treat it as one layer of the fix, alongside sane strength/CFG settings on your actual sampler.
Only useful when the shift is uniform. This node assumes the same color shift happened both inside and outside the mask, and corrects the whole image based on the outside. If your problem is a local mismatch confined to just the masked region rather than a global shift, this isn't the tool - that's closer to a blending/compositing problem, not a color-correction one.
Run it before you composite, on the full decoded output, not after you've already pasted the masked region back - the exclude_mask logic needs to see the shift in the untouched area to measure it correctly.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| target | IMAGE | — | |
| reference | IMAGE | — | |
| strength | FLOAT | 1.000–1 | — |
| exclude_maskopt | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |