Skip to content

Commit 5979c6b

Browse files
adding paper code and updating readme
1 parent fae2679 commit 5979c6b

21 files changed

+1662
-3689
lines changed

.github/workflows/test_and_deploy.yml

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -43,28 +43,28 @@ jobs:
4343
- name: Coverage
4444
uses: codecov/codecov-action@v4
4545

46-
# deploy:
47-
# # this will run when you have tagged a commit, starting with "v*"
48-
# # and requires that you have put your twine API key in your
49-
# # github secrets (see readme for details)
50-
# needs: [test]
51-
# runs-on: ubuntu-latest
52-
# if: contains(github.ref, 'tags')
53-
# steps:
54-
# - uses: actions/checkout@v4
55-
# - name: Set up Python
56-
# uses: actions/setup-python@v4
57-
# with:
58-
# python-version: "3.x"
59-
# - name: Install dependencies
60-
# run: |
61-
# python -m pip install --upgrade pip
62-
# pip install -U setuptools setuptools_scm wheel twine
63-
# - name: Build and publish
64-
# env:
65-
# TWINE_USERNAME: __token__
66-
# TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }}
67-
# run: |
68-
# git tag
69-
# python setup.py sdist bdist_wheel
70-
# twine upload dist/*
46+
deploy:
47+
# this will run when you have tagged a commit, starting with "v*"
48+
# and requires that you have put your twine API key in your
49+
# github secrets (see readme for details)
50+
needs: [test]
51+
runs-on: ubuntu-latest
52+
if: contains(github.ref, 'tags')
53+
steps:
54+
- uses: actions/checkout@v4
55+
- name: Set up Python
56+
uses: actions/setup-python@v4
57+
with:
58+
python-version: "3.x"
59+
- name: Install dependencies
60+
run: |
61+
python -m pip install --upgrade pip
62+
pip install -U setuptools setuptools_scm wheel twine
63+
- name: Build and publish
64+
env:
65+
TWINE_USERNAME: __token__
66+
TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }}
67+
run: |
68+
git tag
69+
python setup.py sdist bdist_wheel
70+
twine upload dist/*

README.md

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,25 @@
1616
[![GitHub stars](https://img.shields.io/github/stars/MouseLand/cellpose?style=social)](https://github.com/MouseLand/cellpose/)
1717
[![GitHub forks](https://img.shields.io/github/forks/MouseLand/cellpose?style=social)](https://github.com/MouseLand/cellpose/)
1818

19-
A generalist algorithm for cell and nucleus segmentation (v1.0) that can be optimized for your own data (v2.0) and (**NEW**) perform image restoration (v3.0).
19+
**Cellpose-SAM: cell and nucleus segmentation with superhuman generalization. It can be optimized for your own data, applied in 3D, works on noisy and blurry images.**
2020

21-
Cellpose was written by Carsen Stringer and Marius Pachitariu. To learn about Cellpose3 (image restoration), read the [paper](https://www.nature.com/articles/s41592-025-02595-5) or watch the [talk](https://youtu.be/TZZZlGk6AKo). To learn about Cellpose 2.0 (human-in-the-loop), read the [paper](https://www.nature.com/articles/s41592-022-01663-4) or watch the [talk](https://www.youtube.com/watch?v=3ydtAhfq6H0). To learn about Cellpose 1.0, read the [paper](https://t.co/kBMXmPp3Yn?amp=1) or watch the [talk](https://t.co/JChCsTD0SK?amp=1). For support, please open an [issue](https://github.com/MouseLand/cellpose/issues).
21+
To learn about Cellpose-SAM read the [paper](https://www.biorxiv.org/content/10.1101/2025.04.28.651001v1) or watch the [talk](https://t.co/JChCsTD0SK?amp=1). For info on fine-tuning a model, watch this [tutorial talk](https://youtu.be/5qANHWoubZU), and see this example [video](https://youtu.be/3Y1VKcxjNy4) of human-in-the-loop training. For support, please open an [issue](https://github.com/MouseLand/cellpose/issues).
2222

23-
Please see install instructions [below](README.md/#Installation), and also check out the detailed documentation at [**cellpose.readthedocs.io**](https://cellpose.readthedocs.io/en/latest/) for more information. Example notebooks:
23+
Please see install instructions [below](README.md/#Installation), and also check out the detailed documentation at <font size="4">[**cellpose.readthedocs.io**](https://cellpose.readthedocs.io/en/latest/)</font>.
2424

25-
* [run_cellpose3.ipynb](https://github.com/MouseLand/cellpose/blob/main/notebooks/run_cellpose3.ipynb) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/MouseLand/cellpose/blob/main/notebooks/run_cellpose3.ipynb): run image restoration and segmentation with Cellpose3
26-
* [run_cyto3.ipynb](https://github.com/MouseLand/cellpose/blob/main/notebooks/run_cellpose3.ipynb) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/MouseLand/cellpose/blob/main/notebooks/run_cyto3.ipynb): segment with the new super-generalist "cyto3" model
27-
* [run_cellpose_2.ipynb](https://github.com/MouseLand/cellpose/blob/main/notebooks/run_cellpose_2.ipynb) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/MouseLand/cellpose/blob/main/notebooks/run_cellpose_2.ipynb): train your own models with Cellpose2
28-
* [run_cellpose_GPU.ipynb](https://github.com/MouseLand/cellpose/blob/main/notebooks/run_cellpose_GPU.ipynb) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/MouseLand/cellpose/blob/main/notebooks/run_cellpose_GPU.ipynb): run Cellpose segmentation in 2D and 3D
29-
* [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/MouseLand/cellpose/blob/main/notebooks/Cellpose_cell_segmentation_2D_prediction_only.ipynb): a user-friendly notebook for 2D segmentation written by [@pr4deepr](https://github.com/pr4deepr)
30-
* [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/HenriquesLab/ZeroCostDL4Mic/blob/master/Colab_notebooks/Beta%20notebooks/Cellpose_2D_ZeroCostDL4Mic.ipynb): a user-friendly [ZeroCostDL4Mic](https://github.com/HenriquesLab/ZeroCostDL4Mic) notebook that includes training cellpose models, written by [@guijacquemet](https://github.com/guijacquemet)
25+
Example notebooks:
3126

32-
:triangular_flag_on_post: All models in Cellpose, except `yeast_BF_cp3`, `yeast_PhC_cp3`, and `deepbacs_cp3`, are trained on some amount of data that is **CC-BY-NC**. The Cellpose annotated dataset is also CC-BY-NC.
27+
* [run_Cellpose-SAM.ipynb](https://github.com/MouseLand/cellpose/blob/main/notebooks/run_Cellpose-SAM.ipynb) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/MouseLand/cellpose/blob/main/notebooks/run_Cellpose-SAM.ipynb): run Cellpose-SAM on your own data, mounted in google drive
28+
* [test_Cellpose-SAM.ipynb](https://github.com/MouseLand/cellpose/blob/main/notebooks/test_Cellpose-SAM.ipynb) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/MouseLand/cellpose/blob/main/notebooks/test_Cellpose-SAM.ipynb): shows running Cellpose-SAM using example data in 2D and 3D
29+
* [train_Cellpose-SAM.ipynb](https://github.com/MouseLand/cellpose/blob/main/notebooks/train_Cellpose-SAM.ipynb) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/MouseLand/cellpose/blob/main/notebooks/train_Cellpose-SAM.ipynb): train Cellpose-SAM on your own labeled data (also optional example data provided)
30+
31+
:triangular_flag_on_post: The Cellpose-SAM model is trained on data that is licensed under **CC-BY-NC**. The Cellpose annotated dataset is also CC-BY-NC.
3332

3433
### CITATION
3534

35+
**If you use Cellpose-SAM, please cite the Cellpose-SAM [paper](https://www.biorxiv.org/content/10.1101/2025.04.28.651001v1):**
36+
Pachitariu, M., Rariden, M., & Stringer, C. (2025). Cellpose-SAM: superhuman generalization for cellular segmentation. <em>bioRxiv</em>.
37+
3638
**If you use Cellpose 1, 2 or 3, please cite the Cellpose 1.0 [paper](https://t.co/kBMXmPp3Yn?amp=1):**
3739
Stringer, C., Wang, T., Michaelos, M., & Pachitariu, M. (2021). Cellpose: a generalist algorithm for cellular segmentation. <em>Nature methods, 18</em>(1), 100-106.
3840

@@ -42,9 +44,9 @@ Pachitariu, M. & Stringer, C. (2022). Cellpose 2.0: how to train your own model.
4244
**If you use the new image restoration models or cyto3, please also cite the Cellpose3 [paper](https://www.nature.com/articles/s41592-025-02595-5):**
4345
Stringer, C. & Pachitariu, M. (2025). Cellpose3: one-click image restoration for improved segmentation. <em>Nature Methods</em>.
4446

45-
### v3.1+ update (Feb 2025)
47+
## Old updates
4648

47-
`pip install cellpose --upgrade` to get all the new features and bug fixes!
49+
### v3.1+ update (Feb 2025)
4850

4951
* support for **big data** contributed by [@GFleishman](https://github.com/GFleishman), usage info [here](https://cellpose.readthedocs.io/en/latest/distributed.html)
5052
* new options to improve 3D segmentation like `flow3D_smooth` and `pretrained_model_ortho`, more info [here](https://cellpose.readthedocs.io/en/latest/do3d.html#segmentation-settings)
@@ -58,12 +60,6 @@ Cellpose3 enables image restoration in the GUI, API and CLI (saved to `_seg.npy`
5860
* Tutorial [talk](https://youtu.be/TZZZlGk6AKo) about the algorithm and how to use it
5961
* API documentation [here](https://cellpose.readthedocs.io/en/latest/restore.html)
6062

61-
<img src="http://www.cellpose.org/static/images/poisson_cp3.gif?raw=True" width="350" title="cellpose denoising" alt="cellpose denoising examples">
62-
63-
<img src="http://www.cellpose.org/static/images/blur_cp3.gif?raw=True" width="350" title="cellpose deblurring" alt="cellpose deblurring examples">
64-
65-
<img src="http://www.cellpose.org/static/images/downsample_cp3.gif?raw=True" width="350" title="cellpose upsampling" alt="cellpose upsampling examples">
66-
6763
### :star2: v2.0 (April 2022) :star2:
6864

6965
Cellpose 2.0 allows human-in-the-loop training of models! To learn more, check out the twitter [thread](https://twitter.com/marius10p/status/1511415409047650307?s=20&t=umTVIG1CFKIWHYMrQqFKyQ), [paper](https://www.nature.com/articles/s41592-022-01663-4), [review](https://www.nature.com/articles/s41592-022-01664-3), [short talk](https://youtu.be/wB7XYh4QRiI), and the [tutorial talk](https://youtu.be/5qANHWoubZU) which goes through running Cellpose 2.0 in the GUI and a jupyter notebook. Check out the full human-in-the-loop [video](https://youtu.be/3Y1VKcxjNy4). See how to use it yourself in the [docs](https://cellpose.readthedocs.io/en/latest/gui.html#training-your-own-cellpose-model) and also check out the help info in the `Models` menu in the GUI.
@@ -82,15 +78,15 @@ Linux, Windows and Mac OS are supported for running the code. For running the gr
8278
cellpose relies on the following excellent packages (which are automatically installed with conda/pip if missing):
8379
- [pytorch](https://pytorch.org/)
8480
- [pyqtgraph](http://pyqtgraph.org/)
85-
- [PyQt5](http://pyqt.sourceforge.net/Docs/PyQt5/)
86-
- [numpy](http://www.numpy.org/) (>=1.16.0)
87-
- [numba](http://numba.pydata.org/numba-doc/latest/user/5minguide.html)
81+
- [PyQt6](https://www.riverbankcomputing.com/software/pyqt/) or PySide
82+
- [numpy](http://www.numpy.org/) (>=1.20.0)
8883
- [scipy](https://www.scipy.org/)
8984
- [natsort](https://natsort.readthedocs.io/en/master/)
9085
- [tifffile](https://github.com/cgohlke/tifffile)
9186
- [imagecodecs](https://github.com/cgohlke/imagecodecs)
9287
- [roifile](https://github.com/cgohlke/roifile)
9388
- [fastremap](https://github.com/seung-lab/fastremap/)
89+
- [fill_voids](https://github.com/seung-lab/fill_voids/)
9490

9591
### Option 1: Installation Instructions with conda
9692

cellpose/vit_sam.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
"""
2+
Copyright © 2025 Howard Hughes Medical Institute, Authored by Carsen Stringer and Marius Pachitariu.
3+
"""
4+
15
import torch
26
from segment_anything import sam_model_registry
37
torch.backends.cuda.matmul.allow_tf32 = True

docs/do3d.rst

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,12 @@ incorrect. If drag-and-drop works (you can see a tiff with multiple planes),
2424
then the GUI will automatically run 3D segmentation and display it in the GUI. Watch
2525
the command line for progress. It is recommended to use a GPU to speed up processing.
2626

27-
In the CLI/notebook, you can specify the ``z_axis`` and optionally the ``channel_axis``
27+
In the CLI/notebook, you need to specify the ``z_axis`` and the ``channel_axis``
2828
parameters to specify the axis (0-based) of the image which corresponds to the image channels and to the z axis.
2929
For example an image with 2 channels of shape (1024,1024,2,105,1) can be
30-
specified with ``channel_axis=2`` and ``z_axis=3``. If ``channel_axis=None``
31-
cellpose will try to automatically determine the channel axis by choosing
32-
the dimension with the minimal size after squeezing. If ``z_axis=None``
33-
cellpose will automatically select the first non-channel axis of the image
34-
to be the Z axis. These parameters can be specified using the command line
30+
specified with ``channel_axis=2`` and ``z_axis=3``. These parameters can be specified using the command line
3531
with ``--channel_axis`` or ``--z_axis`` or as inputs to ``model.eval`` for
36-
the ``Cellpose`` or ``CellposeModel`` model.
32+
the ``CellposeModel`` model.
3733

3834
Volumetric stacks do not always have the same sampling in XY as they do in Z.
3935
Therefore you can set an ``anisotropy`` parameter in CLI/notebook to allow for differences in

docs/index.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,21 @@ cellpose
55

66
cellpose is an anatomical segmentation algorithm written in Python 3
77
by Carsen Stringer and Marius Pachitariu. For support, please open
8-
an `issue`_.
9-
10-
We make pip installable releases of cellpose, here is the `pypi`_. You
8+
an `issue`_. We make pip installable releases of cellpose available on `pypi`_. You
119
can install it as ``pip install cellpose[gui]``.
1210

13-
You can try it out without installing at `https://huggingface.co/spaces/mouseland/cellpose`_.
11+
**Cellpose-SAM is now available!**
1412

15-
Also check out these resources:
13+
You can run Cellpose-SAM in the cloud (no install) at `Hugging Face <https://huggingface.co/spaces/mouseland/cellpose>`_.
1614

1715
Cellpose-SAM: superhuman generalization for cellular segmentation
1816

1917
- `paper <https://www.biorxiv.org/content/10.1101/2025.04.28.651001v1>`_ on biorxiv
2018

2119

20+
Old releases:
21+
-----------------------------
22+
2223
Cellpose3: one-click image restoration for improved cellular segmentation
2324

2425
- `paper <https://www.biorxiv.org/content/10.1101/2024.02.10.579780v1>`_ on biorxiv

docs/installation.rst

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -110,39 +110,4 @@ If you are on Yosemite Mac OS or earlier, PyQt doesn't work and you won't be abl
110110
to use the graphical interface for cellpose. More recent versions of Mac
111111
OS are fine. The software has been heavily tested on Windows 10 and
112112
Ubuntu 18.04, and less well tested on Mac OS. Please post an issue if
113-
you have installation problems.
114-
115-
116-
Dependencies
117-
~~~~~~~~~~~~~~~~~~~~~~
118-
119-
cellpose relies on the following excellent packages (which are
120-
automatically installed with pip if missing):
121-
122-
- `pytorch`_
123-
- `pyqtgraph`_
124-
- `PyQt5`_ or pyside or PyQt6
125-
- `numpy`_ (>=1.16.0)
126-
- `numba`_
127-
- `scipy`_
128-
- `tifffile`_
129-
- `natsort`_
130-
- `fastremap`_
131-
- `roifile`_
132-
- `superqt`_
133-
134-
.. _Anaconda: https://www.anaconda.com/download/
135-
.. _environment.yml: https://github.com/MouseLand/cellpose/blob/master/environment.yml?raw=true
136-
.. _here: https://pypi.org/project/cellpose/
137-
138-
.. _pytorch: https://pytorch.org/
139-
.. _pyqtgraph: http://pyqtgraph.org/
140-
.. _PyQt5: http://pyqt.sourceforge.net/Docs/PyQt5/
141-
.. _numpy: http://www.numpy.org/
142-
.. _numba: http://numba.pydata.org/numba-doc/latest/user/5minguide.html
143-
.. _scipy: https://www.scipy.org/
144-
.. _tifffile: https://pypi.org/project/tifffile/
145-
.. _natsort: https://natsort.readthedocs.io/en/master/
146-
.. _fastremap: https://github.com/seung-lab/fastremap
147-
.. _roifile: https://github.com/cgohlke/roifile
148-
.. _superqt: https://github.com/pyapp-kit/superqt
113+
you have installation problems.

notebooks/Cellpose_cell_segmentation_2D_prediction_only.ipynb

Lines changed: 0 additions & 734 deletions
This file was deleted.

notebooks/run_Cellpose-SAM.ipynb

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
{
44
"cell_type": "markdown",
55
"metadata": {
6-
"id": "view-in-github",
7-
"colab_type": "text"
6+
"colab_type": "text",
7+
"id": "view-in-github"
88
},
99
"source": [
10-
"<a href=\"https://colab.research.google.com/github/MouseLand/cellpose_dev/blob/main/notebooks/run_Cellpose-SAM.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
10+
"<a href=\"https://colab.research.google.com/github/MouseLand/cellpose/blob/main/notebooks/run_Cellpose-SAM.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
1111
]
1212
},
1313
{
@@ -111,7 +111,7 @@
111111
},
112112
"outputs": [],
113113
"source": [
114-
"!pip install git+https://www.github.com/mouseland/cellpose_dev.git"
114+
"!pip install git+https://www.github.com/mouseland/cellpose.git"
115115
]
116116
},
117117
{
@@ -139,13 +139,12 @@
139139
"import matplotlib.pyplot as plt\n",
140140
"from natsort import natsorted\n",
141141
"\n",
142+
"io.logger_setup() # run this to get printing of progress\n",
142143
"\n",
143144
"#Check if colab notebook instance has GPU access\n",
144145
"if core.use_gpu()==False:\n",
145146
" raise ImportError(\"No GPU access, change your runtime\")\n",
146147
"\n",
147-
"io.logger_setup() # run this to get printing of progress\n",
148-
"\n",
149148
"model = models.CellposeModel(gpu=True)"
150149
]
151150
},
@@ -322,8 +321,8 @@
322321
"metadata": {
323322
"accelerator": "GPU",
324323
"colab": {
325-
"provenance": [],
326-
"include_colab_link": true
324+
"include_colab_link": true,
325+
"provenance": []
327326
},
328327
"kernelspec": {
329328
"display_name": "cellpose",
@@ -345,4 +344,4 @@
345344
},
346345
"nbformat": 4,
347346
"nbformat_minor": 0
348-
}
347+
}

notebooks/run_cellpose.ipynb

Lines changed: 0 additions & 179 deletions
This file was deleted.

0 commit comments

Comments
 (0)