Nodes/ComfyUI-Image-Filters/LatentNormalizeShuffle
ComfyUI Node

LatentNormalizeShuffle

Scrub the leftover image out of inverted noise

By spacepxl·Created 3 years ago·Updated 8 months ago· 293
LatentNormalizeShuffle
  • latents
  • LATENT
flatten0
normalizetrue
shuffletrue

The README's one-line description is precise and worth taking literally: "Can help break up residual image information in inversion noise." When you invert a real image back to its noise representation - the setup for editing workflows that need to preserve structure while regenerating content - that "noise" isn't actually random. It still carries a faint imprint of the original image's structure baked into it, which can bias what a sampler does with it in ways you don't want. This node exists to launder that noise: normalize its statistics, shuffle its values around, and hand back something that's harder for the leftover structure to survive in.

The problem this solves

Inversion (DDIM inversion and similar techniques) is popular precisely because feeding a model its own inverted noise, unchanged, reconstructs close to the original image - which is the whole trick for structure-preserving edits. But that "close to original" property is exactly the problem when you don't want it: the noise itself is contaminated with information about the image it came from, so even after you swap in a new prompt, remnants of the old composition can leak through. LatentNormalizeShuffle attacks this two ways at once - normalizing forces the latent's statistics back to what a sampler expects clean noise to look like (the same idea behind this pack's AdaIN nodes, just applied to noise instead of an image), and shuffling spatially scrambles values so any residual structural pattern gets broken up rather than surviving into the next generation.

Inputs and outputs

  • latents (LATENT) - the latent (typically your inverted noise) to process.
  • flatten (0–16, default 0) - controls the grouping/granularity the shuffle operates over. At 0, expect the most conservative/localized behavior; higher values change how broadly values get pooled and permuted.
  • normalize (default on) - toggles the statistics-normalization step independently of the shuffle.
  • shuffle (default on) - toggles the value-shuffling step independently of normalization. Run either one alone, or both together.

Output is a single LATENT - cleaned up, ready to hand to your sampler as the starting noise.

Installing it

ComfyUI Manager: search "ComfyUI-Image-Filters," install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/spacepxl/ComfyUI-Image-Filters

pip install -r requirements.txt (or install.bat on Windows), restart. No models involved - pure latent tensor operations.

The pack's OpenCV dependency is the one thing to watch during install: if another node pack already put a different opencv/cv2 build on your system, you can get import errors for this entire repo, not just this node. import_error_install.bat handles it by wiping every variant and reinstalling the correct one, opencv-contrib-python.

Common issues

This node is a niche, targeted fix - if you're not doing inversion-based editing, you probably don't need it, and running it on ordinary freshly-sampled noise won't do anything useful since there's no residual structure to break up in the first place. If you use it and your results still show ghosting of the original composition, try both normalize and shuffle enabled together rather than one at a time - they attack the problem from different angles and the combination is generally stronger than either alone. And because flatten changes the granularity of the shuffle, don't assume a default of 0 is always right for your latent's shape - if residual structure persists at the default, that's the first knob worth experimenting with before concluding the technique doesn't work for your case.

CategoryImage-Filters/latent

Inputs (4)

NameTypeDefaultDescription
latentsLATENT
flattenINT00–16
normalizeBOOLEANtrue
shuffleBOOLEANtrue

Outputs (1)

NameTypeDescription
LATENTLATENT