NAFNet 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.
NAFNet S
RGB restoration, 256 × 256 input, native NAFNetLocal eval. Shapes exclude batch.
LibreYOLO
NAFNet S
RGB restoration, 256 × 256 input, native NAFNetLocal eval. Shapes exclude batch.
Encoder, bottleneck and decoder
Input and pad to multiple of 16
3 × 256 × 256; no padding at this canvas
Conv2d 3×3, stride 1
3 to 32; padding 1
NAFBlock, n=1
32 × 256 × 256
Conv2d 2×2, stride 2
32 to 64; output 128 × 128
NAFBlock, n=1
64 × 128 × 128
Conv2d 2×2, stride 2
64 to 128; output 64 × 64
NAFBlock, n=1
128 × 64 × 64
Conv2d 2×2, stride 2
128 to 256; output 32 × 32
NAFBlock, n=28
256 × 32 × 32
Conv2d 2×2, stride 2
256 to 512; output 16 × 16
NAFBlock, n=1
512 × 16 × 16
Conv2d 1×1 + PixelShuffle ×2
512 to 1024; shuffle gives 256 × 32 × 32
+
NAFBlock, n=1
256 × 32 × 32
E3
E3
Conv2d 1×1 + PixelShuffle ×2
256 to 512; shuffle gives 128 × 64 × 64
+
NAFBlock, n=1
128 × 64 × 64
E2
E2
Conv2d 1×1 + PixelShuffle ×2
128 to 256; shuffle gives 64 × 128 × 128
+
NAFBlock, n=1
64 × 128 × 128
E1
E1
Conv2d 1×1 + PixelShuffle ×2
64 to 128; shuffle gives 32 × 256 × 256
+
NAFBlock, n=1
32 × 256 × 256
E0
E0
Conv2d 3×3, stride 1
32 to 3; padding 1
Matching E0, E1, E2, E3 labels carry identical encoder tensors.
Final image residual and crop are shown in the output panel.
Default preset depths: encoder [1,1,1,28], middle 1, decoder [1,1,1,1].
Image residual and output
Ending convolution
3 × 256 × 256
Padded input image
3 × 256 × 256
+
Crop to original image size
3 × 256 × 256 restored RGB
SimpleGate
Split channels into equal halves
Each half retains the same spatial grid
First channel half
Second channel half
×
Elementwise product; channel count is halved.
Upsample primitive
Conv2d 1×1, bias=False
Channels double; spatial dimensions fixed
PixelShuffle ×2
Channels divide by 4; height/width double
Every concrete upsample lists its numeric channel counts.
TLC calibration uses a 256×256 training canvas.
At this input, each pool spans the entire feature map.
Larger native images use local average pooling.
Convolutions use bias unless explicitly marked otherwise.
NAFBlock, channels 32
Input
32 × 256 × 256
Channel LayerNorm
32 channels; epsilon 1e-6
Conv2d 1×1
32 to 64; bias=True
Depthwise Conv2d 3×3
64 channels/groups; s=1, p=1
SimpleGate
64 to 32 channels
Average pool
32 × 1 × 1 at this input
Conv2d 1×1
32 to 32; attention weights
×
Conv2d 1×1
32 to 32
Multiply learned beta
32 channel scalars; initialized zero
+
Channel LayerNorm
32 channels; epsilon 1e-6
Conv2d 1×1
32 to 64
SimpleGate
64 to 32 channels
Conv2d 1×1
32 to 32
Multiply learned gamma
32 channel scalars; initialized zero
+
Output
32 × 256 × 256
No nonlinear activation or dropout.
NAFBlock, channels 64
Input
64 × 128 × 128
Channel LayerNorm
64 channels; epsilon 1e-6
Conv2d 1×1
64 to 128; bias=True
Depthwise Conv2d 3×3
128 channels/groups; s=1, p=1
SimpleGate
128 to 64 channels
Average pool
64 × 1 × 1 at this input
Conv2d 1×1
64 to 64; attention weights
×
Conv2d 1×1
64 to 64
Multiply learned beta
64 channel scalars; initialized zero
+
Channel LayerNorm
64 channels; epsilon 1e-6
Conv2d 1×1
64 to 128
SimpleGate
128 to 64 channels
Conv2d 1×1
64 to 64
Multiply learned gamma
64 channel scalars; initialized zero
+
Output
64 × 128 × 128
No nonlinear activation or dropout.
NAFBlock, channels 128
Input
128 × 64 × 64
Channel LayerNorm
128 channels; epsilon 1e-6
Conv2d 1×1
128 to 256; bias=True
Depthwise Conv2d 3×3
256 channels/groups; s=1, p=1
SimpleGate
256 to 128 channels
Average pool
128 × 1 × 1 at this input
Conv2d 1×1
128 to 128; attention weights
×
Conv2d 1×1
128 to 128
Multiply learned beta
128 channel scalars; initialized zero
+
Channel LayerNorm
128 channels; epsilon 1e-6
Conv2d 1×1
128 to 256
SimpleGate
256 to 128 channels
Conv2d 1×1
128 to 128
Multiply learned gamma
128 channel scalars; initialized zero
+
Output
128 × 64 × 64
No nonlinear activation or dropout.
NAFBlock, channels 256
Input
256 × 32 × 32
Channel LayerNorm
256 channels; epsilon 1e-6
Conv2d 1×1
256 to 512; bias=True
Depthwise Conv2d 3×3
512 channels/groups; s=1, p=1
SimpleGate
512 to 256 channels
Average pool
256 × 1 × 1 at this input
Conv2d 1×1
256 to 256; attention weights
×
Conv2d 1×1
256 to 256
Multiply learned beta
256 channel scalars; initialized zero
+
Channel LayerNorm
256 channels; epsilon 1e-6
Conv2d 1×1
256 to 512
SimpleGate
512 to 256 channels
Conv2d 1×1
256 to 256
Multiply learned gamma
256 channel scalars; initialized zero
+
Output
256 × 32 × 32
No nonlinear activation or dropout.
NAFBlock, channels 512
Input
512 × 16 × 16
Channel LayerNorm
512 channels; epsilon 1e-6
Conv2d 1×1
512 to 1024; bias=True
Depthwise Conv2d 3×3
1024 channels/groups; s=1, p=1
SimpleGate
1024 to 512 channels
Average pool
512 × 1 × 1 at this input
Conv2d 1×1
512 to 512; attention weights
×
Conv2d 1×1
512 to 512
Multiply learned beta
512 channel scalars; initialized zero
+
Channel LayerNorm
512 channels; epsilon 1e-6
Conv2d 1×1
512 to 1024
SimpleGate
1024 to 512 channels
Conv2d 1×1
512 to 512
Multiply learned gamma
512 channel scalars; initialized zero
+
Output
512 × 16 × 16
No nonlinear activation or dropout.
Fresh s/l preset topology. Loaded checkpoints can infer different depths, for example SIDD encoder [2,2,4,8] and middle 12.
Those checkpoint-derived custom layouts are not mislabeled as the constructor presets. No pretrained checkpoint was loaded.
Source: libreyolo/models/nafnet/nn.py and model.py. Revision a4d0ecc9e17f.
libreyolo.com