computational-cell-analytics/micro-sam
Segment Anything for Microscopy 2
What it is
micro-sam is a set of tools for working with microscopy images — specifically for segmentation (drawing outlines around objects like cells), tracking (following cells over time), and classification (labeling objects, e.g., by cell type). It's built on Meta's Segment Anything 2 (SAM2) model, but trained on microscopy data so it understands what cells and tissues look like.
What you can do with it
It comes as a plugin for napari (a Python image viewer) and lets you:
- Segment objects in 2D images and 3D volumes — either interactively (you click a few points and it finds the object) or automatically (no clicks needed).
- Track cells in 2D time-lapse videos, interactively or automatically.
- Classify segmented objects — for example, telling cell types apart.
- Do pixel classification — labeling every pixel of an image, useful for marking whole regions like tissue types.
- Process entire folders of images in batch with any of the above.
How it works under the hood
Two pieces power it:
- micro-sam2 models — pre-trained on microscopy data, so they already know what cells and tissues look like.
- The micro_sam Python library — lets you apply these models to large datasets and fine-tune them on your own data.
The older version (based on the original SAM1 model) is still available as micro_sam.v1 and via micro_sam v1 command-line tools.
Installation & usage
Full instructions are in the documentation. There are also video tutorials (note: they show the previous version, so the interface looks a bit different).
- Works best on a computer with a GPU.
- Can run on a normal laptop with a CPU, but will be slow for 3D volumes or large images.
- The team is working on improving performance on Apple M-series Macs.
Getting help & contributing
- Problems or questions? Open a GitHub issue or ask on the image.sc forum with the tag
micro-sam. - Contributions are welcome. For simple documentation edits, you can edit files directly on GitHub. For bigger changes, discuss your idea in a new issue first, and check the contributing guide.
- All participants must follow the project's Code of Conduct.
Citation
If you use it in research, cite the μSAM2 preprint (for the new version) or the μSAM publication (for the old one). If you use automatic tracking, also cite Trackastra. Other relevant papers cover SAM/SAM2, the Automatic Prompt Generation (APG) segmentation mode, the μClass classification method, and special-purpose models for histopathology and medical imaging.
Related projects
Another napari plugin, napari-segment-anything-2, also builds on SAM2 but only supports 2D and video. micro-sam goes further: it handles 2D, 3D, tracking, and classification, and provides fine-tuning methods and models trained specifically for microscopy. Tools like WebKnossos, QuPath, and Fiji also integrate SAM2, mainly for 2D interactive segmentation.
Related
- Project
- Project
- Project
- Project
- Project