Nodes/Eric_Image_Processing_Nodes/SwinIR Image Restoration
ComfyUI Node

SwinIR Image Restoration

A transformer for six different restoration jobs in one node

By EricRollei·Created 9 months ago·Updated 8 months ago· 9
SwinIR Image Restoration
  • image
  • restored_image
taskclassical_sr
model_variantauto
window_size8
device_preferenceauto

SwinIR is one of those models that quietly became infrastructure. It's not the newest thing in the pack - Restormer and DiffBIR sitting right next to it are both later and heavier - but it's the one node here that does six genuinely different restoration jobs off a single task switch: super-resolution, lightweight super-resolution, GAN-based real-world super-resolution, color denoising, grayscale denoising, and JPEG artifact removal. If you just need a competent, non-generative restoration pass and don't want to hunt for six separate tools, this is the one-stop option.

How it works

SwinIR runs on a Swin Transformer backbone - attention computed over shifted local windows instead of the whole image at once. That's the trick that made transformers viable for image restoration in the first place: full self-attention over every pixel is too expensive, but windowed, shifted attention gets you most of the long-range context at CNN-like cost. Compared to the plain convolutional restorers that came before it (RCAN, EDSR-era stuff), SwinIR handles texture and structure more coherently because each window can still "see" its neighbors after the shift. It sits below the diffusion-based restorers (DiffBIR, SUPIR-class models) in raw capability - it repairs, it doesn't invent - but it's faster and won't rewrite content the way a generative model can.

The inputs and outputs that matter

  • image - required.
  • task - the one input that actually changes what this node does: classical_sr for clean-source super-resolution, lightweight_sr for a faster SR pass, real_sr for GAN-based real-world SR (the one to reach for on photos with actual compression/noise, not synthetic test images), color_dn / gray_dn for denoising, jpeg_car for JPEG compression artifact removal.
  • model_variant (optional, default auto) - lets you pick the specific checkpoint for your task: scale factors 2x–8x for the SR tasks, light_noise/medium_noise/heavy_noise (σ=15/25/50) for denoising, jpeg_q10jpeg_q40 for artifact removal matched to how aggressively the source was compressed. Leave it on auto unless you actually know your noise level or original JPEG quality.
  • window_size (optional, default 8) - the transformer's attention window. 8 is the balanced default; smaller is faster with less context, larger is slower but sees more of the image per step.
  • device_preference - auto/cpu/cuda.
  • Output: restored_image.

How to install it

Search Eric_Image_Processing_Nodes in ComfyUI Manager, or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/EricRollei/Eric_Image_Processing_Nodes
cd Eric_Image_Processing_Nodes
pip install -r requirements.txt

Restart ComfyUI. Core dependencies (numpy, opencv-python, scikit-image, scipy, PyWavelets) are what actually gate import; torch is an optional extra the pack needs specifically for nodes like this one. SwinIR's pretrained weights aren't bundled - they download automatically the first time you run a given task/model_variant combination, so the first use of each task is slower than the rest.

Common issues & troubleshooting

Every task switch re-downloads a model. Because each task uses a different checkpoint family, switching from real_sr to jpeg_car isn't free - it's a fresh download the first time you use that combination. Not a bug, just how the multi-task design works.

Denoising result looks either barely-touched or waxy. You picked the wrong noise level. light_noise/medium_noise/heavy_noise need to roughly match your actual noise - too low and it does almost nothing, too high and it smooths away real detail. If you don't know the noise level, that's what auto is for.

Slow on CPU. This is a transformer, not a lightweight filter - set device_preference to cuda if you have a GPU. window_size above 8 makes it noticeably slower still; only push it up if you actually need the extra quality.

Real-world photo, but you used classical_sr. classical_sr assumes clean, near-synthetic degradation. If your source has compression artifacts or camera noise, real_sr (GAN-based) is the one that was actually trained to handle it - this is the single most common mismatch with this node.

CategoryEric's Image Processing

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
taskCOMBOclassical_srRestoration task: • classical_sr: Classical super-resolution (clean images) • lightweight_sr: Lightweight super-resolution (faster) • real_sr: Real-world super-resolution (GAN-based) • color_dn: Color image denoising • gray_dn: Grayscale image denoising • jpeg_car: JPEG compression artifact removal
model_variantoptCOMBOautoModel variant selection: • auto: Automatically select best model for task • 2x-8x: Super-resolution scales • light_noise: σ=15 (for denoising) • medium_noise: σ=25 (for denoising) • heavy_noise: σ=50 (for denoising) • jpeg_q10-40: JPEG quality levels for artifact removal
window_sizeoptINT84–16Transformer window size: • 4-6: Faster processing, less context • 8: Balanced (recommended) • 10-16: Better quality, slower
device_preferenceoptCOMBOautoProcessing device preference

Outputs (1)

NameTypeDescription
restored_imageIMAGE