Nodes/RES4LYF/Latent Match Channelwise
ComfyUI Node Runs on cloud

Latent Match Channelwise

Matching one latent's color stats to another

By ClownsharkBatwing·Created 2 years ago·Updated 22 days ago· 1,222
Latent Match Channelwise
  • model
  • latent_target
  • latent_source
  • mask_target
  • mask_source
  • latent_matched
extra_options

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_target and mask_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 like truncate_conditioning=true directly into an extra_options box 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, then cd 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.

CategoryRES4LYF/latents

Inputs (6)

NameTypeDefaultDescription
modelMODEL
latent_targetLATENT
latent_sourceLATENT
mask_targetoptMASK
mask_sourceoptMASK
extra_optionsoptSTRING

Outputs (1)

NameTypeDescription
latent_matchedLATENT