Nodes/ComfyUI_SamplingUtils/Inject Noise to Latent SamplingUtils
ComfyUI Node

Inject Noise to Latent SamplingUtils

Precise noise, exactly where you want it

By silveroxides·Created 11 months ago·Updated 3 months ago· 20
Inject Noise to Latent SamplingUtils
  • latents
  • noise
  • mask
  • noised_latents
strength0.1000
normalizefalse
averagefalse
mix_randn_amount0.000
seed123

Diffusion is a noisy business, and sometimes you want your noise, not the sampler's. Inject Noise to Latent takes a latent and a second noise latent and mixes them under your control - by strength, by mask, or by averaging - and hands the result back as a noised_latents output. It's the tool for img2img-style workflows where you want to reuse a specific noise latent, add a controlled amount of chaos, or noise only part of an image.

How it works

The core is one line: noised = latents + noise * strength. But the source does a lot of unglamorous shape-matching first, and that's where the node earns its keep. It handles:

  • 4D vs 5D mismatch - image latents are [B,C,H,W], video latents are [B,C,T,H,W]; it unsqueezes, squeezes, or takes the first frame so the two can broadcast.
  • Channel and batch mismatch - expands, repeats, or truncates the noise to match the latent's shape.
  • Spatial mismatch - resizes the noise with bicubic interpolation to the latent's resolution.

Then the knobs apply, in order:

  • average (default off) - instead of latents + noise*strength, it does (latents + noise) / 2, a full blend.
  • normalize - divides the result by its standard deviation, re-energizing the tensor after mixing.
  • mask (optional) - blends mask * noised + (1−mask) * original, so you can noise only a region and leave the rest untouched. This is the standout feature: region-targeted noise injection for inpainting or regeneration.
  • mix_randn_amount + seed - if you want extra fresh gaussian noise on top (not the noise latent you supplied), this adds mix_randn_amount * randn seeded by seed.

strength runs 0–200 (default 0.1); at 0 you get the original latent back, above 1 you're overdriving the injected noise.

When you'd actually use it

The most common real pattern: capture the noise latent from a KSampler, save it, and re-inject the same noise into a later latent so you can do exact-edit or seed-transfer tricks between runs. The mask input makes it a clean way to add noise to just the background while keeping the subject latent intact - a trick people normally hack together with several masking nodes. If you mostly sample with default settings and never touch latents directly, you can skip this one; it's a power-user node.

Install

ComfyUI Manager → search ComfyUI_SamplingUtils, or:

cd ComfyUI/custom_nodes
git clone https://github.com/silveroxides/ComfyUI_SamplingUtils

then restart ComfyUI. Real deps from requirements.txt: kornia, scipy, pilgram, opencv-python, unifiedefficientloader>=0.5.0. Pack note: README marks it DEPRECATED in favor of ComfyUI-UtilsCollection - this node still runs fine, but latent-utility nodes are exactly the kind that get renamed in a migration, so expect the search to change.

Categoryutils/latent

Inputs (8)

NameTypeDefaultDescription
latentsLATENT
strengthFLOAT0.10000–200
noiseLATENT
normalizeBOOLEANfalse
averageBOOLEANfalse
maskoptMASK
mix_randn_amountoptFLOAT0.0000–1000
seedoptINT1230–18446744073709550000

Outputs (1)

NameTypeDescription
noised_latentsLATENT