AdaIN (Latent)
Color-match your latents before you even decode
- latents
- reference
- LATENT
Same idea as AdaIN (Image) - matching mean and standard deviation to a reference - but done in latent space, before the VAE decode. That matters for one practical reason: it's cheaper. Correct the color drift in the latent and you decode once, correctly, instead of decoding, correcting in pixel space, and potentially re-encoding for anything downstream that still wants a latent.
Why latent-space correction
High denoise strength in img2img workflows is a classic source of color drift - you push structure hard enough to get real changes and the overall color cast shifts with it, unrelated to anything you asked for. That drift is present in the latent, not introduced by the VAE decode, so fixing it in latent space before decode is both earlier and cheaper than fixing it after. It's the same underlying problem this whole pack circles back to more than once - IC-Light workflows are notorious for exactly this kind of skin-tone/color drift, which is why "restore what a relighting or high-denoise pass lost" is such a recurring theme across this pack's nodes.
Inputs and outputs that matter
latents- what you're correcting.reference- the latent whose statistics you're matching toward. Often your original pre-denoise latent, or a reference encoded separately.factor(-10 to 10, default 1) - strength of the match. 1 is full strength; dial it down to blend partway if a full correction overshoots.
Output: a single LATENT, ready to continue through your pipeline or go straight to VAE decode.
Installing it
ComfyUI Manager, search ComfyUI Image Filters, or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/spacepxl/ComfyUI-Image-Filters
Restart. It's tensor statistics, no model weights required. The pack's opencv dependency is the one install snag worth knowing - if you're running several custom-node packs and get import errors after adding this one, it's very likely an opencv version conflict, not this node specifically. import_error_install.bat in the repo fixes it by reinstalling all four opencv variants together; manually, uninstall the opencv-* packages and keep only opencv-contrib-python.
Where people get burned
Doing this correction in latent space is efficient, but it's also less visually predictable than doing it on decoded pixels - you're nudging statistics you can't directly see. If the correction looks wrong after decode, it's often easier to debug by testing the pixel-space version, AdaIN Image, first to confirm the reference and factor you want, then switching to the latent version once you know the settings that work.
Also worth knowing: this fixes color statistics, not missing detail. If your img2img pass at high denoise both shifted the color and lost fine texture - which is common, since both are symptoms of the same aggressive denoise - you'll likely want AdaIN Latent for the color and Restore Detail, a separate node in this pack working via frequency separation in pixel space after decode, for the texture. They're not substitutes for each other.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| latents | LATENT | — | |
| reference | LATENT | — | |
| factor | FLOAT | 1.00-10–10 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |