← All models

MODEL EXPLORER / MULTIMODAL MILESTONES

Turn a prompt into candidate masks

How do image features and a user prompt become a mask?

Curated by TensorVizSegment Anything · promptable decoder · 4-step tour
Static architecture
How do image features and a user prompt become a mask?
Opening the interactive graph…
Architecture snapshot · No Python requiredDownload graph ↓

RECORDED NUMERICAL EXAMPLE

Reuse the image; change the prompt.

Recorded prompt-to-mask computation from cached synthetic image features. Explore point location, prompt type and a box while the two-way decoder updates image and token features.

The same cached 2 × 2 image embedding is reused for each prompt. Coordinates are normalized (x,y) in [0,1]. Type IDs are 0 = background, 1 = foreground, 2 = top-left box corner, 3 = bottom-right. Three mask logits express the multi-mask interface; these untrained outputs do not segment a real object and quality scores are not calibrated IoUs.

Candidate 1 · mask logits

Min -0.01213 · Max 0.1301

Recorded cell values
Row / col01234567
00.08099-0.0058380.07064-0.001285-0.0024240.045510.013760.06102
10.12260.025390.083570.048110.07270.016170.080240.003487
20.016230.053660.014850.003523-0.012130.0048630.1039-0.00614
30.054690.025350.075760.048060.059140.061180.13010.02121
40.05909-0.00058230.07052-0.0058730.03205-0.0017030.024370.06232
50.1010.033570.11830.028220.092640.040940.085090.0003713
60.022380.014840.006470.0080720.016460.030880.01036-0.0005467
70.021480.094870.05690.059860.035090.060940.079480.0499
Candidate 2 · mask logits

Min -0.1918 · Max 0.01852

Recorded cell values
Row / col01234567
0-0.1014-0.01623-0.09132-0.016590.000458-0.07277-0.02307-0.08953
1-0.183-0.03976-0.1188-0.06355-0.1086-0.0202-0.1157-0.001932
2-0.02913-0.07802-0.01702-0.025610.01852-0.02849-0.1314-0.01501
3-0.07399-0.02796-0.1172-0.06851-0.09769-0.0879-0.1918-0.03402
4-0.07423-0.0204-0.08769-0.01655-0.03836-0.02082-0.03741-0.09056
5-0.1503-0.04886-0.1774-0.04352-0.1418-0.05984-0.1210.002725
6-0.03601-0.0292-0.007868-0.02868-0.02843-0.04952-0.01015-0.02267
7-0.02525-0.1195-0.08716-0.08184-0.04586-0.07538-0.1249-0.07218
Candidate 3 · mask logits

Min -0.01925 · Max 0.1718

Recorded cell values
Row / col01234567
00.00740.12750.022280.098830.013790.090140.033070.07709
10.17180.045780.084810.022560.10250.0012760.0903-0.01291
20.049480.06398-0.0071820.1156-0.019250.12230.016630.1229
30.0351-0.018190.12870.049850.13420.067160.170.04258
40.0069060.11480.0033230.1294-0.0065590.12470.039790.07404
50.13950.040280.17080.047180.14930.050480.0869-0.01731
60.045540.05912-0.00066440.10180.04410.06195-0.014380.127
7-0.0069360.012810.091950.043090.013730.00073180.14560.05748

Each heatmap uses its own scale. Mint is positive, rust is negative, and the lightest color is zero. Table values are rounded to four significant digits.

Prompt coordinates · x₀, y₀, x₁, y₁
0.25
0.25
0.75
0.75
Prompt type IDs
1
0
Predicted quality scores · untrained
-0.09329
-0.09947
0.1291

Bars share one scale within this example. Values are rounded to four significant digits.

Image encoder calls per changed prompt
0
Candidate masks
3
Verified by the local recipe
  • Reordering sparse prompts preserves mask and quality outputs
  • Moving a point or changing foreground/background type changes outputs without modifying cached image features
  • Hypernetwork masks equal explicit per-pixel feature-weight dot products
  • Mask gradients reach prompt coordinates and the image-to-token attention path

Download the source and run.py to reproduce these checks. Choosing an example here replays recorded values.

ABOUT THIS EXAMPLE

Reuse a cached image embedding, encode points or box corners, and follow two-way attention into three dynamic mask predictions.

Component · 2023

Segment Anything · promptable decoder

Width eight, two two-way blocks with one attention head, three mask tokens and one quality token. Random Fourier coordinate features plus point/box type embeddings. Two transposed convolutions upscale a 2 × 2 image embedding to 8 × 8 mask features.

Source, capture & limitations +

Untrained prompt/decoder subsystem, not a complete SAM model. Input is a cached synthetic embedding; the pretrained ViT image encoder, dense-mask encoder, tokenizer, image resizing and mask losses are omitted. The attention residual pattern follows the paper-level description with one head; this is not a parameter-compatible port. Only three candidate mask tokens are modeled, without the released implementation’s extra single-mask token. Quality scores are uncalibrated.

Original TensorViz teaching example. PyTorch provides the underlying operators.

No separate redistribution license has been declared for these project examples.

Content revision
06fa171ea414ac32
Source SHA-256
bba1c4d0f25557c69579fade1e1ce55a8dd70d4af374ed69438d9a3652291d3e
Captured
2026-09-17 · Python 3.13.13 / Torch 2.7.1

SAM-inspired prompt-encoder and two-way mask-decoder subsystem with cached synthetic image features. Prompt permutation/location/type, hypernetwork dot-product and gradient checks. Output packs three 8 × 8 mask logits and three quality scores.

Read the model manifest ↗