FastSAM  by CASIA-IVA-Lab

CNN for fast image segmentation, comparable to SAM but faster

created 2 years ago
8,002 stars

Top 6.6% on sourcepulse

GitHubView on GitHub
Project Summary

FastSAM is a CNN-based model designed for efficient image segmentation, offering a significantly faster alternative to the original Segment Anything Model (SAM). It targets researchers and developers needing high-speed segmentation with comparable performance, particularly for applications requiring real-time processing or large-scale dataset analysis.

How It Works

FastSAM leverages a CNN architecture, trained on a small fraction (2%) of the SA-1B dataset, to achieve its speed advantage. This approach allows for faster inference compared to SAM's transformer-based architecture, while maintaining competitive zero-shot transfer capabilities for tasks like edge detection and object proposal generation.

Quick Start & Requirements

  • Install: Clone the repository, create a conda environment (conda create -n FastSAM python=3.9), activate it (conda activate FastSAM), and install dependencies (cd FastSAM; pip install -r requirements.txt). Install CLIP separately if using text prompts (pip install git+https://github.com/openai/CLIP.git).
  • Prerequisites: Python >= 3.7, PyTorch >= 1.7, TorchVision >= 0.8. CUDA support for PyTorch/TorchVision is strongly recommended.
  • Getting Started: Download model checkpoints. Run inference via python Inference.py with options for everything, text, box, or point prompts.
  • Demos: HuggingFace Demo, Colab Demo, Replicate Demo & API.

Highlighted Details

  • Achieves 50x higher run-time speed compared to SAM.
  • Offers two model versions: FastSAM (YOLOv8x based) and FastSAM-s (YOLOv8s based).
  • Supports various prompt modes: everything, text, box, and points.
  • Demonstrates competitive zero-shot transfer performance on edge detection and object proposals.
  • Integrates with Ultralytics (YOLOv8) Model Hub.

Maintenance & Community

The project has seen recent updates addressing edge jaggies and synchronizing with the Ultralytics project. It acknowledges contributions from various individuals and teams, including OpenXLab and Grounding-SAM. Links to demos and model zoo are provided.

Licensing & Compatibility

Licensed under the Apache 2.0 license, permitting commercial use and integration with closed-source projects.

Limitations & Caveats

While significantly faster, FastSAM's instance segmentation performance (AP) is lower than SAM and ViTDet-H on the COCO 2017 dataset. The project also notes an issue with edge jaggies, which has seen minor improvements.

Health Check
Last commit

1 year ago

Responsiveness

1 day

Pull Requests (30d)
2
Issues (30d)
3
Star History
175 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.