Metadata-Version: 2.4
Name: micro_sam
Version: 2.0.1
Summary: Segment Anything For Microscopy
Home-page: https://github.com/computational-cell-analytics/micro-sam
Author: Anwai Archit, Paul Hilt, Genevieve Buckley, Constantin Pape
License: MIT
Project-URL: Bug Tracker, https://github.com/computational-cell-analytics/micro-sam/issues
Project-URL: Documentation, https://computational-cell-analytics.github.io/micro-sam/micro_sam.html
Project-URL: Source Code, https://github.com/computational-cell-analytics/micro-sam
Project-URL: User Support, https://github.com/computational-cell-analytics/micro-sam/issues
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: napari
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Image Processing
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: bioimage-cpp>=0.7
Requires-Dist: bioimage-py>=0.2.2
Requires-Dist: bioimageio.core>=0.11
Requires-Dist: click
Requires-Dist: h5py
Requires-Dist: huggingface-hub
Requires-Dist: imagecodecs
Requires-Dist: imageio
Requires-Dist: joblib
Requires-Dist: kornia
Requires-Dist: magicgui
Requires-Dist: matplotlib
Requires-Dist: napari<0.11,>=0.7.1
Requires-Dist: natsort
Requires-Dist: networkx
Requires-Dist: numpy
Requires-Dist: pandas
Requires-Dist: pooch
Requires-Dist: pydantic<2.14
Requires-Dist: PyQt6<6.10; sys_platform == "linux"
Requires-Dist: PyQt6<6.12; sys_platform == "darwin"
Requires-Dist: PyQt6; sys_platform != "linux" and sys_platform != "darwin"
Requires-Dist: python-elf>=0.9
Requires-Dist: sam2==1.1.0
Requires-Dist: scikit-image
Requires-Dist: scikit-learn
Requires-Dist: segment-anything-py>=1.0.1
Requires-Dist: superqt
Requires-Dist: tensordict
Requires-Dist: timm
Requires-Dist: torch>=2.5
Requires-Dist: torch-em>=0.10.8
Requires-Dist: torchvision
Requires-Dist: tqdm
Requires-Dist: trackastra>=0.5.3
Requires-Dist: transformers>=4.56
Requires-Dist: xarray
Requires-Dist: xxhash
Requires-Dist: z5py>=3
Requires-Dist: zarr>=3
Dynamic: license-file

[![DOC](https://shields.mitmproxy.org/badge/docs-pdoc.dev-brightgreen.svg)](https://computational-cell-analytics.github.io/micro-sam/)
[![PyPI](https://img.shields.io/pypi/v/micro_sam.svg)](https://pypi.org/project/micro_sam/)
[![Conda](https://anaconda.org/conda-forge/micro_sam/badges/version.svg)](https://anaconda.org/conda-forge/micro_sam)
[![codecov](https://codecov.io/gh/computational-cell-analytics/micro-sam/graph/badge.svg?token=7ETPP5CABP)](https://codecov.io/gh/computational-cell-analytics/micro-sam)
[![Image.sc forum][imagesc-img]][imagesc-url]
[![DOI](https://img.shields.io/badge/DOI-10.5281%2Fzenodo.7919746-blue.svg)](https://doi.org/10.5281/zenodo.7919746)

# Segment Anything for Microscopy 2

<a href="https://github.com/computational-cell-analytics/micro-sam"><img src="https://raw.githubusercontent.com/computational-cell-analytics/micro-sam/main/doc/logo/v2/logo_and_text.png" width="300" align="right">

Tools for segmentation, tracking and classification in microscopy built on [Segment Anything 2 (SAM2)](https://ai.meta.com/sam2/).
Segment, track and classify objects in microscopy images interactively with a few clicks, or automatically.

We implement a napari plugin for:
- interactive and automatic segmentation of 2d images and 3d volumes
- interactive and automatic tracking of cells in 2d timeseries
- classification of segmented objects, for example into cell types
- pixel classification, for example for tissue or region segmentation
- batch annotation of all images in a folder with any of these tools

This functionality is powered by the `micro-sam2` models, which are trained on microscopy data, and the `micro_sam` python library which enables application to large datasets and finetuning on your data.

The functionality of the previous version, based on the original [Segment Anything](https://segment-anything.com/) (SAM1), is still available in the `micro_sam.v1` subpackage and in the `micro_sam v1` command line tools.

<table>
<tr>
<td align="center"><img src="https://raw.githubusercontent.com/computational-cell-analytics/micro-sam/main/doc/gifs/interactive_2d.gif" width="176"><br>Interactive Cell Segmentation in 2D</td>
<td align="center"><img src="https://raw.githubusercontent.com/computational-cell-analytics/micro-sam/main/doc/gifs/interactive_3d.gif" width="176"><br>Interactive Mitochondria Segmentation in volumeEM</td>
<td align="center"><img src="https://raw.githubusercontent.com/computational-cell-analytics/micro-sam/main/doc/gifs/automatic_3d.gif" width="176"><br>Automatic Cell Segmentation in 3D</td>
<td align="center"><img src="https://raw.githubusercontent.com/computational-cell-analytics/micro-sam/main/doc/gifs/interactive_tracking.gif" width="176"><br>Interactive Cell Tracking in 2D+T</td>
</tr>
</table>
<table align="center">
<tr>
<td align="center"><img src="https://raw.githubusercontent.com/computational-cell-analytics/micro-sam/main/doc/gifs/pixel_classification.gif" width="176"><br>Pixel Classification in Histopathology</td>
<td align="center"><img src="https://raw.githubusercontent.com/computational-cell-analytics/micro-sam/main/doc/gifs/object_classification.gif" width="176"><br>Object Classification with Corrections</td>
<td align="center"><img src="https://raw.githubusercontent.com/computational-cell-analytics/micro-sam/main/doc/gifs/batch_object_classification.gif" width="176"><br>Batch Nucleus Classification in Histopathology</td>
</tr>
</table>

If you run into any problems or have questions about our tool, please open an [issue](https://github.com/computational-cell-analytics/micro-sam/issues/new/choose) on GitHub or contact us via [image.sc](https://forum.image.sc/) using the tag `micro-sam`, and tagging [@anwai98](https://forum.image.sc/u/anwai98/summary) and [@constantinpape](https://forum.image.sc/u/constantinpape/summary).
You can follow recent updates on `micro_sam` in our [news feed](https://forum.image.sc/t/microsam-news-feed).

## Installation and Usage

Please check [the documentation](https://computational-cell-analytics.github.io/micro-sam/) for details on how to install and use `micro_sam`. You can also watch [the quickstart video](https://youtu.be/gcv0fa84mCc), [our virtual I2K workshop video](https://www.youtube.com/watch?v=dxjU4W7bCis&list=PLdA9Vgd1gxTbvxmtk9CASftUOl_XItjDN&index=33) or [all video tutorials](https://youtube.com/playlist?list=PLwYZXQJ3f36GQPpKCrSbHjGiH39X4XjSO&si=qNbB8IFXqAX33r_Z). The videos show the previous version, so the user interface differs from the current one.

`micro_sam` works best on a computer with a GPU. It can be used on a normal laptop with a CPU, but will be slow for applications in 3D or for large images.
Note: we are working on improving performance on Macbook with an M-series chip;
it will be much faster there soon!


## Contributing

We always welcome new contributions!

If you just want to suggest a documentation edit, [you can do this directly here, on GitHub][edit-files-on-github].
For more complex changes, see [CONTRIBUTING.md][contributing] or the [contributing guide](https://computational-cell-analytics.github.io/micro-sam/micro_sam.html#contribution-guide) in our documentation for details. The first step is to [discuss your idea in a new issue](https://github.com/computational-cell-analytics/micro-sam/issues/new) with the current developers.

Everyone participating in this project is expected to follow our [Code of Conduct][code-of-conduct].


## Citation

If you use this repository in your research, please cite
- our [μSAM2 preprint](https://doi.org/10.64898/2026.11.12.766082) (if you use μSAM2)
- our [μSAM publication](https://www.nature.com/articles/s41592-024-02580-4) (μSAM1)
- If you use automatic tracking, please also cite [Trackastra](https://arxiv.org/abs/2405.15700).

Other publications relevant for specific aspects:
- The [SAM](https://arxiv.org/abs/2304.02643) and [SAM2](https://arxiv.org/abs/2408.00714) publications that describe the models we buid on for μSAM1 / μSAM2.
- Our publication on the [Automatic Prompt Generation (APG)](https://openreview.net/forum?id=xFO3DFZN45) segmentation mode.
- Our publication on interactive object and pixel classification: [μClass](https://arxiv.org/abs/2603.19802)
- Our previous special-purpose models for [histopathology](https://arxiv.org/abs/2502.00408) and [medical imaging](https://ieeexplore.ieee.org/abstract/document/11303368).


## Related Projects

There is one other napari plugin built around Segment Anything 2:
- https://github.com/royerlab/napari-segment-anything-2 (2d and video support)

Compared to this plugin we support more applications (2d, 3d, tracking and classification), and provide finetuning methods and finetuned models for microscopy data.
[WebKnossos](https://webknossos.org/), [QuPath](https://github.com/ksugar/qupath-extension-sam) and [Fiji](https://github.com/segment-anything-models-java/SAMJ-IJ) also integrate Segment Anything 2 for interactive segmentation, mainly in 2d.

## Release Overview

You can find an overview of changes introduced in previous releases [here](https://github.com/computational-cell-analytics/micro-sam/blob/main/RELEASE_OVERVIEW.md).

[imagesc-img]: https://img.shields.io/badge/dynamic/json.svg?label=forum&url=https%3A%2F%2Fforum.image.sc%2Ftags%2Fmicro-sam.json&query=%24.topic_list.tags.0.topic_count&colorB=brightgreen&suffix=%20topics&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAABPklEQVR42m3SyyqFURTA8Y2BER0TDyExZ+aSPIKUlPIITFzKeQWXwhBlQrmFgUzMMFLKZeguBu5y+//17dP3nc5vuPdee6299gohUYYaDGOyyACq4JmQVoFujOMR77hNfOAGM+hBOQqB9TjHD36xhAa04RCuuXeKOvwHVWIKL9jCK2bRiV284QgL8MwEjAneeo9VNOEaBhzALGtoRy02cIcWhE34jj5YxgW+E5Z4iTPkMYpPLCNY3hdOYEfNbKYdmNngZ1jyEzw7h7AIb3fRTQ95OAZ6yQpGYHMMtOTgouktYwxuXsHgWLLl+4x++Kx1FJrjLTagA77bTPvYgw1rRqY56e+w7GNYsqX6JfPwi7aR+Y5SA+BXtKIRfkfJAYgj14tpOF6+I46c4/cAM3UhM3JxyKsxiOIhH0IO6SH/A1Kb1WBeUjbkAAAAAElFTkSuQmCC
[imagesc-url]: https://forum.image.sc/tag/micro-sam
[contributing]: https://github.com/computational-cell-analytics/micro-sam/blob/main/CONTRIBUTING.md
[code-of-conduct]: https://github.com/computational-cell-analytics/micro-sam/blob/main/CODE_OF_CONDUCT.md
[edit-files-on-github]: https://docs.github.com/en/repositories/working-with-files/managing-files/editing-files
