SegFormer B0

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

SegFormer B0Semantic segmentation, 150 classes, 512 × 512 RGB, native eval. Shapes exclude batch.LibreYOLOSegFormer B0Semantic segmentation, 150 classes, 512 × 512 RGB, native eval. Shapes exclude batch.MiT encoderRGB input and ImageNet normalization3 × 512 × 512Conv2d overlap embedding3 to 32; k=7, s=4, p=3Flatten + LayerNorm128 × 128 spatial tokens, width 32Transformer block, n=21 heads; reduction 8LayerNorm + restore spatial map32 × 128 × 128F1Conv2d overlap embedding32 to 64; k=3, s=2, p=1Flatten + LayerNorm64 × 64 spatial tokens, width 64Transformer block, n=22 heads; reduction 4LayerNorm + restore spatial map64 × 64 × 64F2Conv2d overlap embedding64 to 160; k=3, s=2, p=1Flatten + LayerNorm32 × 32 spatial tokens, width 160Transformer block, n=25 heads; reduction 2LayerNorm + restore spatial map160 × 32 × 32F3Conv2d overlap embedding160 to 256; k=3, s=2, p=1Flatten + LayerNorm16 × 16 spatial tokens, width 256Transformer block, n=28 heads; reduction 1LayerNorm + restore spatial map256 × 16 × 16F4No learned position embeddings; Mix-FFN supplies spatial mixing.All-MLP decode headF4256 × 16 × 16Flatten + Linear256 to 256Restore feature map256 × 16 × 16Bilinear resize256 × 128 × 128F3160 × 32 × 32Flatten + Linear160 to 256Restore feature map256 × 32 × 32Bilinear resize256 × 128 × 128F264 × 64 × 64Flatten + Linear64 to 256Restore feature map256 × 64 × 64Bilinear resize256 × 128 × 128F132 × 128 × 128Flatten + Linear32 to 256Restore feature map256 × 128 × 128Bilinear resize256 × 128 × 128Concat in reverse stage order: F4, F3, F2, F11024 × 128 × 128Conv2d 1×11024 to 256; bias=FalseBatchNorm2d256 channelsReLUDropout 0.1Identity in evalConv2d 1×1256 to 150; bias=TrueBilinear resize to input sizealign_corners=FalseSemantic logits150 × 512 × 512All linear and overlap/reduction convolutions have bias unless marked otherwise.Stage 1 transformer blockInput tokens16384 × 32LayerNorm32 channels, epsilon 1e-5Linear Q32 to 32Conv2d reductionk=s=8; 32 channelsFlatten + LayerNorm256 × 32Linear K32 to 32Linear V32 to 32Q × transpose(K)Scale 1/sqrt(32); 1 headsSoftmax over keys16384 queries, 256 keysWeights × V1 heads, width 32Concat heads16384 × 32Output linear32 to 32+LayerNorm32 channelsLinear Mix-FFN32 to 128Depthwise Conv2d 3×3128 channels/groups; stride1, padding1GELULinear Mix-FFN128 to 32+Output tokens16384 × 32DropPath and all dropout are identities during eval.Stage 2 transformer blockInput tokens4096 × 64LayerNorm64 channels, epsilon 1e-5Linear Q64 to 64Conv2d reductionk=s=4; 64 channelsFlatten + LayerNorm256 × 64Linear K64 to 64Linear V64 to 64Q × transpose(K)Scale 1/sqrt(32); 2 headsSoftmax over keys4096 queries, 256 keysWeights × V2 heads, width 32Concat heads4096 × 64Output linear64 to 64+LayerNorm64 channelsLinear Mix-FFN64 to 256Depthwise Conv2d 3×3256 channels/groups; stride1, padding1GELULinear Mix-FFN256 to 64+Output tokens4096 × 64DropPath and all dropout are identities during eval.Stage 3 transformer blockInput tokens1024 × 160LayerNorm160 channels, epsilon 1e-5Linear Q160 to 160Conv2d reductionk=s=2; 160 channelsFlatten + LayerNorm256 × 160Linear K160 to 160Linear V160 to 160Q × transpose(K)Scale 1/sqrt(32); 5 headsSoftmax over keys1024 queries, 256 keysWeights × V5 heads, width 32Concat heads1024 × 160Output linear160 to 160+LayerNorm160 channelsLinear Mix-FFN160 to 640Depthwise Conv2d 3×3640 channels/groups; stride1, padding1GELULinear Mix-FFN640 to 160+Output tokens1024 × 160DropPath and all dropout are identities during eval.Stage 4 transformer blockInput tokens256 × 256LayerNorm256 channels, epsilon 1e-5Linear Q256 to 256Identity K/V input256 channelsIdentity256 × 256Linear K256 to 256Linear V256 to 256Q × transpose(K)Scale 1/sqrt(32); 8 headsSoftmax over keys256 queries, 256 keysWeights × V8 heads, width 32Concat heads256 × 256Output linear256 to 256+LayerNorm256 channelsLinear Mix-FFN256 to 1024Depthwise Conv2d 3×31024 channels/groups; stride1, padding1GELULinear Mix-FFN1024 to 256+Output tokens256 × 256DropPath and all dropout are identities during eval.Source: libreyolo/models/segformer/nn.py and model.py. Revision a4d0ecc9e17f.libreyolo.com