BiRefNet T

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

BiRefNet TAlpha-matte logits,normalized RGB input3 × 1024 × 1024,native eval. Shapes exclude batch.LibreYOLOBiRefNet TAlpha-matte logits,normalized RGB input3 × 1024 × 1024,native eval. Shapes exclude batch.Dual-scale shared encoderfull image3 × 1024 × 1024Shared Swin-v1 encoderE=96;window7half image3 × 512 × 512Shared Swin-v1 encoderE=96;window7Half image uses bilinear resize,align_corners=True.Full stage196 × 256²Resize half stage196 × 128² to256²Concat two scales: X1192 × 256²Full stage2192 × 128²Resize half stage2192 × 64² to128²Concat two scales: X2384 × 128²Full stage3384 × 64²Resize half stage3384 × 32² to64²Concat two scales: X3768 × 64²Full stage4768 × 32²Resize half stage4768 × 16² to32²Concat two scales: X41536 × 32²Resize X1,X2,X3 to32²; concat withX42880 × 32 × 32BasicDecBlk squeeze2880 to1536;32²Bilateral-reference decoderConcat current feature and IPT51536 + 192 = 1728 channels at32²BasicDecBlk1728 to768;32²Gradient-reference attention768 channels multiplied by spatial gateBilinear resize×2768 × 64²+Conv1×1(X3)768 to768Concat current feature and IPT4768 + 192 = 960 channels at64²BasicDecBlk960 to384;64²Gradient-reference attention384 channels multiplied by spatial gateBilinear resize×2384 × 128²+Conv1×1(X2)384 to384Concat current feature and IPT3384 + 96 = 480 channels at128²BasicDecBlk480 to192;128²Gradient-reference attention192 channels multiplied by spatial gateBilinear resize×2192 × 256²+Conv1×1(X1)192 to192Concat current feature and IPT2192 + 48 = 240 channels at256²BasicDecBlk240 to96;256²Bilinear resize to1024²96 channelsConcat full-resolution feature and IPT196 + 24 = 120 channelsConv1×1 to one logit120 to1;1 × 1024 × 1024Sigmoid to alpha belongs to shared matte postprocessing.Image-patch reference pathsEach IPT path consumes the original normalized1024 RGB image.Tile packing for IPT532×32 contiguous tiles;3072×32²Conv3×3 thenConv3×33072 to64 to192;boths1,p1IPT5192 × 32²Tile packing for IPT416×16 contiguous tiles;768×64²Conv3×3 thenConv3×3768 to64 to192;boths1,p1IPT4192 × 64²Tile packing for IPT38×8 contiguous tiles;192×128²Conv3×3 thenConv3×3192 to64 to96;boths1,p1IPT396 × 128²Tile packing for IPT24×4 contiguous tiles;48×256²Conv3×3 thenConv3×348 to64 to48;boths1,p1IPT248 × 256²Tile packing for IPT11×1 contiguous tiles;3×1024²Conv3×3 thenConv3×33 to64 to24;boths1,p1IPT124 × 1024²Tile packing concatenates whole spatial tiles as channels;it is not the pixel-interleaving PixelUnshuffle operation.Shared Swin-v1 backboneConv patch4,stride4 + LayerNorm3 to96; fullgrid256² / halfgrid128²Swin block stage1,n=296 channels;heads3;MLPwidth384Output-stage LayerNormFull/half grids 256² / 128²PatchMergingConcat2×2 gives384;LN;Linear to192Swin block stage2,n=2192 channels;heads6;MLPwidth768Output-stage LayerNormFull/half grids 128² / 64²PatchMergingConcat2×2 gives768;LN;Linear to384Swin block stage3,n=6384 channels;heads12;MLPwidth1536Output-stage LayerNormFull/half grids 64² / 32²PatchMergingConcat2×2 gives1536;LN;Linear to768Swin block stage4,n=2768 channels;heads24;MLPwidth3072Output-stage LayerNormFull/half grids 32² / 16²Stage normalization is an output tap; merging uses pre-tap tokens.Swin block and attentionInput tokensStage widths [96, 192, 384, 768]LayerNormepsilon1e-5Pad spatial grid to window multipleWindow7; alternating shift0/3Partition windows49 tokens perwindowLinear QKV; split headsQKV widths [288, 576, 1152, 2304]QK transpose /sqrt32 +relative biasLearned relative bias; shifted mask0/-100Softmax thenweights × VEach head has32 channelsConcat heads; output LinearRestore stage channel widthReverse windows,undo shift,cropRestore unpadded stage grid+LN; Linear to4C; GELU; Linear toCNumeric widths [384, 768, 1536, 3072]+PatchMerging reads2×2 spatial neighbors, thenLN and4C-to2C Linear.BasicDecBlkConv3×3Occurrence Cin to64;s1,p1,biasTrueBatchNorm2d + ReLU64 channelsASPPDeformable64 to64Conv3×364 tooccurrence Cout;s1,p1,biasTrueBatchNorm2dCout channels;no finalactivationGradient-reference attentionConv3×3;BN;ReLUInputchannels[768, 384, 192] to16;s1,p1Conv1×1 +Sigmoid16to1;spatial gate×FeatureAttention executes in eval; gradient-prediction supervision does not.ASPPDeformable: five parallel branchesDeformableConv1×164to256;padding0BatchNorm2d thenReLU256 channelsDeformableConv1×164to256;padding0BatchNorm2d thenReLU256 channelsDeformableConv3×364to256;padding1BatchNorm2d thenReLU256 channelsDeformableConv7×764to256;padding3BatchNorm2d thenReLU256 channelsGlobal avgpool;Conv1×1;BN;ReLU64to256;resize back toinputgridConcat five256-channel results1280 channelsConv1×1;BatchNorm;ReLU;Dropout0.51280to64;dropout isidentity in evalTwo distinct1×1 deformable branches exist: aspp1 plus the first entry of parallel_block_sizes=(1,3,7).Modulated deformable convolutionOffset Conv k×k64to2k²:2,18,98 offsets for k1,3,7; biasTrueMask Conv k×k64tok²:1,9,49 values;biasTrueMultiply2 × SigmoidModulation range(0,2)Base kernel grid + learned offsetsBilinear sample input features at displaced locationsMultiply sampled values by modulation and kernel weightsLearned kernel[256,64,k,k]; sum over channels/kernelpositionsOutput256 channelsStride1; spatial size preservedregular_conv supplies its weights to torchvision deform_conv2d; it is not an extra executed convolution.Image-reference primitives and valuesPacked image tilesCin3072,768,192,48,3 fromcoarse tofullConv3×3Cin to64;stride1,padding1Conv3×364 toIPT outputchannels [192, 192, 96, 48, 24]No normalization or activation between these two convolutions.Training-only multiscale and gradient-label heads are storedfor checkpoint loading, but excluded from this eval graph.Source: libreyolo/models/birefnet/nn.py and model.py. Revision a4d0ecc9e17f.libreyolo.com