# Segment Anything

Author: Ishwar Jangid
Canonical URL: https://ishwarj.com/papers/sam/
Updated: 2026-10-18
Source: https://github.com/ishwar6/ishwar-books/blob/main/content/papers/sam/index.md


## Why this paper

Segmentation means to find the exact pixels of an object in a picture. Before 2023, a segmentation model usually knew a fixed list of object types. It also worked well only on pictures like its training pictures. For a new kind of object or a new kind of picture, you collected new labels and trained a new model.

This paper asks a different question. Can one model cut out *any* object, in *any* picture, when you only show it *which* object you want? You show the object with a click, a box or a rough mask. The model returns a mask. The paper calls this a **prompt**, the same word that language models use.

The paper has three linked parts. A new task: promptable segmentation. A new model: the Segment Anything Model (SAM). A new dataset: SA-1B, with 1.1 billion masks on 11 million pictures. SAM helped people make the dataset, and the dataset trained SAM. SAM is now a standard tool in labelling software, in medical imaging research and in robotics.

## How the six parts are organised

**Before Part 1 (optional): [The Road to SAM](https://ishwarj.com/papers/sam/background-the-road-to-sam/).** How FCN, YOLO and Mask R-CNN cut out objects from a fixed list, how GPT-3 and CLIP brought the prompt, and how YOLO and SAM differ on the same photo.

Each part follows the paper's own sections:

1. **[The Big Idea: Segment Anything](https://ishwarj.com/papers/sam/part-1-the-big-idea/)**: the title, Figure 1, the abstract and §1. What a mask is, what a foundation model is, and the three parts of the project. With a real run of SAM on one picture.
2. **[The Task: Promptable Segmentation](https://ishwarj.com/papers/sam/part-2-the-task/)**: §2 and Figure 3. Prompts, valid masks, ambiguity, pre-training and zero-shot transfer.
3. **[The Model: Encoder, Prompts and Decoder](https://ishwarj.com/papers/sam/part-3-the-model/)**: §3, Figure 4, Figure 14 and Appendix A. Every block of SAM with the real numbers of the released models, the losses and the training loop.
4. **[The Data Engine and SA-1B](https://ishwarj.com/papers/sam/part-4-data-engine-and-sa-1b/)**: §4, §5, §6 and Appendices B and C. Three stages of labelling, the automatic mask generator, and the analysis of the dataset.
5. **[Zero-Shot Experiments](https://ishwarj.com/papers/sam/part-5-zero-shot-experiments/)**: §7 and Appendix D. Points to masks on 23 datasets, edges, object proposals, instance segmentation, text to mask, and the ablations.
6. **[After SAM: Impact, Limits and Summary](https://ishwarj.com/papers/sam/part-6-impact-and-summary/)**: §8 and the work that came later.

## How to read the boxes

- A **teal "From the paper" box** shows the exact lines of the paper as a highlighted screenshot. Click the screenshot to see it at full size. Under it, **What it says** gives the main words of the paper. **What it means** then explains those lines, and what the authors mean but do not write. When the box shows a different paper, the box gives the name of that paper.
- A **yellow definition box** explains a technical word the first time it occurs. If you know the word, skip the box.
- The small **Paper §3** tag above a heading tells you which section of the paper you read. Use it to find the text in the PDF.
- A **green "Key takeaways" box** ends each part with the facts to remember.

Code blocks show real code. The output under a code block is the output that the code printed. The scripts are in [`code/papers/sam`](https://github.com/ishwar6/ishwar-books/tree/main/code/papers/sam). They use the models that Meta released, through the Hugging Face `transformers` library, on an Apple M5 Pro (64 GB).


## What you need to know first

You do not need to know about computer vision. Each term has an explanation when it first occurs. SAM's image encoder is a Vision Transformer (ViT). The [ViT breakdown](https://ishwarj.com/papers/vit/) explains it from zero, but Part 1 and Part 2 do not need it. If attention is new to you, the [attention series](https://ishwarj.com/writings/attention-1-self-attention/) starts from zero. For Part 3 you need only this idea: each token looks at the other tokens.

