napari-cellposesam 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. napari_cellposesam-0.1.0/.github/workflows/test_and_deploy.yml +174 -0
  2. napari_cellposesam-0.1.0/.gitignore +79 -0
  3. napari_cellposesam-0.1.0/.readthedocs.yaml +20 -0
  4. napari_cellposesam-0.1.0/LICENSE +28 -0
  5. napari_cellposesam-0.1.0/PKG-INFO +158 -0
  6. napari_cellposesam-0.1.0/README.md +119 -0
  7. napari_cellposesam-0.1.0/docs/Makefile +20 -0
  8. napari_cellposesam-0.1.0/docs/_static/favicon.ico +0 -0
  9. napari_cellposesam-0.1.0/docs/_static/gui.png +0 -0
  10. napari_cellposesam-0.1.0/docs/conf.py +96 -0
  11. napari_cellposesam-0.1.0/docs/index.rst +46 -0
  12. napari_cellposesam-0.1.0/docs/installation.rst +74 -0
  13. napari_cellposesam-0.1.0/docs/make.bat +35 -0
  14. napari_cellposesam-0.1.0/docs/requirements.txt +2 -0
  15. napari_cellposesam-0.1.0/docs/running.rst +54 -0
  16. napari_cellposesam-0.1.0/docs/settings.rst +139 -0
  17. napari_cellposesam-0.1.0/napari_cellposesam/__init__.py +4 -0
  18. napari_cellposesam-0.1.0/napari_cellposesam/_dock_widget.py +563 -0
  19. napari_cellposesam-0.1.0/napari_cellposesam/_sample_data.py +36 -0
  20. napari_cellposesam-0.1.0/napari_cellposesam/_version.py +24 -0
  21. napari_cellposesam-0.1.0/napari_cellposesam/napari.yaml +23 -0
  22. napari_cellposesam-0.1.0/napari_cellposesam.egg-info/PKG-INFO +158 -0
  23. napari_cellposesam-0.1.0/napari_cellposesam.egg-info/SOURCES.txt +32 -0
  24. napari_cellposesam-0.1.0/napari_cellposesam.egg-info/dependency_links.txt +1 -0
  25. napari_cellposesam-0.1.0/napari_cellposesam.egg-info/entry_points.txt +2 -0
  26. napari_cellposesam-0.1.0/napari_cellposesam.egg-info/requires.txt +19 -0
  27. napari_cellposesam-0.1.0/napari_cellposesam.egg-info/scm_file_list.json +27 -0
  28. napari_cellposesam-0.1.0/napari_cellposesam.egg-info/scm_version.json +8 -0
  29. napari_cellposesam-0.1.0/napari_cellposesam.egg-info/top_level.txt +1 -0
  30. napari_cellposesam-0.1.0/pyproject.toml +103 -0
  31. napari_cellposesam-0.1.0/setup.cfg +4 -0
  32. napari_cellposesam-0.1.0/tests/__init__.py +0 -0
  33. napari_cellposesam-0.1.0/tests/conftest.py +3 -0
  34. napari_cellposesam-0.1.0/tests/test_plugin.py +109 -0
@@ -0,0 +1,174 @@
1
+ # Runs tests on push/PR. On a "v*" tag, builds the package and publishes it to PyPI
2
+ # via trusted publishing: https://docs.pypi.org/trusted-publishers/
3
+
4
+ ### test workflow from Talley Lambert's napari-omero! thanks!
5
+ # https://github.com/tlambert03/napari-omero/blob/main/.github/workflows/ci.yml
6
+
7
+ name: tests
8
+
9
+ on:
10
+ push:
11
+ branches:
12
+ - main
13
+ tags:
14
+ - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
15
+ pull_request:
16
+ branches:
17
+ - main
18
+ workflow_dispatch:
19
+
20
+ concurrency:
21
+ group: ${{ github.workflow }}-${{ github.ref }}
22
+ cancel-in-progress: true
23
+
24
+ jobs:
25
+ test:
26
+ name: ${{ matrix.platform }} ${{ matrix.python-version }}
27
+ runs-on: ${{ matrix.platform }}
28
+ strategy:
29
+ fail-fast: false
30
+ matrix:
31
+ platform: [ubuntu-latest, macos-latest, windows-latest]
32
+ python-version: ["3.11", "3.12", "3.13"]
33
+
34
+ steps:
35
+ - uses: actions/checkout@v6
36
+
37
+ - name: Set up Python ${{ matrix.python-version }}
38
+ uses: actions/setup-python@v6
39
+ with:
40
+ python-version: ${{ matrix.python-version }}
41
+
42
+ - uses: tlambert03/setup-qt-libs@v1
43
+
44
+ - name: Install Windows OpenGL
45
+ if: runner.os == 'Windows'
46
+ run: |
47
+ git clone --depth 1 https://github.com/pyvista/gl-ci-helpers.git
48
+ powershell gl-ci-helpers/appveyor/install_opengl.ps1
49
+
50
+ - name: Install dependencies
51
+ run: |
52
+ python -m pip install --upgrade pip
53
+ python -m pip install --upgrade setuptools tox tox-gh-actions
54
+
55
+ # model weights (~1.2 GB) and sample data are fetched once, with retries, and
56
+ # cached, so tests don't download them mid-run from flaky/slow servers
57
+ - name: Restore cellpose models and sample data
58
+ id: cp-cache
59
+ uses: actions/cache/restore@v6
60
+ with:
61
+ path: ~/.cellpose
62
+ key: cellpose-assets-v1-${{ runner.os }}
63
+
64
+ - name: Fetch cellpose models and sample data
65
+ if: steps.cp-cache.outputs.cache-hit != 'true'
66
+ shell: bash
67
+ run: |
68
+ mkdir -p ~/.cellpose/models
69
+ curl -fsSL --retry 5 --retry-all-errors --retry-delay 10 -o ~/.cellpose/models/cpsam https://huggingface.co/mouseland/cellpose-sam/resolve/main/cpsam
70
+ curl -fsSL --retry 5 --retry-all-errors --retry-delay 10 -o ~/.cellpose/data.zip https://osf.io/download/s52q3/
71
+ python -m zipfile -e ~/.cellpose/data.zip ~/.cellpose
72
+
73
+ - name: Save cellpose models and sample data
74
+ if: steps.cp-cache.outputs.cache-hit != 'true'
75
+ uses: actions/cache/save@v6
76
+ with:
77
+ path: ~/.cellpose
78
+ key: cellpose-assets-v1-${{ runner.os }}
79
+
80
+ - name: Test with tox
81
+ uses: aganders3/headless-gui@v2
82
+ with:
83
+ run: python -m tox
84
+ env:
85
+ PLATFORM: ${{ matrix.platform }}
86
+
87
+ - name: Codecov
88
+ uses: codecov/codecov-action@v6
89
+
90
+ test-cellpose3:
91
+ name: cellpose v3 compat (ubuntu, py3.11)
92
+ runs-on: ubuntu-latest
93
+ steps:
94
+ - uses: actions/checkout@v6
95
+
96
+ - uses: actions/setup-python@v6
97
+ with:
98
+ python-version: "3.11"
99
+
100
+ - uses: tlambert03/setup-qt-libs@v1
101
+
102
+ - name: Install dependencies (cellpose v3 pinned)
103
+ run: |
104
+ python -m pip install --upgrade pip
105
+ python -m pip install ".[testing]" "cellpose>=3,<4"
106
+
107
+ - name: Restore cellpose models and sample data
108
+ id: cp-cache
109
+ uses: actions/cache/restore@v6
110
+ with:
111
+ path: ~/.cellpose
112
+ key: cellpose3-assets-v1-${{ runner.os }}
113
+
114
+ - name: Fetch cellpose models and sample data
115
+ if: steps.cp-cache.outputs.cache-hit != 'true'
116
+ run: |
117
+ mkdir -p ~/.cellpose/models
118
+ for f in cyto3 size_cyto3.npy; do
119
+ curl -fsSL --retry 5 --retry-all-errors --retry-delay 10 -o ~/.cellpose/models/$f https://www.cellpose.org/models/$f
120
+ done
121
+ curl -fsSL --retry 5 --retry-all-errors --retry-delay 10 -o ~/.cellpose/data.zip https://osf.io/download/s52q3/
122
+ python -m zipfile -e ~/.cellpose/data.zip ~/.cellpose
123
+
124
+ - name: Save cellpose models and sample data
125
+ if: steps.cp-cache.outputs.cache-hit != 'true'
126
+ uses: actions/cache/save@v6
127
+ with:
128
+ path: ~/.cellpose
129
+ key: cellpose3-assets-v1-${{ runner.os }}
130
+
131
+ - name: Test with pytest
132
+ uses: aganders3/headless-gui@v2
133
+ with:
134
+ run: pytest -v --color=yes
135
+ env:
136
+ CI: true
137
+
138
+ build:
139
+ name: Build distribution
140
+ needs: [test, test-cellpose3]
141
+ runs-on: ubuntu-latest
142
+ if: startsWith(github.ref, 'refs/tags/v')
143
+ steps:
144
+ - uses: actions/checkout@v6
145
+ with:
146
+ fetch-depth: 0 # setuptools_scm needs the tag history for the version
147
+ - uses: actions/setup-python@v6
148
+ with:
149
+ python-version: "3.x"
150
+ - name: Build and check
151
+ run: |
152
+ python -m pip install --upgrade build twine
153
+ python -m build
154
+ twine check dist/*
155
+ - uses: actions/upload-artifact@v7
156
+ with:
157
+ name: dist
158
+ path: dist/
159
+
160
+ publish:
161
+ name: Publish to PyPI
162
+ needs: build
163
+ runs-on: ubuntu-latest
164
+ environment:
165
+ name: pypi
166
+ url: https://pypi.org/p/napari-cellposesam
167
+ permissions:
168
+ id-token: write # trusted publishing
169
+ steps:
170
+ - uses: actions/download-artifact@v8
171
+ with:
172
+ name: dist
173
+ path: dist/
174
+ - uses: pypa/gh-action-pypi-publish@v1.14.2
@@ -0,0 +1,79 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ env/
12
+ build/
13
+ develop-eggs/
14
+ dist/
15
+ downloads/
16
+ eggs/
17
+ .eggs/
18
+ lib/
19
+ lib64/
20
+ parts/
21
+ sdist/
22
+ var/
23
+ *.egg-info/
24
+ .installed.cfg
25
+ *.egg
26
+
27
+ # PyInstaller
28
+ # Usually these files are written by a python script from a template
29
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
30
+ *.manifest
31
+ *.spec
32
+
33
+ # Installer logs
34
+ pip-log.txt
35
+ pip-delete-this-directory.txt
36
+
37
+ # Unit test / coverage reports
38
+ htmlcov/
39
+ .tox/
40
+ .coverage
41
+ .coverage.*
42
+ .cache
43
+ nosetests.xml
44
+ coverage.xml
45
+ *,cover
46
+ .hypothesis/
47
+ .napari_cache
48
+
49
+ # Translations
50
+ *.mo
51
+ *.pot
52
+
53
+ # Django stuff:
54
+ *.log
55
+ local_settings.py
56
+
57
+ # Flask instance folder
58
+ instance/
59
+
60
+ # Sphinx documentation
61
+ docs/_build/
62
+
63
+ # MkDocs documentation
64
+ /site/
65
+
66
+ # PyBuilder
67
+ target/
68
+
69
+ # IPython Notebook
70
+ .ipynb_checkpoints
71
+
72
+ # pyenv
73
+ .python-version
74
+
75
+ # OS
76
+ .DS_Store
77
+
78
+ # written by setuptools_scm
79
+ */_version.py
@@ -0,0 +1,20 @@
1
+ # Read the Docs configuration file
2
+ # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3
+
4
+ # Required
5
+ version: 2
6
+
7
+ # Set the OS, Python version, and other tools you might need
8
+ build:
9
+ os: ubuntu-24.04
10
+ tools:
11
+ python: "3.13"
12
+
13
+ # Build documentation in the "docs/" directory with Sphinx
14
+ sphinx:
15
+ configuration: docs/conf.py
16
+
17
+ # Only the docs toolchain is installed, not the plugin (which would pull in torch)
18
+ python:
19
+ install:
20
+ - requirements: docs/requirements.txt
@@ -0,0 +1,28 @@
1
+
2
+ Copyright (c) 2021, Carsen Stringer
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ * Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ * Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ * Neither the name of cellpose-napari nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,158 @@
1
+ Metadata-Version: 2.4
2
+ Name: napari-cellposesam
3
+ Version: 0.1.0
4
+ Summary: napari plugin for cellpose and Cellpose-SAM segmentation
5
+ Author-email: Carsen Stringer <stringerc@janelia.hhmi.org>, Jesko Wagner <35219306+jeskowagner@users.noreply.github.com>
6
+ License: BSD-3-Clause
7
+ Project-URL: Homepage, https://github.com/jeskowagner/napari-cellposesam
8
+ Project-URL: Bug Tracker, https://github.com/jeskowagner/napari-cellposesam/issues
9
+ Project-URL: Upstream, https://github.com/MouseLand/cellpose-napari
10
+ Classifier: Programming Language :: Python
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: License :: OSI Approved :: BSD License
17
+ Classifier: Framework :: napari
18
+ Requires-Python: >=3.11
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: napari>=0.6
22
+ Requires-Dist: magicgui
23
+ Requires-Dist: cellpose>=3
24
+ Requires-Dist: imagecodecs
25
+ Provides-Extra: docs
26
+ Requires-Dist: sphinx>=3.0; extra == "docs"
27
+ Requires-Dist: sphinxcontrib-apidoc; extra == "docs"
28
+ Requires-Dist: sphinx_rtd_theme; extra == "docs"
29
+ Requires-Dist: sphinx-prompt; extra == "docs"
30
+ Requires-Dist: sphinx-autodoc-typehints; extra == "docs"
31
+ Provides-Extra: testing
32
+ Requires-Dist: tox; extra == "testing"
33
+ Requires-Dist: pytest; extra == "testing"
34
+ Requires-Dist: pytest-cov; extra == "testing"
35
+ Requires-Dist: pytest-qt; extra == "testing"
36
+ Requires-Dist: napari; extra == "testing"
37
+ Requires-Dist: pyqt6; extra == "testing"
38
+ Dynamic: license-file
39
+
40
+ # napari-cellposesam <img src="docs/_static/favicon.ico" width="50" title="cellpose" alt="cellpose" align="right" vspace = "50">
41
+
42
+ [![Documentation Status](https://readthedocs.org/projects/napari-cellposesam/badge/?version=latest)](https://napari-cellposesam.readthedocs.io/en/latest/)
43
+ [![tests](https://github.com/jeskowagner/napari-cellposesam/actions/workflows/test_and_deploy.yml/badge.svg)](https://github.com/jeskowagner/napari-cellposesam/actions)
44
+ [![PyPI version](https://img.shields.io/pypi/v/napari-cellposesam)](https://pypi.org/project/napari-cellposesam/)
45
+ [![Python version](https://img.shields.io/pypi/pyversions/napari-cellposesam)](https://pypi.org/project/napari-cellposesam/)
46
+ [![License](https://img.shields.io/pypi/l/napari-cellposesam.svg?color=green)](https://github.com/jeskowagner/napari-cellposesam/raw/main/LICENSE)
47
+ [![website](https://img.shields.io/website?url=https%3A%2F%2Fwww.cellpose.org)](https://www.cellpose.org)
48
+
49
+ A [napari] plugin for cell segmentation with [cellpose], including Cellpose-SAM (cellpose v4).
50
+
51
+ This is a fork of [MouseLand/cellpose-napari](https://github.com/MouseLand/cellpose-napari), the original plugin by Carsen Stringer. It adds:
52
+
53
+ - support for cellpose v4 and the Cellpose-SAM (`cpsam`) models, while still working with cellpose v3
54
+ - z/channel axis selection for 3D and 4D images
55
+ - fp32 inference on CPU, which is much faster than bf16 on CPUs without native bf16 support
56
+ - an npe2 manifest and `pyproject.toml` packaging
57
+
58
+ The cellpose code was written by Carsen Stringer and Marius Pachitariu. To learn about Cellpose, read the [**paper**](https://t.co/kBMXmPp3Yn?amp=1) or watch this [**talk**](https://t.co/JChCsTD0SK?amp=1).
59
+
60
+ For problems with this plugin, open an [issue](https://github.com/jeskowagner/napari-cellposesam/issues). For problems with cellpose itself, open an [issue](https://github.com/MouseLand/cellpose/issues) on the cellpose repo.
61
+
62
+ If you use this plugin, please cite the [cellpose paper](https://www.nature.com/articles/s41592-020-01018-x), and the Cellpose-SAM paper if you use the `cpsam` models (see the [cellpose repo](https://github.com/MouseLand/cellpose) for the reference):
63
+
64
+ ```bibtex
65
+ @article{stringer2021cellpose,
66
+ title={Cellpose: a generalist algorithm for cellular segmentation},
67
+ author={Stringer, Carsen and Wang, Tim and Michaelos, Michalis and Pachitariu, Marius},
68
+ journal={Nature Methods},
69
+ volume={18},
70
+ number={1},
71
+ pages={100--106},
72
+ year={2021},
73
+ publisher={Nature Publishing Group}
74
+ }
75
+ ```
76
+
77
+ ![napari-cellposesam segmenting the 2D sample image](https://raw.githubusercontent.com/jeskowagner/napari-cellposesam/main/docs/_static/gui.png)
78
+
79
+ ## Installation
80
+
81
+ Requires Python 3.11 or newer. We recommend a fresh environment, e.g. with conda:
82
+
83
+ ```
84
+ conda create -n napari-cellposesam python=3.12
85
+ conda activate napari-cellposesam
86
+ ```
87
+
88
+ Install napari and the plugin with pip:
89
+
90
+ ```
91
+ pip install "napari[all]" napari-cellposesam
92
+ ```
93
+
94
+ Or install the plugin from the napari plugin manager (Plugins > Install/Uninstall Plugins).
95
+
96
+ To install the latest development version from GitHub:
97
+
98
+ ```
99
+ pip install git+https://github.com/jeskowagner/napari-cellposesam
100
+ ```
101
+
102
+ If you have issues installing cellpose, see the [cellpose installation docs](https://cellpose.readthedocs.io/en/latest/installation.html).
103
+
104
+ ### GPU
105
+
106
+ cellpose runs on CPU, NVIDIA GPUs (CUDA) and Apple silicon (MPS). For CUDA, install a CUDA build of torch following the [PyTorch instructions](https://pytorch.org/get-started/locally/) before or after installing the plugin. The plugin uses the GPU automatically if torch can see one.
107
+
108
+ ### Optional: CPDINO models
109
+
110
+ The CPDINO models need [DINOv3](https://github.com/facebookresearch/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:
111
+
112
+ ```
113
+ pip install git+https://github.com/facebookresearch/dinov3
114
+ ```
115
+
116
+ Without it, cellpose logs a `Could not import CPDINO` warning on startup. This is harmless if you don't use those models.
117
+
118
+ ### Upgrading
119
+
120
+ ```
121
+ pip install --upgrade napari-cellposesam cellpose
122
+ ```
123
+
124
+ ## Usage
125
+
126
+ Open napari with the plugin docked:
127
+
128
+ ```
129
+ napari -w napari-cellposesam
130
+ ```
131
+
132
+ Sample data is available under File > Open Sample > napari-cellposesam.
133
+
134
+ Detailed usage is described in the [documentation](https://napari-cellposesam.readthedocs.io/).
135
+
136
+ ## Contributing
137
+
138
+ Contributions are welcome. For development, clone the repo and install it in editable mode with the test dependencies:
139
+
140
+ ```
141
+ pip install -e ".[testing]"
142
+ pytest
143
+ ```
144
+
145
+ ## License
146
+
147
+ Distributed under the terms of the [BSD-3] license, "napari-cellposesam" is free and open source software.
148
+
149
+ ## Dependencies
150
+
151
+ napari-cellposesam relies on:
152
+ - [napari](https://napari.org)
153
+ - [magicgui](https://napari.org/magicgui/)
154
+ - [cellpose], which in turn uses [torch](https://pytorch.org/), [numpy](https://numpy.org/), [scipy](https://scipy.org/), [opencv](https://opencv.org/) and others
155
+
156
+ [napari]: https://github.com/napari/napari
157
+ [cellpose]: https://github.com/MouseLand/cellpose
158
+ [BSD-3]: http://opensource.org/licenses/BSD-3-Clause
@@ -0,0 +1,119 @@
1
+ # napari-cellposesam <img src="docs/_static/favicon.ico" width="50" title="cellpose" alt="cellpose" align="right" vspace = "50">
2
+
3
+ [![Documentation Status](https://readthedocs.org/projects/napari-cellposesam/badge/?version=latest)](https://napari-cellposesam.readthedocs.io/en/latest/)
4
+ [![tests](https://github.com/jeskowagner/napari-cellposesam/actions/workflows/test_and_deploy.yml/badge.svg)](https://github.com/jeskowagner/napari-cellposesam/actions)
5
+ [![PyPI version](https://img.shields.io/pypi/v/napari-cellposesam)](https://pypi.org/project/napari-cellposesam/)
6
+ [![Python version](https://img.shields.io/pypi/pyversions/napari-cellposesam)](https://pypi.org/project/napari-cellposesam/)
7
+ [![License](https://img.shields.io/pypi/l/napari-cellposesam.svg?color=green)](https://github.com/jeskowagner/napari-cellposesam/raw/main/LICENSE)
8
+ [![website](https://img.shields.io/website?url=https%3A%2F%2Fwww.cellpose.org)](https://www.cellpose.org)
9
+
10
+ A [napari] plugin for cell segmentation with [cellpose], including Cellpose-SAM (cellpose v4).
11
+
12
+ This is a fork of [MouseLand/cellpose-napari](https://github.com/MouseLand/cellpose-napari), the original plugin by Carsen Stringer. It adds:
13
+
14
+ - support for cellpose v4 and the Cellpose-SAM (`cpsam`) models, while still working with cellpose v3
15
+ - z/channel axis selection for 3D and 4D images
16
+ - fp32 inference on CPU, which is much faster than bf16 on CPUs without native bf16 support
17
+ - an npe2 manifest and `pyproject.toml` packaging
18
+
19
+ The cellpose code was written by Carsen Stringer and Marius Pachitariu. To learn about Cellpose, read the [**paper**](https://t.co/kBMXmPp3Yn?amp=1) or watch this [**talk**](https://t.co/JChCsTD0SK?amp=1).
20
+
21
+ For problems with this plugin, open an [issue](https://github.com/jeskowagner/napari-cellposesam/issues). For problems with cellpose itself, open an [issue](https://github.com/MouseLand/cellpose/issues) on the cellpose repo.
22
+
23
+ If you use this plugin, please cite the [cellpose paper](https://www.nature.com/articles/s41592-020-01018-x), and the Cellpose-SAM paper if you use the `cpsam` models (see the [cellpose repo](https://github.com/MouseLand/cellpose) for the reference):
24
+
25
+ ```bibtex
26
+ @article{stringer2021cellpose,
27
+ title={Cellpose: a generalist algorithm for cellular segmentation},
28
+ author={Stringer, Carsen and Wang, Tim and Michaelos, Michalis and Pachitariu, Marius},
29
+ journal={Nature Methods},
30
+ volume={18},
31
+ number={1},
32
+ pages={100--106},
33
+ year={2021},
34
+ publisher={Nature Publishing Group}
35
+ }
36
+ ```
37
+
38
+ ![napari-cellposesam segmenting the 2D sample image](https://raw.githubusercontent.com/jeskowagner/napari-cellposesam/main/docs/_static/gui.png)
39
+
40
+ ## Installation
41
+
42
+ Requires Python 3.11 or newer. We recommend a fresh environment, e.g. with conda:
43
+
44
+ ```
45
+ conda create -n napari-cellposesam python=3.12
46
+ conda activate napari-cellposesam
47
+ ```
48
+
49
+ Install napari and the plugin with pip:
50
+
51
+ ```
52
+ pip install "napari[all]" napari-cellposesam
53
+ ```
54
+
55
+ Or install the plugin from the napari plugin manager (Plugins > Install/Uninstall Plugins).
56
+
57
+ To install the latest development version from GitHub:
58
+
59
+ ```
60
+ pip install git+https://github.com/jeskowagner/napari-cellposesam
61
+ ```
62
+
63
+ If you have issues installing cellpose, see the [cellpose installation docs](https://cellpose.readthedocs.io/en/latest/installation.html).
64
+
65
+ ### GPU
66
+
67
+ cellpose runs on CPU, NVIDIA GPUs (CUDA) and Apple silicon (MPS). For CUDA, install a CUDA build of torch following the [PyTorch instructions](https://pytorch.org/get-started/locally/) before or after installing the plugin. The plugin uses the GPU automatically if torch can see one.
68
+
69
+ ### Optional: CPDINO models
70
+
71
+ The CPDINO models need [DINOv3](https://github.com/facebookresearch/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:
72
+
73
+ ```
74
+ pip install git+https://github.com/facebookresearch/dinov3
75
+ ```
76
+
77
+ Without it, cellpose logs a `Could not import CPDINO` warning on startup. This is harmless if you don't use those models.
78
+
79
+ ### Upgrading
80
+
81
+ ```
82
+ pip install --upgrade napari-cellposesam cellpose
83
+ ```
84
+
85
+ ## Usage
86
+
87
+ Open napari with the plugin docked:
88
+
89
+ ```
90
+ napari -w napari-cellposesam
91
+ ```
92
+
93
+ Sample data is available under File > Open Sample > napari-cellposesam.
94
+
95
+ Detailed usage is described in the [documentation](https://napari-cellposesam.readthedocs.io/).
96
+
97
+ ## Contributing
98
+
99
+ Contributions are welcome. For development, clone the repo and install it in editable mode with the test dependencies:
100
+
101
+ ```
102
+ pip install -e ".[testing]"
103
+ pytest
104
+ ```
105
+
106
+ ## License
107
+
108
+ Distributed under the terms of the [BSD-3] license, "napari-cellposesam" is free and open source software.
109
+
110
+ ## Dependencies
111
+
112
+ napari-cellposesam relies on:
113
+ - [napari](https://napari.org)
114
+ - [magicgui](https://napari.org/magicgui/)
115
+ - [cellpose], which in turn uses [torch](https://pytorch.org/), [numpy](https://numpy.org/), [scipy](https://scipy.org/), [opencv](https://opencv.org/) and others
116
+
117
+ [napari]: https://github.com/napari/napari
118
+ [cellpose]: https://github.com/MouseLand/cellpose
119
+ [BSD-3]: http://opensource.org/licenses/BSD-3-Clause
@@ -0,0 +1,20 @@
1
+ # Minimal makefile for Sphinx documentation
2
+ #
3
+
4
+ # You can set these variables from the command line, and also
5
+ # from the environment for the first two.
6
+ SPHINXOPTS ?=
7
+ SPHINXBUILD ?= sphinx-build
8
+ SOURCEDIR = .
9
+ BUILDDIR = ../build
10
+
11
+ # Put it first so that "make" without argument is like "make help".
12
+ help:
13
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14
+
15
+ .PHONY: help Makefile
16
+
17
+ # Catch-all target: route all unknown targets to Sphinx using the new
18
+ # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19
+ %: Makefile
20
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)