Segment Anything Model

Machine Learning
Introduced by
Alexander Kirillov
Year
2023
Type
Neural network architecture
Family
Deep Learning, Image Segmentation, Foundation Models

What does it do?

Segment Anything Model (SAM) is a promptable image segmentation model introduced by Kirillov et al. in 2023.

It is designed to segment objects in an image from prompts such as points, bounding boxes, or masks, and it is evaluated in a zero-shot setting on image distributions and tasks it was not specifically trained for. The model is trained on the SA-1B dataset of 11 million images and over 1 billion masks.

The intuition behind the method

SAM treats segmentation as a prompt-response task. Instead of training a separate model for each segmentation problem, it uses one architecture that returns a mask in response to a prompt the user supplies. The model was built together with a data collection loop in which the model itself helped annotate the training masks at scale. Because the model is trained to be promptable, the authors report that it can transfer to new image distributions and tasks without retraining. The decoder predicts several candidate masks for a single prompt, which handles cases where one prompt could correspond to more than one valid object. The candidates are ranked by predicted quality, and the user or downstream code chooses among them.

History

Alexander Kirillov and colleagues introduced the Segment Anything project, which includes the Segment Anything Model and the SA-1B dataset, and the work appeared in the Proceedings of the IEEE/CVF International Conference on Computer Vision in 2023. The authors describe the project as treating image segmentation as a promptable, foundation-model-style task. The training dataset was built through a data collection loop and contains over 1 billion masks on 11 million images. The model and dataset were released publicly to support research on foundation models for computer vision.

When to use it

Choose SAM for interactive segmentation, where a person can click, draw a box, or refine a mask, and for general object segmentation in which the object categories are not fixed in advance. It is a reasonable starting point when training a task-specific model is impractical because the range of possible objects is wide. It is not a substitute for a supervised model trained on a large labelled dataset for one fixed problem, where a standard segmentation network may be more accurate for that problem. In specialised domains such as medical or satellite imagery, the cited source reports zero-shot results only for the tasks it evaluates, so evaluating the base model on your own data, and considering fine-tuning if it falls short, is the appropriate check.

Limitations and considerations

  • Zero-shot results are described as often competitive with, not uniformly better than, prior fully supervised methods; on a specific benchmark or narrow task a supervised specialist can still be the stronger choice
  • Ambiguous prompts can return several valid masks, so the user or downstream code must select the intended one
  • The reported evaluation does not cover specialised domains such as medical or satellite imagery, so performance there cannot be assumed from the reported results

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Supports segmentation of objects it was not trained to recognise as a fixed category, because it is driven by prompts rather than a closed label set
  • Zero-shot performance is reported as often competitive with prior fully supervised results on the evaluated tasks, so a single model can cover several segmentation needs
  • Prompt types (points, boxes, masks) allow interactive workflows in which a user refines the output step by step
  • The model is described as efficient enough to be used inside a data collection loop, which is how its training data was produced

Applications

  • Interactive image annotation for dataset creation, the kind of prompt-driven data collection loop used to build the SA-1B dataset
  • Interactive mask refinement, in which a person supplies points or boxes and adjusts the output step by step
  • Exploratory use in medical, driving-scene or robotic settings, such as organ outlines, scene segmentation, or selecting objects for grasping. The reported evaluation does not establish performance in these settings, so any such use needs validation on representative data before it informs a decision

How it works

How it works

1

The input image is processed once by a vision transformer backbone that produces feature maps covering both local detail and wider image context.

2

User prompts, such as points, boxes, or a previous mask, are encoded as embeddings that can be combined with the image features.

3

A lightweight decoder combines the image features with the prompt embeddings to predict several candidate segmentation masks.

4

For each candidate mask the model predicts an intersection-over-union (IoU) score, and the candidates are ranked by this predicted quality. The score is the model's own estimate of mask quality. It is useful for ordering candidates, but it should not be read as a calibrated probability that a mask is correct.

Common pitfalls

  • Underspecified prompts, such as a single point on a boundary between two objects, can produce a mask for the wrong object; prompts should be chosen to identify the target unambiguously
  • Fine-tuning on a small dataset risks overfitting and can lower performance on other images; compare the fine-tuned model against the base model on a held-out set drawn from the target domain before adopting it
  • Assuming that zero-shot results carry over to a new domain without checking on representative data is a common error, because the reported evaluation covers particular tasks and image distributions
  • Treating the predicted IoU score as a guarantee of correctness; when the scores of several candidates are close, inspect the masks visually and check the chosen mask against held-out examples before relying on it

Frequently asked questions

What types of prompts does SAM support?

SAM is a promptable segmentation model. The prompt types named for it are points, bounding boxes and masks, and a prompt identifies the object to be segmented. For ambiguous prompts, SAM returns multiple candidate masks with predicted quality scores, so the user can choose the intended one.

How does SAM handle ambiguous cases?

When a prompt could correspond to more than one valid object, for example a click on the border between two objects, SAM predicts several candidate masks. It ranks them with predicted IoU scores, which lets the user select the correct mask rather than receiving a single forced answer.

Can SAM be fine-tuned for specialised domains?

Fine-tuning on domain-specific data is a common way to adapt the model, but the cited source does not report fine-tuning results for specialised domains, so its benefit should be measured on your own data. Results depend on the size and quality of the domain dataset, and a small dataset can reduce generalisation if it is not regularised.

Related methods

Sources

  1. Kirillov, A., Mintun, E., Darrell, T., & Girshick, R. (2023). Segment Anything. In Proceedings of the IEEE/CVF International Conference on Computer Vision (pp. 4015-4026).

    Open DOI reference