Skip to content

Knowledge sharing3 min read

Segment Anything – But Can It Really Segment Anything?

Foundation models have transformed NLP, while computer vision continues to evolve rapidly. Yet image segmentation has lagged behind. Meta's Segment Anything Model (SAM) aims to change that by supporting prompts in the form of points, boxes, masks, or text—and even generating multiple possible segmentations. Is this the breakthrough the field has been waiting for?

Summarize in
or

We are currently witnessing the golden age of foundation models in NLP, and computer vision has also seen remarkable progress. One area, however, has struggled to keep pace: image segmentation. While segmentation is one of the core tasks of computer vision, today's models are typically trained for specific datasets and use cases. A truly general-purpose segmentation model has long been missing.

The creators of Segment Anything Model (SAM) set out to address this challenge by first asking three fundamental questions:

  • What task enables true zero-shot generalization?
  • What model architecture best supports this task?
  • What kind of data is required to train such a model?

Their answer was a new task called promptable segmentation. Instead of relying on a fixed task definition, SAM accepts multiple types of prompts—including a point, a bounding box, an existing mask, or even natural language text—and segments the corresponding region of the image.

Because prompts are not always unambiguous (for example, a point placed on a T-shirt could refer to the shirt itself or to the person wearing it), SAM generates three candidate masks for each prompt, allowing the user or downstream application to select the most appropriate result.

SAM consists of three main components:

  • Image Encoder – Processes the input image. Although this is the computationally expensive part of the model, it only needs to run once per image, after which multiple segmentation tasks can be performed efficiently.
  • Prompt Encoder – Encodes different prompt types, including points, bounding boxes, masks, and text.
  • Mask Decoder – Combines the encoded image and prompt to generate the three candidate segmentation masks. This stage is lightweight and runs quickly.

As part of the SAM project, Meta also introduced SA-1B, one of the largest segmentation datasets ever created. It contains 11 million images and 1.1 billion segmentation masks. The dataset was built in three stages:

  1. Model-assisted manual annotation.
  2. A semi-automatic phase combining human annotation with model-generated masks.
  3. A fully automatic phase in which the model generated masks without human intervention.

Remarkably, 99% of all masks were produced during this fully automated third stage.

SAM was evaluated on a wide range of downstream computer vision tasks, including point-based segmentation, edge detection, object proposal generation, instance segmentation, and text-to-mask generation. Some applications required minor post-processing, while others benefited from additional task-specific fine-tuning. Overall, SAM delivered consistently strong performance, even if it was not the top-performing model in every benchmark.

Overall, SAM represents a major step toward universal image segmentation, but it is not a one-size-fits-all solution. It is fast, flexible, and easy to use, although some applications may still require post-processing or specialized models to achieve the best possible results.

Source: https://arxiv.org/abs/2304.02643