SwinIR Model Loader
Where 90% of SwinIR problems actually live
- SWINIR_MODEL
This node doesn't upscale anything. What it does is load a SwinIR model file and build the network architecture around it, producing a SWINIR_MODEL that you feed to SwinIR Upscale/Denoise. Which sounds boring until you realise it's the node holding all nine config knobs - and the one where misconfiguration produces output that looks like the other node broke. Get this right once and you never think about it again.
SwinIR is the 2021 Swin Transformer for image restoration, the deterministic ancestor of the modern generative upscalers. In the upscaling ladder from the wider ComfyUI knowledge base it lives on the non-generative rung: it adds resolution and cleans noise without hallucinating detail the way SeedVR2 or SUPIR will. It's an old name - it shipped as a built-in upscaler in A1111 back in 2022 - but it's still one of the few fast, predictable, low-VRAM options that also does real denoising.
How it works
The loader pulls the model file from ComfyUI's upscale_models folder, then parses your comma-separated depths and num_heads strings into the actual network structure. model_type decides the upsampling path: classicalSR uses pixel-shuffle, lightweightSR a direct pixel-shuffle, realSR nearest-neighbour plus convolution, and denoising no upsampler at all (it prints a warning if you pair it with an upscale other than 1). Weights are loaded with strict=False, handling the params_ema / params state-dict wrappers the official checkpoints ship in.
Inputs that matter
Nine required inputs, but most of them you can forget after one setup:
model_name- dropdown populated from yourupscale_modelsfolder. Pick your downloaded.pth.model_type-classicalSR,lightweightSR,realSR, ordenoising. Match it to the file you downloaded.upscale(default 4) - the scale factor baked into the model, not an arbitrary "make it 4x" button. It must match the file (_x2,_x4in the filename).img_size(default 128) - the trap. This must equal the model's training size, which is encoded in the filename:s64means 64,s128means 128. The README's config tables spell this out per model.- The rest -
window_size,embed_dim,depths,num_heads,mlp_ratio- are the architecture itself. Use the README tables.
Output is a single SWINIR_MODEL that wires into SwinIR Upscale/Denoise.
The trap: strict=False
Here's what burns people. The loader uses strict=False when loading weights, which means a mismatched architecture doesn't crash - it just loads whatever keys line up and silently ignores the rest. Set img_size wrong, or type "6,6,6,6" for a model that wants six layers, and you get a soft, washed-out, or subtly wrong upscale with zero error messages. If your SwinIR output looks bad, audit the loader config against the README's "Common Model Configurations" table before touching anything else.
Install
ComfyUI Manager, search "ComfyUI-SwinIR". Or:
cd ComfyUI/custom_nodes
git clone https://github.com/alexcong/ComfyUI-SwinIR.git
cd ComfyUI-SwinIR
pip install -r requirements.txt
Dependencies are timm, numpy, and torch - timm is the one that'll actually be missing if pip complains. Models come from the official SwinIR releases and go in ComfyUI/models/upscale_models/. If model_name shows nothing, that's your problem - the folder's empty or the file's in the wrong place. Restart ComfyUI after installing.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| model_name | COMBO | 0 options: | |
| model_type | COMBO | 4 options: classicalSR, lightweightSR, realSR, denoising | |
| upscale | INT | 41–8 | — |
| window_size | INT | 84–32 | — |
| embed_dim | INT | 18048–512 | — |
| depths | STRING | 6, 6, 6, 6, 6, 6 | — |
| num_heads | STRING | 6, 6, 6, 6, 6, 6 | — |
| mlp_ratio | FLOAT | 2.01–8 | — |
| img_size | INT | 12832–256 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| SWINIR_MODEL | SWINIR_MODEL | — |