Skip to main content

napari-cellposesam cellpose

Documentation Status tests PyPI version Python version License website

A napari plugin for cell segmentation with cellpose, including Cellpose-SAM (cellpose 4).

This is a fork of MouseLand/cellpose-napari, the original plugin by Carsen Stringer. It adds:

  • support for Cellpose-SAM (cpsam) and Cellpose3 models in the same environment and UI
  • z/channel axis selection for 3D and 4D images
  • compatibility with new napari versions

The cellpose code was written by Carsen Stringer and Marius Pachitariu. To learn about Cellpose, read the paper or watch this talk.

For problems with this plugin, open an issue. For problems with cellpose itself, open an issue on the cellpose repo.

If you use this plugin, please cite the cellpose paper, the Cellpose3 paper if you use the Cellpose3 models, and the Cellpose-SAM paper if you use the cpsam models (see the cellpose repo for the references):

@article{stringer2021cellpose,
  title={Cellpose: a generalist algorithm for cellular segmentation},
  author={Stringer, Carsen and Wang, Tim and Michaelos, Michalis and Pachitariu, Marius},
  journal={Nature Methods},
  volume={18},
  number={1},
  pages={100--106},
  year={2021},
  publisher={Nature Publishing Group}
}

napari-cellposesam segmenting the 2D sample image

Installation

Requires Python 3.11 or newer. We recommend a fresh environment, e.g. with conda:

conda create -n napari-cellposesam python=3.12
conda activate napari-cellposesam

Install napari and the plugin with pip:

pip install "napari[all]" napari-cellposesam

Or install the plugin from the napari plugin manager (Plugins > Install/Uninstall Plugins).

To install the latest development version from GitHub:

pip install git+https://github.com/jeskowagner/napari-cellposesam

If you have issues installing cellpose, see the cellpose installation docs.

Cellpose3 models

The plugin installs cellpose 4, which provides the Cellpose-SAM and CPDINO models. The Cellpose3 models (cyto3, nuclei, etc.) are in the same model list. They need cellpose 3, which the plugin offers to download the first time you run one. It downloads cellpose 3.1.1.3 into a private folder without touching the installed cellpose, and installs numba if it is missing. The plugin then picks the right cellpose version for each model, including custom models.

The private copy is in ~/.cellpose/napari-cellposesam/cellpose-3.1.1.3-format1/_cellpose3 (~ is your user folder, also on Windows). To keep it elsewhere, set the environment variable NAPARI_CELLPOSESAM_CACHE to a folder that then takes the place of ~/.cellpose/napari-cellposesam. To reset it, delete ~/.cellpose/napari-cellposesam (or the folder NAPARI_CELLPOSESAM_CACHE names): the plugin offers to download cellpose 3 again the next time you run a Cellpose3 model.

To run the same download ahead of time, so that napari never prompts:

python -m napari_cellposesam fetch-cellpose3

The download goes to the home folder of whoever runs the command. For an environment shared by several users, set NAPARI_CELLPOSESAM_CACHE to a shared folder, both when running the command and for everyone who uses the environment. Users only need read access to it.

Both need internet access and pip in the environment. If the environment has no pip, as in some uv-created ones, the plugin asks you to install it first.

Don't install cellpose-napari next to this plugin. It lists the Cellpose3 models, but with cellpose 4 installed it ignores the selected model and runs Cellpose-SAM, thus breaking it.

GPU

cellpose runs on CPU, NVIDIA GPUs (CUDA) and Apple silicon (MPS). The plugin uses a GPU automatically if torch can see one, for both the cellpose 4 and the Cellpose3 models.

  • Apple silicon: nothing to do, the torch from PyPI supports MPS.

  • NVIDIA on Linux: the torch from PyPI is a CUDA build, so it usually works as installed.

  • NVIDIA on Windows: the torch from PyPI is CPU-only. In a fresh environment, install torch and torchvision from the PyTorch index first, with the CUDA version the PyTorch selector gives for your driver, then napari and the plugin, e.g.:

    pip install torch torchvision --index-url https://download.pytorch.org/whl/cu126
    pip install "napari[all]" napari-cellposesam
    

    If the plugin is already installed, reinstall torch and torchvision together instead:

    pip install --force-reinstall --no-deps torch torchvision --index-url https://download.pytorch.org/whl/cu126
    

Check that torch sees the GPU:

python -c "import torch; print('cuda', torch.cuda.is_available(), 'mps', torch.backends.mps.is_available())"

Optional: CPDINO models

The CPDINO models need DINOv3, which is not on PyPI and so is not installed automatically. The plugin offers to install it when you run segmentation with a CPDINO model, or install it yourself:

pip install git+https://github.com/facebookresearch/dinov3

Without it, cellpose logs a Could not import CPDINO warning on startup. This is harmless if you don't use those models.

Upgrading

pip install --upgrade napari-cellposesam cellpose

If you installed a CUDA build of torch, upgrade torch the same way you installed it, or pip may replace it with the CPU-only build.

Coming from 0.1.x with a separate cellpose 3 environment (cellpose<4): from 0.2.0 that environment is no longer needed, since one environment runs both the Cellpose3 and the cellpose 4 models. Upgrading it with the command above moves it to cellpose 4, and the plugin downloads cellpose 3 the first time you run a Cellpose3 model.

Usage

Open napari with the plugin docked:

napari -w napari-cellposesam

Sample data is available under File > Open Sample > napari-cellposesam.

Detailed usage is described in the documentation.

Contributing

Contributions are welcome. For development, clone the repo and install it in editable mode with the test dependencies:

pip install -e ".[testing]"
pytest

License

Distributed under the terms of the BSD-3 license, "napari-cellposesam" is free and open source software.

Dependencies

napari-cellposesam relies on:

Metadata

Release files for napari-cellposesam 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for napari-cellposesam 0.2.1
File Size Uploaded Provenance Actions
napari_cellposesam-0.2.1.tar.gz 340.5 kB With provenance Details for napari_cellposesam-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for napari-cellposesam 0.2.1
File Interpreter ABI Platform Actions
napari_cellposesam-0.2.1-py3-none-any.whl Python 3 none any Details for napari_cellposesam-0.2.1-py3-none-any.whl

Total release size: 362.1 kB

Release files / napari_cellposesam-0.2.1.tar.gz

Download URL napari_cellposesam-0.2.1.tar.gz
Size 340.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a307a13a40fb7a05bf4df9a485ff0e95fed3b36c10e49794e321731ec69ebc9e
BLAKE2b-256 checksum
How to use checksums
98bc48a6b99bb5367df6e633162fab2f897e3a8cbf1f0e003c90e701332fcf37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Release files / napari_cellposesam-0.2.1-py3-none-any.whl

Download URL napari_cellposesam-0.2.1-py3-none-any.whl
Size 21.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ea8b2be77f4923ed0f28be03ae9866b2219403642f84d39a4026a1ac00756fea
BLAKE2b-256 checksum
How to use checksums
46216d11e595bf41d1b4a908252d4793debb3f5c59e019c20fb3d05d353ca1cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Security for napari-cellposesam 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for napari_cellposesam-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page