Nodes/ComfyUI-NAFNet-Residual/NAFNet Restoration
ComfyUI Node

NAFNet Restoration

It's Not an Upscaler — It's the Grid-Killer Your Qwen/Wan Images Need

By DraconicDragon·Created about a month ago·Updated about a month ago· 4
NAFNet Restoration
  • upscale_model
  • image
  • IMAGE
modeFull

Let's get the name out of the way: NAFNet Upscale does not make your image bigger. It's a 1x restoration pass. What it actually does is scrub the faint grid pattern that Qwen and Wan VAEs leave baked into decoded images - the artifact that, in a real-time viewer, you'd normally fight with a Reshade shader called Nyquist Notch. This node does that job as a learned model, at full quality, without touching anything else.

That's a genuinely useful niche. If you've generated with Qwen-Image or Wan you've seen it: flat gradients, shadows, and film-grain areas come out with a subtle checkerboard/moiré texture. It's annoying at 1x and it's a real problem once you enlarge the image, because the grid gets baked in and sharpened along with everything else. The standard pipeline guidance is fix defects first, upscale last - this node is the "fix defects" rung. Run the image through it, then hand the clean result to SeedVR2 or an ESRGAN model for the actual enlargement.

How it works

NAFNet is a real, well-regarded restoration architecture - megvii-research/nafnet, ECCV 2022, "Nonlinear Activation Free Network." DraconicDragon trained a NAFNet-small variant, NAFNet-VAE-DeGrid (Apache-2.0), on Qwen VAE encode→decode pairs, so the model learns "what does the VAE's grid corrupt here?" Crucially, the model outputs a residual, not the finished image: the difference between the clean and the corrupt version, which you then add back to the original.

That one design choice is the whole point of the pack. ComfyUI clamps upscale-model output to the normal 0–1 image range, so the stock route - Load Upscale Model → Upscale Image (using Model), then Image Blend at -1.0 to add the residual back - silently throws away the negative residuals and only gives you half the fix. This node grabs the raw residual before the clamp and lets you choose what to apply. It tiles the image at 512px with 32px overlap, runs the model, adds the residual, and if you run out of VRAM it automatically halves the tile size down to a 128px floor, so big images work on modest cards.

The inputs

Only three, and the only one you'll fiddle with is mode:

  • upscale_model - a NAFNet model loaded with the built-in Load Upscale Model node. Feed it anything else and the node errors out with "NAFNet Restoration requires a NAFNet model."
  • image - what you want scrubbed.
  • mode - Full adds the entire residual (both dark and bright corrections), Dark Pixels Mainly applies only positive residuals and lands close to the Nyquist Notch result, Bright Pixels Mainly applies only the negative ones. Default is Full, and Full is what you want most of the time; the split modes are there for when one side over-corrects.

The output is a single IMAGE at the same resolution as the input. Wire it to Save Image, or straight into whatever does your real upscaling.

Install

ComfyUI Manager, search "ComfyUI-NAFNet-Residual", or the manual way:

cd ComfyUI/custom_nodes
git clone https://github.com/DraconicDragon/ComfyUI-NAFNet-Residual

Then restart ComfyUI. There are no extra pip dependencies - it rides on ComfyUI's own torch and Spandrel. You do need the model file itself: grab VAE_DeGrid_NAFNet_small_v1.1.safetensors from the HF repo and drop it in ComfyUI/models/upscale_models/. Go for the v1.1 finetune, not v1.0 - the author says it performs noticeably better and doesn't suffer the repetitive pattern that shows up on artifact-heavy images.

The patch and the gotchas

The pack also ships a global NAFNet Residual Patch setting (Settings → NAFNet Residual → Residual Mode: Disabled / Full / Dark Pixels Mainly / Bright Pixels Mainly). It monkey-patches Spandrel so the normal Load Upscale Model → Upscale Image (using Model) workflow applies the residual automatically. Only models detected as NAFNet get patched; your ESRGANs are untouched. It's convenient, but it's also the fiddliest part - the author calls it "mostly a nice to have" and openly asks for bug reports, because it modifies ComfyUI/Spandrel internals. The standalone node is the safer default; reach for the patch only if you're attached to the stock workflow.

Two things will bite you:

  • Cached results. After changing the patch mode, ComfyUI happily reuses old node outputs. Change a value in a used node, or otherwise invalidate the workflow cache, before re-running.
  • Scope. This model learned Qwen/Wan VAE artifacts, mostly from anime and illustration data. The author's own word on realism is "maybe realism, idk." It won't denoise diffusion noise, won't repair JPEG, and can smooth film grain. Don't point it at photos and expect magic - point it at your Qwen/Wan generation, then upscale.
Categoryimage/restoration

Inputs (3)

NameTypeDefaultDescription
upscale_modelUPSCALE_MODELA NAFNet model loaded with "Load Upscale Model".
imageIMAGEImage to restore with NAFNet.
modeCOMBOFullControls which NAFNet residual corrections are applied. Full - applies the complete residual. Dark Pixels Mainly - applies only positive residuals, which correct dark artifact pixels; The result of this option is closer to Nyquist Notch shader. Bright Pixels Mainly - applies only negative residuals, which correct bright artifact pixels.

Outputs (1)

NameTypeDescription
IMAGEIMAGE