1 An image encoder and a promptable decoder
SAM is split in two. The image encoder runs once per image. It resizes the longest side to 1,024 pixels and turns the image into a 64×64 grid of 256-number vectors. The prompt encoder turns each click into a token: its position, plus whether it means "this" or "not this". The mask decoder is a small two-way transformer. Prompt tokens and four mask tokens attend to the image grid, the grid attends back, and each mask token becomes a mask. Three of them answer the ambiguity of a single click (a part, a bigger part, the whole). Alongside each mask the decoder predicts its own quality, the IoU it expects with what a person meant. Because the encoder runs only once, every further click costs milliseconds.
This is MobileSAM. Its prompt encoder and mask decoder are SAM's own. Its image encoder is a small TinyViT, trained to reproduce the image embeddings of SAM's 632-million-parameter ViT-H encoder on about 1% of SAM's training images. It learned to see like SAM, not from the masks themselves.
SAM's training set, SA-1B, holds 11 million licensed photos and 1.1 billion masks. Annotators drew masks with an early SAM in the loop, and later SAMs drew more on their own. In the end, 99.1% of the released masks were generated fully automatically. To protect privacy, every face and licence plate in the photos was blurred before release.
Layer by layer
2 Point at things
Pick, drop, paste or upload an image, or capture one from the webcam. Click to add a point on the object; shift-click or right-click to add a "not this" point. Up to seven points. Segment everything clicks a 16×16 grid by itself and keeps the masks SAM rates as good and stable, the way SA-1B's automatic masks were made.
Three answers to one click (SAM's predicted IoU under each)
Where each mask token looks (final token-to-image attention)
3 What it learned to count as one thing
A face is one thing
Edges people see that aren't there
A shadow is its own object
4 Segment everything, and nothing
SAM's automatic mode, run offline with its default quality filters on the sample photos and on images that contain no objects at all.