Differential Diffusion
The fix for two-tone seams in masked inpainting
- model
- MODEL
If you've done classic inpainting - mask a region, regenerate it, get a visible edge where the new pixels meet the old ones - you've hit the problem DifferentialDiffusion was built for. The community has discussed the seam issue forever: standard-model inpainting treats the mask as a binary switch, everything inside gets fully regenerated, everything outside is frozen, and that hard boundary is exactly where the two-tone edge shows up. DifferentialDiffusion replaces the switch with a ramp, and the seams mostly vanish.
The mechanism. Normally the mask says "denoise these pixels, don't touch those," and it says the same thing at every step. This node, adapted from exx8's differential-diffusion, makes the mask timestep-dependent. At the start of sampling, only the darkest parts of your mask get denoised; as steps progress, the threshold slides down, so more and more of the mask region joins in. By the end, everything inside the mask has been regenerated - but the pixels near the boundary started denoising later than the center, which lets the model blend edges into the surrounding image instead of snapping to a hard line. Same result, no border.
Inputs and output. It's a model patcher:
- model - your checkpoint's MODEL, patched in place.
- strength (default 1.0, range 0–1) - how aggressively to use the differential mask. At 1.0 it's the full progressive-threshold behavior. Lower it and the node blends between that and your original soft mask, which gets you closer to classic inpainting. If your inpaint looks too conservative (the model barely changes anything), dial strength down and see.
Output is a MODEL that feeds your KSampler's model input, sitting alongside the usual SetLatentNoiseMask / InpaintModelConditioning setup. Important: it only does anything when a denoise mask is actually present. Wire it in without a mask and it's a no-op - the hook fires but there's nothing to threshold.
Where it fits. The knowledge base's inpainting essay lays out the modern landscape: dedicated inpaint models (Flux Fill, Qwen Edit) and Inpaint Crop + Stitch have largely replaced generic masked inpainting for serious work. DifferentialDiffusion is aimed at the older, still-common pattern - a regular checkpoint doing masked img2img - and it's the cheap upgrade over feathering your mask in an image editor. Feathering blurs the boundary before sampling; this blurs it during sampling, which tracks the actual denoising progress.
Gotchas. It's not a dedicated inpaint model and won't make one out of your checkpoint; it fixes edges, not understanding. If your mask has very feathered, low-value regions, the thresholding can leave those areas under-regenerated - check the edges before you commit to a batch. It's been in core for a while (the search alias is "inpaint gradient"), so it's stable-ish for an experimental node, but treat any experimental-category node's API as movable.
Community signal is real but low-key: about 140 threads mention differential diffusion over the last year and a half, mostly inside "how do I fix my inpaint seam" conversations. That's the right audience. If seams are your problem, this is the first thing to try before buying a feathering tool.
Ships with ComfyUI core - search "DifferentialDiffusion" or "inpaint gradient" to add it. No install.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| strengthopt | FLOAT | 1.000–1 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |