NAFNet S

Click a block to read its description, or select it with Tab and Enter.

NAFNet SRGB restoration, 256 × 256 input, native NAFNetLocal eval. Shapes exclude batch.LibreYOLONAFNet SRGB restoration, 256 × 256 input, native NAFNetLocal eval. Shapes exclude batch.Encoder, bottleneck and decoderInput and pad to multiple of 163 × 256 × 256; no padding at this canvasConv2d 3×3, stride 13 to 32; padding 1NAFBlock, n=132 × 256 × 256Conv2d 2×2, stride 232 to 64; output 128 × 128NAFBlock, n=164 × 128 × 128Conv2d 2×2, stride 264 to 128; output 64 × 64NAFBlock, n=1128 × 64 × 64Conv2d 2×2, stride 2128 to 256; output 32 × 32NAFBlock, n=28256 × 32 × 32Conv2d 2×2, stride 2256 to 512; output 16 × 16NAFBlock, n=1512 × 16 × 16Conv2d 1×1 + PixelShuffle ×2512 to 1024; shuffle gives 256 × 32 × 32+NAFBlock, n=1256 × 32 × 32E3E3Conv2d 1×1 + PixelShuffle ×2256 to 512; shuffle gives 128 × 64 × 64+NAFBlock, n=1128 × 64 × 64E2E2Conv2d 1×1 + PixelShuffle ×2128 to 256; shuffle gives 64 × 128 × 128+NAFBlock, n=164 × 128 × 128E1E1Conv2d 1×1 + PixelShuffle ×264 to 128; shuffle gives 32 × 256 × 256+NAFBlock, n=132 × 256 × 256E0E0Conv2d 3×3, stride 132 to 3; padding 1Matching 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 outputEnding convolution3 × 256 × 256Padded input image3 × 256 × 256+Crop to original image size3 × 256 × 256 restored RGBSimpleGateSplit channels into equal halvesEach half retains the same spatial gridFirst channel halfSecond channel half×Elementwise product; channel count is halved.Upsample primitiveConv2d 1×1, bias=FalseChannels double; spatial dimensions fixedPixelShuffle ×2Channels divide by 4; height/width doubleEvery 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 32Input32 × 256 × 256Channel LayerNorm32 channels; epsilon 1e-6Conv2d 1×132 to 64; bias=TrueDepthwise Conv2d 3×364 channels/groups; s=1, p=1SimpleGate64 to 32 channelsAverage pool32 × 1 × 1 at this inputConv2d 1×132 to 32; attention weights×Conv2d 1×132 to 32Multiply learned beta32 channel scalars; initialized zero+Channel LayerNorm32 channels; epsilon 1e-6Conv2d 1×132 to 64SimpleGate64 to 32 channelsConv2d 1×132 to 32Multiply learned gamma32 channel scalars; initialized zero+Output32 × 256 × 256No nonlinear activation or dropout.NAFBlock, channels 64Input64 × 128 × 128Channel LayerNorm64 channels; epsilon 1e-6Conv2d 1×164 to 128; bias=TrueDepthwise Conv2d 3×3128 channels/groups; s=1, p=1SimpleGate128 to 64 channelsAverage pool64 × 1 × 1 at this inputConv2d 1×164 to 64; attention weights×Conv2d 1×164 to 64Multiply learned beta64 channel scalars; initialized zero+Channel LayerNorm64 channels; epsilon 1e-6Conv2d 1×164 to 128SimpleGate128 to 64 channelsConv2d 1×164 to 64Multiply learned gamma64 channel scalars; initialized zero+Output64 × 128 × 128No nonlinear activation or dropout.NAFBlock, channels 128Input128 × 64 × 64Channel LayerNorm128 channels; epsilon 1e-6Conv2d 1×1128 to 256; bias=TrueDepthwise Conv2d 3×3256 channels/groups; s=1, p=1SimpleGate256 to 128 channelsAverage pool128 × 1 × 1 at this inputConv2d 1×1128 to 128; attention weights×Conv2d 1×1128 to 128Multiply learned beta128 channel scalars; initialized zero+Channel LayerNorm128 channels; epsilon 1e-6Conv2d 1×1128 to 256SimpleGate256 to 128 channelsConv2d 1×1128 to 128Multiply learned gamma128 channel scalars; initialized zero+Output128 × 64 × 64No nonlinear activation or dropout.NAFBlock, channels 256Input256 × 32 × 32Channel LayerNorm256 channels; epsilon 1e-6Conv2d 1×1256 to 512; bias=TrueDepthwise Conv2d 3×3512 channels/groups; s=1, p=1SimpleGate512 to 256 channelsAverage pool256 × 1 × 1 at this inputConv2d 1×1256 to 256; attention weights×Conv2d 1×1256 to 256Multiply learned beta256 channel scalars; initialized zero+Channel LayerNorm256 channels; epsilon 1e-6Conv2d 1×1256 to 512SimpleGate512 to 256 channelsConv2d 1×1256 to 256Multiply learned gamma256 channel scalars; initialized zero+Output256 × 32 × 32No nonlinear activation or dropout.NAFBlock, channels 512Input512 × 16 × 16Channel LayerNorm512 channels; epsilon 1e-6Conv2d 1×1512 to 1024; bias=TrueDepthwise Conv2d 3×31024 channels/groups; s=1, p=1SimpleGate1024 to 512 channelsAverage pool512 × 1 × 1 at this inputConv2d 1×1512 to 512; attention weights×Conv2d 1×1512 to 512Multiply learned beta512 channel scalars; initialized zero+Channel LayerNorm512 channels; epsilon 1e-6Conv2d 1×1512 to 1024SimpleGate1024 to 512 channelsConv2d 1×1512 to 512Multiply learned gamma512 channel scalars; initialized zero+Output512 × 16 × 16No 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