SwinIR S
Fit diagram
Read at 100%
Clear selection
Download SVG
Download PNG
Click a block to read its description, or select it with Tab and Enter.
SwinIR S
RGB super-resolution ×4,input3 × 64 × 64,native eval. Shapes exclude batch.
LibreYOLO
SwinIR S
RGB super-resolution ×4,input3 × 64 × 64,native eval. Shapes exclude batch.
Shallow and deep features
Input RGB
3 × 64 × 64; pad to window multiple8 (none here)
Subtract RGB mean
[0.4488,0.4371,0.4040]; img_range=1
Conv2d3×3
3 to60;s1,p1
Flatten + LayerNorm
4096 × 60; patch_size1
RSTB residual group,n=4
Six Swin blocks/group; 6 heads; window8
Final LayerNorm
60 channels; epsilon1e-5
Restore feature grid
60 × 64 × 64
Body convolution residual module
60 to60; 1conv
+
Deep feature for upsampling
60 × 64 × 64
Residual Swin Transformer Block
Token input
4096 × 60
Swin transformer block,n=6
Alternating shift0,4,0,4,0,4
Reshape to image
60 × 64 × 64
Residual convolution module
60 to60; 1conv
Flatten (no LayerNorm)
4096 × 60
+
No spatial downsampling or patch merging inside RSTB.
Initial patch embed has LayerNorm; RSTB re-embed does not.
Reconstruction and output
Conv2d3×3
60 to48;s1,p1
PixelShuffle×4
48×64² becomes3×256²
Add RGB mean back
img_range=1;3 × 256 × 256
Crop to4× original input canvas
3 × 256 × 256
No input-image residual in these registered SR presets.
Swin transformer block
Token input
4096 × 60
LayerNorm
60 channels; epsilon1e-5
Cyclic shift by(-4,-4) or identity
Shift4 on odd blocks;0 on even blocks
Partition8×8 windows
64 windows,64 tokens/window,width60
Window attention
6 heads
Reverse windows and undo cyclic shift
4096 × 60
+
LayerNorm
60 channels
Linear MLP
60 to120
GELU
Linear MLP
120 to60
+
Dropout/DropPath are identities in eval. No absolute positions.
Window attention
Window tokens
64 × 60
Linear QKV
60 to180; split into6 heads
Q × transpose(K)
Scale1/sqrt(10); 64 × 64 per head
Add relative position bias
225 × 6 learned table; indexed to64²
Add shifted-window mask
0 within region, -100 across artificial wrap boundary
Softmax over keys
Attention weights × V
6 heads, width10
Concat heads
64 × 60
Output Linear
60 to60
V is the value slice of the same QKV projection; it bypasses QK/bias/mask.
V
Convolutional residual module
Conv2d3×3
60 to60;s1,p1,bias=True
Same module choice in every RSTB and after the full body.
Concrete configurations
S: D60,N4,A6;24 transformer blocks.
M: D180,N6,A6;36 transformer blocks.
L: D240,N9,A8;54 transformer blocks.
S/M use1conv residual; L uses3conv.
S usesdirect PixelShuffle4.
M/L use two nearest×2 resize/conv stages.
All MLP hidden widths are2D:120,360,480.
All windows are8×8 withshift4 in alternating blocks.
Family view shows structural alternatives, not width-only scaling.
Source: libreyolo/models/swinir/nn.py and model.py. Revision a4d0ecc9e17f.
libreyolo.com