explaingit

facebookresearch/segment-anything

Analysis updated 2026-06-20

54,092Jupyter NotebookAudience · researcherComplexity · 4/5Setup · hard

TLDR

SAM is Meta's AI model that identifies and cuts out any object in an image using a simple click, box, or text prompt, including objects it was never specifically trained to recognize.

Mindmap

mindmap
  root((SAM))
    What it does
      Zero-shot segmentation
      Point click prompts
      Bounding box prompts
      Auto mask generation
    Tech Stack
      Python
      PyTorch
      ONNX export
      Jupyter Notebooks
    Use Cases
      Photo editing
      Medical imaging
      Satellite analysis
      Robotics perception
    Audience
      CV researchers
      ML developers
      Vision engineers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Automatically isolate objects in photos for photo editing or background removal.

USE CASE 2

Segment medical images to highlight regions of interest for analysis.

USE CASE 3

Analyze satellite imagery by masking and extracting land features or structures.

USE CASE 4

Add segmentation capability to robotics or computer vision pipelines.

What is it built with?

PythonPyTorchtorchvisionONNXJupyter Notebook

How does it compare?

facebookresearch/segment-anythingpathwaycom/llm-appjakevdp/pythondatasciencehandbook
Stars54,09259,82947,914
LanguageJupyter NotebookJupyter NotebookJupyter Notebook
Setup difficultyhardmoderateeasy
Complexity4/53/51/5
Audienceresearcherdeveloperdata

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · hard Time to first run · 1h+

Requires downloading large model checkpoint files and a GPU with sufficient VRAM to run the ViT-H model at reasonable speed.

In plain English

Segment Anything Model (SAM) is an AI model from Meta's research team that can identify and cut out any object in an image, even objects it has never been specifically trained to recognize. Traditional image segmentation tools require training on labeled examples of the exact type of object you want to detect. SAM works differently: it accepts a simple prompt such as a point click, a bounding box drawn around an object, or a text description, and it generates a precise mask (a pixel-level outline) of the corresponding object. It can also automatically generate masks for every distinct object in an entire image without any prompt at all. Under the hood, SAM was trained on a dataset of 11 million images and over 1 billion annotated masks, giving it broad visual knowledge. The model architecture uses a Vision Transformer (a type of neural network designed for image understanding) to encode images into a representation that the mask decoder can then use to respond to prompts. The model is available in three sizes with different accuracy and speed tradeoffs. The lightweight mask decoder can also be exported to the ONNX format, which is a standard format for running models in environments other than Python, including in web browsers. You would use SAM if you are a computer vision researcher or developer who needs flexible, zero-shot image segmentation for tasks like photo editing, medical imaging, satellite image analysis, robotics perception, or any application where you need to isolate objects in images. The tech stack is Python with PyTorch and torchvision, with example Jupyter Notebooks included. A newer version called SAM 2 extending these capabilities to video is also available.

Copy-paste prompts

Prompt 1
Using the Segment Anything Model in Python with PyTorch, write code to load the default checkpoint, pass an image, and generate masks for all objects automatically without any prompt.
Prompt 2
Show me how to use SAM to segment a specific object in an image by providing a single point click as a prompt using the Python API.
Prompt 3
Write Python code that uses SAM to accept a bounding box around an object and return a precise pixel mask for it.
Prompt 4
How do I export the SAM mask decoder to ONNX format so I can run it outside of Python, for example in a web browser?
Prompt 5
Compare the three SAM model sizes in terms of speed vs accuracy and help me choose the right one for real-time image segmentation on a laptop GPU.

Frequently asked questions

What is segment-anything?

SAM is Meta's AI model that identifies and cuts out any object in an image using a simple click, box, or text prompt, including objects it was never specifically trained to recognize.

What language is segment-anything written in?

Mainly Jupyter Notebook. The stack also includes Python, PyTorch, torchvision.

How hard is segment-anything to set up?

Setup difficulty is rated hard, with roughly 1h+ to a first successful run.

Who is segment-anything for?

Mainly researcher.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Scan in gitsafehub Deploy in gitdeployhub facebookresearch on gitmyhub

Verify against the repo before relying on details.