ViTMatte Small
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.
ViTMatte Small
Guided alpha matting,input normalized RGB3 channels + trimap1 channel at512 × 512,native eval.
LibreYOLO
ViTMatte Small
Guided alpha matting,input normalized RGB3 channels + trimap1 channel at512 × 512,native eval.
ViTDet-S backbone
RGB + trimap input
4 × 512 × 512; trimap0,0.5,1
Conv2d16×16,stride16
4 to384;384 × 32 × 32
Add bicubic absolute positions
Learned14×14 grid resized32×32; discardCLS slot
Window transformer blocks,n=2
Indices0,1;384channels;6heads
Global transformer + CNN bottleneck
Index2;384 × 32 × 32
Window transformer blocks,n=2
Indices3,4;384channels;6heads
Global transformer + CNN bottleneck
Index5;384 × 32 × 32
Window transformer blocks,n=2
Indices6,7;384channels;6heads
Global transformer + CNN bottleneck
Index8;384 × 32 × 32
Window transformer blocks,n=2
Indices9,10;384channels;6heads
Global transformer + CNN bottleneck
Index11;384 × 32 × 32
Window blocks pad32 to42,partition nine14×14 windows,
then crop back. There is no cyclic window shift orCLS token.
Convolution detail stream
Input RGB + trimap
4 × 512 × 512
ConvBNReLU3×3,stride2
4 to48;256×256
ConvBNReLU3×3,stride2
48 to96;128×128
ConvBNReLU3×3,stride2
96 to192;64×64
Retain raw input plus all three detail levels as decoder skips.
All three convolutions usepadding1 andbias=False.
BatchNorm epsilon1e-5; ReLU follows normalization.
Detail fusion and alpha
Bilinear resize×2
384 × 64 × 64;align_cornersFalse
Concat detail skip thenupsampledfeature
192+384=576 channels
ConvBNReLU3×3,stride1
576 to256;padding1
Bilinear resize×2
256 × 128 × 128;align_cornersFalse
Concat detail skip thenupsampledfeature
96+256=352 channels
ConvBNReLU3×3,stride1
352 to128;padding1
Bilinear resize×2
128 × 256 × 256;align_cornersFalse
Concat detail skip thenupsampledfeature
48+128=176 channels
ConvBNReLU3×3,stride1
176 to64;padding1
Bilinear resize×2
64 × 512 × 512;align_cornersFalse
Concat detail skip thenupsampledfeature
4+64=68 channels
ConvBNReLU3×3,stride1
68 to32;padding1
Matting head
Conv3×3:32to16;BN;ReLU;Conv1×1:16to1
Sigmoid
1 × 512 × 512 alpha probabilities
Apply exact known trimap labels
Background0 forcesalpha0;foreground1 forcesalpha1
Transformer layer
Input
384channels at32×32
LayerNorm
384channels,epsilon1e-6
Attention on local windows orfull grid
Local196tokens;global1024tokens;6heads
+
LayerNorm
384channels,epsilon1e-6
Linear
384 to1536
GELU
Linear
1536 to384
+
Global layers subsequently run the residual CNN bottleneck.
Attention and decomposed positions
LinearQKV
384 to1152;split into6 heads of64
Q × transpose(K) /8
196² local or1024² global logits/head
Add Q-dependent height relative term
einsum(Q,relative_height)
Add Q-dependent width relative term
einsum(Q,relative_width)
Softmax over keys
Weights × V
64 channels/head
Concat heads + Linear
384 to384
Each relative table is27×64 for14×14 window attention;
63×64 for32×32 global attention. Tables resize if needed.
CNN residual after each global layer
Global transformer output
384 × 32 × 32
Conv1×1
384 to192;biasFalse
ChannelLayerNorm + GELU
192channels,epsilon1e-6
Conv3×3
192 to192;padding1,biasFalse
ChannelLayerNorm + GELU
192channels,epsilon1e-6
Conv1×1
192 to384;biasFalse
ChannelLayerNorm
384channels,epsilon1e-6
+
No additional finalbackbone normalization after layer11.
Convolutional primitives
Conv2d3×3
Numericchannels/stride at occurrence
BatchNorm2d
ReLU
Matting head differs:Conv3×3(32to16,biasTrue),BatchNorm16,ReLU,Conv1×1(16to1,biasTrue).
Known trimap pixels are constrained after the single decoder sigmoid; unknown0.5 pixels keep predictedalpha.
Source: libreyolo/models/vitmatte/nn.py and model.py. Revision a4d0ecc9e17f.
libreyolo.com