whatisgithub

What is fastsam?

casia-lmc-lab/fastsam — explained in plain English

Analysis updated 2026-06-24

8,340PythonAudience · developerComplexity · 3/5Setup · moderate

In one sentence

FastSAM is a real-time image segmentation tool that draws precise outlines around every object in a photo, reportedly 50x faster than Meta's SAM, with support for text, bounding box, point, or automatic prompts.

Mindmap

mindmap
  root((repo))
    What it does
      Image segmentation
      Object masking
      Faster than SAM
    Prompt Modes
      Everything auto
      Text description
      Bounding box
      Point click
    Interfaces
      Python script
      Gradio web UI
      HuggingFace demo
    Model Sizes
      Default larger model
      FastSAM-s smaller
    Requirements
      Python 3.7 plus
      PyTorch
      GPU recommended
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 segment and mask every object in product photos for an e-commerce pipeline without writing any prompt logic.

USE CASE 2

Use text prompts to isolate and extract specific objects from images in a Python data-processing workflow.

USE CASE 3

Build a real-time segmentation feature into a web app using FastSAM's Gradio interface as a backend.

USE CASE 4

Replace Meta's SAM in an existing project to get significantly faster inference speed with comparable accuracy on standard hardware.

What is it built with?

PythonPyTorchYOLOv8Gradio

How does it compare?

casia-lmc-lab/fastsamapple/ml-sharpdetailyang/awesome-cheatsheet
Stars8,3408,3418,346
LanguagePythonPythonPython
Setup difficultymoderatehardeasy
Complexity3/54/51/5
Audiencedeveloperresearcherdeveloper

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

How do you get it running?

Difficulty · moderate Time to first run · 30min

GPU strongly recommended, CPU inference is very slow and not practical for most real-world use cases.

So what is it?

FastSAM is a tool for image segmentation, which means it draws precise outlines around every distinct object or region in a photo. You give it an image and it returns masks showing exactly which pixels belong to which thing. It was built as a faster alternative to Meta's Segment Anything Model (SAM), with the README claiming roughly 50 times the speed while delivering comparable accuracy. It was trained on a small fraction (2%) of the large dataset that SAM used. The tool supports four ways of telling it what to segment. The first is an "everything" mode that automatically outlines all objects it can find without any guidance from you. The second is a text prompt, where you describe what you want in plain language, for example "the yellow dog." The third is a bounding box, where you draw a rectangle around the area of interest. The fourth is a points prompt, where you click specific pixel coordinates to indicate foreground or background regions. You interact with it through a Python script or a short code snippet using the FastSAM library. You load a downloaded model file, point it at an image, choose a mode, and it produces annotated output images showing the detected segments. An optional Gradio web interface lets you upload images and test the modes without writing any code. Live demos are also hosted on HuggingFace and Replicate for trying it in a browser. Two model sizes are available: a larger default version based on YOLOv8x for higher accuracy, and a smaller FastSAM-s version based on YOLOv8s that runs faster on limited hardware. Installation requires Python 3.7 or later, PyTorch, and a few other packages listed in a requirements file. GPU support is strongly recommended for reasonable speed.

Copy-paste prompts

Prompt 1
Using FastSAM, show me a Python script that loads the model, runs 'everything' segmentation on a local image file, and saves an annotated output image with all detected masks drawn.
Prompt 2
I want to use FastSAM with a text prompt to isolate just the dog in a photo. Show me the Python code to load the model, pass the text prompt 'the dog', and get back the binary mask.
Prompt 3
Help me set up the FastSAM Gradio web interface locally so I can test all four segmentation modes in a browser without writing any code.
Prompt 4
I need to run FastSAM on a CPU-only machine. Show me which model size to choose and how to set the device flag, and explain what speed trade-offs to expect.
Prompt 5
Show me how to use FastSAM's bounding box prompt mode in Python: how to specify the box coordinates and how to extract the cropped masked region from the output.

Frequently asked questions

What is fastsam?

FastSAM is a real-time image segmentation tool that draws precise outlines around every object in a photo, reportedly 50x faster than Meta's SAM, with support for text, bounding box, point, or automatic prompts.

What language is fastsam written in?

Mainly Python. The stack also includes Python, PyTorch, YOLOv8.

How hard is fastsam to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is fastsam for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.