SAM 3 large visual prompts (default config)

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

SAM 3 large visual prompts (default config)Transformers 5.16.1 default architecture, 1008 × 1008 input, one box. Gated checkpoint configuration was not accessible.LibreYOLOSAM 3 large visual prompts (default config)Transformers 5.16.1 default architecture, 1008 × 1008 input, one box. Gated checkpoint configuration was not accessible.Image-mode visual pathImage encoder32-block ViT, 1,024 channelsIndependent FPN resamplings256-channel maps at 288,144,72,36Select three finest feature levels288×288, 144×144, 72×72Project high-resolution features32 × 288 × 288 and 64 × 144 × 144Add no-memory embedding256 × 72 × 72 main image featureNo video memory runs in this adapter.Box prompt encoderOne box2 corner coordinates × 2Shift pixel centersAdd 0.5 to x and yNormalize coordinatesDivide by 1008, map to [-1,1]MatMul random Fourier matrix2 coords to 128 frequenciesMultiply by 2 pi2 × 128Sin2 × 128Cos2 × 128Concat sin and cos2 × 256Corner type2 learned × 256+Sparse prompt embeddings2 × 256Learned no-mask embeddingBroadcast to 256 × 72 × 72Selected input: one box, no mask prompt.Points use the same Fourier encoding, pluspositive/negative or not-a-point embeddings.Dense image position: this encoding evaluatedon the centers of the 72 × 72 feature grid.Mask decoder inputsImage embedding256 × 72 × 72Dense prompt256 × 72 × 72+Flatten image features5,184 × 256Learned output tokensObject + IoU + 4 mask = 6 × 256Sparse prompts2 × 256Concat output and prompt tokens8 × 256Two-way block 18 queries, 5,184 image tokensTwo-way block 28 queries, 5,184 image tokensFinal token-to-image attentionQ+Q0, K+P, V=updated image+Final LayerNorm on queries8 × 256Q0 is the original token sequence.P is fixed Fourier image position.5,184 image tokens feed block 1 keys/values.Masks and quality outputsUpdated query tokens1 IoU + 4 mask tokens + 1 object tokenUpdated image tokens5,184 × 256Reshape to image256 × 72 × 72ConvTranspose2d 2×2 / 2256 to 64; 64 × 144 × 144Channel LayerNorm64 × 144 × 144GELU64 × 144 × 144ConvTranspose2d 2×2 / 264 to 32; 32 × 288 × 288GELU32 × 288 × 288Select four mask tokens4 × 256Four independent Linear layersEach 256 to 256ReLU4 × 256Four independent Linear layersEach 256 to 256ReLU4 × 256Four independent Linear layersEach 256 to 32MatMul mask coefficients × upscaled image4 × 32 times 32 × 82,944; reshape to 4 × 288 × 288Select masks 1 to 33 × 288 × 288Mask logits are resized to the input canvas,then unpadded/resized to the original image.multimask_output=True is drawn.False selects mask/score 0 instead.Object token: Linear 256, ReLU, Linear 256,ReLU, Linear 1 produces object-score logit.+High-res feature s164 × 144 × 144+High-res feature s032 × 288 × 288Select IoU token 1256Linear256 to 256ReLU256Linear256 to 256ReLU256Linear256 to 4Sigmoid4 mask-quality scoresSelect scores 1 to 33 quality scoresSelect object token 0256Linear256 to 256ReLU256Linear256 to 256ReLU256Linear256 to 1 object-score logitTwo-way block 1Query state8 × 256Image state5,184 × 256Token self-attention8 heads, 32 channels per headFirst self-attention has no PE or residual.LayerNorm8 × 256Original tokens Q08 × 256+Image position P5,184 × 256+Token-to-image attentionQ=8, K/V=5,184; 8 heads × 16+LayerNorm8 × 256Linear256 to 2,048ReLU8 × 2,048Linear2,048 to 256+LayerNorm8 × 256Original tokens Q08 × 256+Image-to-token attentionQ=5,184, K/V=8; 8 heads × 16+LayerNorm on image state5,184 × 256Updated queries: 8 × 256Two-way block 2Query state8 × 256Image state5,184 × 256Token self-attention8 heads, 32 channels per headOriginal tokens Q08 × 256+Self-attention Q/K include Q0.+LayerNorm8 × 256Original tokens Q08 × 256+Image position P5,184 × 256+Token-to-image attentionQ=8, K/V=5,184; 8 heads × 16+LayerNorm8 × 256Linear256 to 2,048ReLU8 × 2,048Linear2,048 to 256+LayerNorm8 × 256Original tokens Q08 × 256+Image-to-token attentionQ=5,184, K/V=8; 8 heads × 16+LayerNorm on image state5,184 × 256Updated queries: 8 × 256Token self-attentionQuery input8 × 256Key/value input8 × 256Linear Q256 to 256Reshape heads8 × 8 × 32Linear K256 to 256Reshape heads8 × 8 × 32Linear V256 to 256Reshape heads8 × 8 × 32MatMul Q K-transpose8 × 8 × 8ScaleDivide by sqrt(32)Softmax over keys8 × 8 × 8MatMul attention × V8 × 8 × 32Merge heads8 × 256Linear output256 to 256Token-to-image attentionQuery input8 × 256Key/value input4096 × 256Linear Q256 to 128Reshape heads8 × 8 × 16Linear K256 to 128Reshape heads8 × 4096 × 16Linear V256 to 128Reshape heads8 × 4096 × 16MatMul Q K-transpose8 × 8 × 4096ScaleDivide by sqrt(16)Softmax over keys8 × 8 × 4096MatMul attention × V8 × 8 × 16Merge heads8 × 128Linear output128 to 256Image-to-token attentionQuery input4096 × 256Key/value input8 × 256Linear Q256 to 128Reshape heads8 × 4096 × 16Linear K256 to 128Reshape heads8 × 8 × 16Linear V256 to 128Reshape heads8 × 8 × 16MatMul Q K-transpose8 × 4096 × 8ScaleDivide by sqrt(16)Softmax over keys8 × 4096 × 8MatMul attention × V8 × 4096 × 16Merge heads4096 × 128Linear output128 to 256Image-mode decoderQ0: original eight output/prompt tokens; P: Fourier image position.Final cross-attention uses the token-to-image equation, with residual and LayerNorm.Features s0 and s1 are computed once, then added at the two upscaling steps.The no-memory embedding is added to the 72×72 image feature.This is image inference. Video memory attention and memory encoder do not run.multimask_output=True selects mask/IoU slots 1, 2 and 3.Single-mask eval can fall back to the best multimask using stability thresholds.SAM 3 vision encoderImage3 × 1,008 × 1,008Conv2d 14×14 / 145,184 × 1,024 patch tokensTile learned position embedding24×24 pretrain grid to 72×72 gridAdd patch position5,184 × 1,024; no CLS tokenViT blocks, repeats=321,024 width, 16 heads, MLP 4,736Reshape final features1,024 × 72 × 72Global blocks (1-based): 8, 16, 24, 32.All other blocks use nine 24×24 windows.Head width 64; axial RoPE on Q and K.Vision ViT blockLayerNorm72 × 72 × 1,024Window partition when localNine 24×24 windows, no paddingRotary self-attention576 local / 5,184 global tokensReverse windows72 × 72 × 1,024+LayerNorm1,024 channelsLinear1,024 to 4,736GELU4,736 channelsLinear4,736 to 1,024+Local vision self-attentionQuery input576 × 1024Key/value input576 × 1024Linear Q1024 to 1024Reshape heads16 × 576 × 64Linear K1024 to 1024Reshape heads16 × 576 × 64Linear V1024 to 1024Reshape heads16 × 576 × 64Rotary position2D axial; scale 1Rotary position2D axial; scale 1MatMul Q K-transpose16 × 576 × 576ScaleDivide by sqrt(64)Softmax over keys16 × 576 × 576MatMul attention × V16 × 576 × 64Merge heads576 × 1024Linear output1024 to 1024Global vision self-attentionQuery input5184 × 1024Key/value input5184 × 1024Linear Q1024 to 1024Reshape heads16 × 5184 × 64Linear K1024 to 1024Reshape heads16 × 5184 × 64Linear V1024 to 1024Reshape heads16 × 5184 × 64Rotary position2D axial; scale 1/3Rotary position2D axial; scale 1/3MatMul Q K-transpose16 × 5184 × 5184ScaleDivide by sqrt(64)Softmax over keys16 × 5184 × 5184MatMul attention × V16 × 5184 × 64Merge heads5184 × 1024Linear output1024 to 1024Vision feature pyramidShared final ViT feature1,024 × 72 × 72ConvTranspose2d 2×2 / 21,024 to 512, 144×144GELU512 × 144 × 144ConvTranspose2d 2×2 / 2512 to 256, 288×288Conv2d 1×1256 to 256Conv2d 3×3 / 1256 to 256, p=1256 × 288 × 288Shared final ViT feature1,024 × 72 × 72ConvTranspose2d 2×2 / 21,024 to 512, 144×144Conv2d 1×1512 to 256Conv2d 3×3 / 1256 to 256, p=1256 × 144 × 144Shared final ViT feature1,024 × 72 × 72Conv2d 1×11024 to 256Conv2d 3×3 / 1256 to 256, p=1256 × 72 × 72Shared final ViT feature1,024 × 72 × 72MaxPool2d 2×2 / 21,024 × 36 × 36Conv2d 1×11024 to 256Conv2d 3×3 / 1256 to 256, p=1256 × 36 × 36 (not used by image heads)These branches are independent resamplings, not top-down additions. Three finest levels enter the image heads.Default-config scope: architecture verified from Apache-2.0 Transformers classes; no gated checkpoint or license acceptance was used.Source: libreyolo/models/sam/sam3.py. Revision a4d0ecc9e17f.libreyolo.com