MSE Heatmap ๐
See exactly where two latents actually differ
- latent1
- latent2
- image
- IMAGE
You've probably had the experience of A/B testing two generations - same seed, one variable changed, like a LoRA on vs off, or two different samplers - and squinting between them trying to figure out what actually moved. MSE Heatmap automates the squinting: feed it two latents and it computes the pixel-by-pixel mean squared error between them, then overlays that as a heatmap on top of a reference image so you can see exactly where the two runs diverge instead of guessing.
What it's doing, mechanically
Mean squared error is about as simple as image-diffing gets: for every corresponding location, square the difference and that's your error value. High values mean the two latents disagree strongly there; near zero means they agree. This node runs that comparison, then paints the result as a heatmap composited onto a separate image input at a blend strength you control - so instead of a raw difference map that's hard to read on its own, you get the divergence visualized in context against the actual picture.
It lives in the pack's for_test category, which is the author's own signal that this is a diagnostic/experimental tool rather than something meant for a production pipeline - and that's exactly the right way to think about it. This is for understanding why two runs differ, not for generating anything itself.
Inputs and outputs
Required:
- latent1 / latent2 - the two latents you want compared. Same shape expected, obviously - this is a straight per-element comparison, not an alignment algorithm.
- image - the reference image the heatmap gets composited onto. Typically you'd decode one of the two latents (or a shared base render) and use that.
- alpha - how strongly the heatmap overlay blends over the reference image, 0-1, default 0.3.
Output is a single IMAGE: your reference picture with the divergence heatmap painted on top.
Installing it
ComfyUI Manager, search "cgem156-ComfyUI". Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/laksjdjf/cgem156-ComfyUI
Restart ComfyUI. No model download involved - this is pure tensor math on latents you've already generated, so it's cheap and instant to run.
Where this is actually useful, and where it isn't
The obvious use case is debugging: comparing a latent before and after a LoRA patch, before and after a sampler swap, or across two seeds at otherwise identical settings, to see spatially where the change actually landed rather than just eyeballing the decoded images side by side. It's genuinely handy for that.
Where it'll mislead you: MSE in latent space doesn't map cleanly onto perceptual difference in pixel space - a small, spatially concentrated latent change can decode into a large visible difference, and a large-looking latent difference can sometimes decode into something barely noticeable, because the VAE's decoding isn't linear. Treat this as a tool for locating where two latents disagree, not as a measurement of how visually different the final images will be. And since latent1/latent2 need matching dimensions, mismatched latent sizes (say, comparing a base-resolution latent against an upscaled one) will error rather than silently resize - bring them to the same shape first if you want a comparison at all.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| latent1 | LATENT | โ | |
| latent2 | LATENT | โ | |
| image | IMAGE | โ | |
| alpha | FLOAT | 0.300โ1 | โ |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | โ |