Skip to content

Commit e3879a1

Browse files
authored
Merge pull request #1341 from MouseLand/faq_update
Faq update
2 parents 04279e5 + 3bc430d commit e3879a1

File tree

2 files changed

+56
-17
lines changed

2 files changed

+56
-17
lines changed

docs/faq.rst

Lines changed: 54 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
FAQ
22
~~~~~~~~~~~~~~~~~~~~~~~~
33

4+
----------------------
5+
Cellpose settings and usage
6+
----------------------
7+
48
**Q: What should I set the** ``--flow_threshold``/``--cellprob_threshold``/``--diameter`` **parameter to?**
59

610
These parameters should be set experimentally by running Cellpose, viewing the results, and tuning the parameters
@@ -18,20 +22,6 @@ FAQ
1822
Some additional information on precision and accuracy can be found `here <https://forum.image.sc/t/how-to-interpret-cellposes-average-precision-model-evaluation-value/75231/3>`_.
1923

2024

21-
**Q: How do I download the pretrained models?**
22-
23-
The new Cellpose-SAM model (cpsam) will be downloaded from `https://huggingface.co/mouseland/cellpose-sam/blob/main/cpsam`_.
24-
25-
The old models will be downloaded automatically from the `website <https://www.cellpose.org/>`_ when you first run a
26-
pretrained model in cellpose. If you are having issues with the downloads, you can download them from this
27-
`google drive zip file <https://drive.google.com/file/d/1zHGFYCqRCTwTPwgEUMNZu0EhQy2zaovg/view?usp=sharing>`_,
28-
unzip the file and put the models in your home directory under the path ``.cellpose/models/``,
29-
e.g. on Windows this would be ``C:/Users/YOUR_USERNAME/.cellpose/models/`` or on Linux this would be
30-
``/home/YOUR_USERNAME/.cellpose/models/``, so ``/home/YOUR_USERNAME/.cellpose/models/cyto_0`` is the full
31-
path to one model for example. If you cannot access google drive, the models are also available on
32-
baidu: https://pan.baidu.com/s/1CARpRGCBHIYaz7KeyoX-fg thanks to @qixinbo!
33-
34-
3525
**Q: How can I use cellpose to recognize different types of cells in the same image?**
3626

3727
Cellpose does not natively support recognizing different types of cells (aka 'multiclass segmentation').
@@ -68,6 +58,24 @@ FAQ
6858
`here <https://pytorch.org/docs/stable/threading_environment_variables.html>`_.
6959

7060

61+
----------------------
62+
Models and training
63+
----------------------
64+
65+
**Q: How do I download the pretrained models?**
66+
67+
The new Cellpose-SAM model (cpsam) will be downloaded from `huggingface <https://huggingface.co/mouseland/cellpose-sam/blob/main/cpsam>`_.
68+
69+
The old models will be downloaded automatically from the `website <https://www.cellpose.org/>`_ when you first run a
70+
pretrained model in cellpose. If you are having issues with the downloads, you can download them from this
71+
`google drive zip file <https://drive.google.com/file/d/1zHGFYCqRCTwTPwgEUMNZu0EhQy2zaovg/view?usp=sharing>`_,
72+
unzip the file and put the models in your home directory under the path ``.cellpose/models/``,
73+
e.g. on Windows this would be ``C:/Users/YOUR_USERNAME/.cellpose/models/`` or on Linux this would be
74+
``/home/YOUR_USERNAME/.cellpose/models/``, so ``/home/YOUR_USERNAME/.cellpose/models/cyto_0`` is the full
75+
path to one model for example. If you cannot access google drive, the models are also available on
76+
baidu: https://pan.baidu.com/s/1CARpRGCBHIYaz7KeyoX-fg thanks to @qixinbo!
77+
78+
7179
**Q: How does HITL work?**
7280

7381
In cellpose HITL training always starts from a pretrained model but incorporates more training
@@ -111,4 +119,35 @@ colab/a cluster)**
111119

112120
5. Evaluate the trained model on the next image.
113121

114-
6. Repeat 3-5 until you have a working fine-tuned model.
122+
6. Repeat 3-5 until you have a working fine-tuned model.
123+
124+
125+
**Q: Why should I always start from the built-in cellpose model for fine-tuning rather than my fine-tuned model?**
126+
127+
Cellpose uses transfer learning,
128+
where a pre-trained network is used as a starting point that is 'good enough'. Cellpose was trained on a large
129+
and diverse training set of images so that it is a generalist segmentation model: it will segment many types
130+
of images. However, it is not perfect. This means that the
131+
network parameters are somewhat close to predicting good outputs for a new dataset.
132+
133+
After HITL training, you have a new trained network, with parameterst that are closer to your ideal network for that
134+
particular image dataset. To improve the model, you should then take this better performing network and train it again, no?
135+
136+
This is actually a bad idea. The result would be that the network would learn on your data, but it would start to
137+
memorize your data instead of generalizing. This is because each time you train a model, you are moving away from the
138+
generalist, pre-trained parameters, and toward a smaller target distribution of images. Done enough times, the network
139+
may lose the ability to generalize to new images.
140+
141+
Instead, the cellpose GUI forces you to always start with a pretrained model that is known to perform well to make
142+
the iteration cycle more robust. New data is added each cycle, but the model will always start with the generalist
143+
pre-trained model to produce a new fine-tuned model. As you continue the training cycle, the model will converge
144+
on the best model parameters to segment your images. You *should* use the new models to predict the segmentation,
145+
that is the point of the HITL design. Eventually, you will have a model that doesn't need additional training
146+
to accurately predict your segmentation.
147+
148+
149+
**Q: Why not train from scratch?**
150+
151+
You also have the option to train from scratch, but that will take much
152+
longer and requires much more data. The CP4 network leverages extensive pretraining (300k natural images,
153+
23k cellular images). You will need something similar to this to get generalist results.

docs/notebook.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ See :ref:`Settings` for more information on run settings.
2323

2424
masks, flows, styles = model.eval(imgs)
2525

26-
See example notebook at `run_cellpose.ipynb`_.
26+
See example notebook at `run_Cellpose-SAM.ipynb`_.
2727

28-
.. _run_cellpose.ipynb: https://nbviewer.jupyter.org/github/MouseLand/cellpose/blob/master/notebooks/run_cellpose.ipynb
28+
.. _run_cellpose.ipynb: https://github.com/MouseLand/cellpose/blob/main/notebooks/run_Cellpose-SAM.ipynb

0 commit comments

Comments
 (0)