Latent Match Channelwise
Matching one latent's color stats to another
- model
- latent_target
- latent_source
- mask_target
- mask_source
- latent_matched
This is the "do something" node in RES4LYF's channel-wise latent toolkit - where Latent Get Channel Means measures and LatentBatch_channels lets you manually push values around, Latent Match Channelwise automates the whole job: give it a target latent and a source latent, and it adjusts the target's per-channel statistics to match the source's. It's the latent-space equivalent of a color-match tool in a photo editor, done on the tensor before decode instead of on pixels after.
The obvious use is consistency: matching color and tone between frames in a video generation, matching a guided/composited region back to the surrounding latent so it doesn't look pasted in, or pulling a generation's color balance toward a reference image you liked. Because it needs a model input, it's presumably using architecture-specific information to interpret the latent's channels correctly - which matters, since a 4-channel SD1.5 latent and a 16-channel Flux latent don't mean the same thing per channel.
Inputs and output
model(MODEL) - required. Ties the matching operation to the architecture the latents belong to.latent_target(LATENT) - required, the latent you're adjusting.latent_source(LATENT) - required, the latent whose statistics you're matching toward.mask_targetandmask_source(MASK) - optional. Restrict the matching to specific regions in either latent instead of operating across the whole frame - useful when you only want a composited or guided region to match, not the entire image.extra_options(STRING, multiline) - a free-text field for advanced flags. This is a real pattern elsewhere in the pack too: the README mentions typing flags liketruncate_conditioning=truedirectly into anextra_optionsbox on the main sampler rather than exposing a separate widget for every advanced setting.- Output:
latent_matched(LATENT) - the target latent, adjusted.
Installing it
Comes with the full RES4LYF pack:
- ComfyUI Manager - search "RES4LYF," install, restart.
- Manual -
cd ComfyUI/custom_nodes && git clone https://github.com/ClownsharkBatwing/RES4LYF, thencd RES4LYF && pip install -r requirements.txt, restart.
No extra downloads for this node.
Common issues
Matching does nothing visible. Confirm latent_target and latent_source are actually different enough for a match to be noticeable, and that you haven't accidentally wired the same latent into both slots.
Masked matching bleeds outside the intended region. If you're using mask_target or mask_source, make sure the mask is precise and matches the resolution of its corresponding latent - a loose or low-resolution mask will pull in more of the frame than you meant to adjust.
Model mismatch between target and source latents. If the two latents came from different architectures (a 4-channel latent and a 16-channel latent, say), matching across them isn't a sensible operation - keep latent_target and latent_source from the same model family, and make sure the model input matches what actually produced them.
Not sure what to put in extra_options. Leave it blank unless you have a specific documented flag to set. The pack doesn't publish a full list of recognized options for this field, so treat it as an advanced escape hatch rather than something to fill in by default.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| latent_target | LATENT | — | |
| latent_source | LATENT | — | |
| mask_targetopt | MASK | — | |
| mask_sourceopt | MASK | — | |
| extra_optionsopt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| latent_matched | LATENT | — |