3
Train Models
Fine-tune a model on what you have annotated. Numbered steps; the parameters in step 3 depend on which model you picked in step 1.
Step 1 - Choose which model to fine-tune
Model type
Pills
Pick one: Train a Cellpose model to identify cells for better segmentation,
or Train a DenseNet model to classify cells for better labelling. Everything
below re-renders to match.
Step 2 - Select images to train on
Image table
Table select
All images ticked by default; untick any to exclude. Cellpose uses the masks on the
ticked images, DenseNet uses their labelled cells.
Step 3 - Cellpose segmenter parameters
Base model
Dropdown
Weights to start from - cyto, cyto2, cyto3,
nuclei - or scratch to train from random initialisation.
Max epochs
Number
1 to 1000 passes over the training set. More can improve results, at the cost of time.
Learning rate
Number
Step size the optimizer takes. Lower trains more slowly but more stably.
Weight decay
Number
Regularisation over the final epochs, discouraging the model from over-fitting to
your training images.
Min cells per image
Number
Images with fewer annotated cells than this are dropped from training - Cellpose's
own default is 5. The step 4 summary reports how many this excludes.
Batch size
Dropdown
8, 16, 32 or 64 images per training step. Larger is faster but needs more memory.
Images per epoch
Dropdown
How many training images to sample each epoch - All, or 8 / 32 / 64 / 128 / 256.
Optimise hyperparameters
Checkbox
After training, searches for the inference settings - diameter, thresholds and so on -
that suit the new model best. Note the winning values down: you will want to re-enter
them on the Annotate Images page when you use the model.
Optimisation iterations
Slider
10 to 60 combinations to try, in steps of 5. Only shown when the box above is ticked.
More trials, better settings, longer wait.
Train / test split
Slider
10% to 90% in steps of 5, labelled with the share of images used for
training. The rest are held out as a test set and never trained on, so the step 5
plots measure performance on images the model has not seen.
Step 3 - DenseNet classifier parameters
Input size
Dropdown
64, 96 or 128 pixels - the size each cell crop is scaled to before the model sees it.
Larger keeps more detail and trains more slowly.
Batch size
Dropdown
As above, but counted in cell crops rather than whole images.
Max epochs
Number
1 to 500 passes over the labelled cells.
Train / validation split
Slider
Works like the Cellpose split, but divides labelled cells. The held-out
share becomes the validation set behind the accuracy and confusion matrix plots.
Step 4 - Train the model
Only one model trains at a time; starting one greys out the other.
Training set summary
Status
Sits just above the button. Cellpose reports total masks, images passing the
minimum-cells filter, and the train/test breakdown. DenseNet reports total labelled
cells, the train/validation breakdown, and a per-class count table.
Fine-tune Cellpose
Button
Starts training in the background.
Fine tune Densenet121
Button
The same, and additionally disabled until at least two classes have two or more
labelled cells each.
View Training Log
Expander
Appears while a job runs - live worker output, so you can follow progress epoch by
epoch. Cellpose shows a matching View Validation Log during its evaluation
pass afterwards.
Cancel Training
Button
Stops the running job; nothing is kept from a cancelled run. Reads
Cancel Validation during the evaluation pass.
Show Error Details
Expander
Appears if a job fails, holding the full error from the worker.
Step 5 - Review model training
Appears once a model has finished.
How do I interpret these graphs?
Popover
Plain-language notes on each plot, one expander apiece - training vs test loss, IoU
comparison and predicted vs real counts for Cellpose; loss, accuracy / precision /
recall / F1, and the confusion matrix for DenseNet.
Tested hyperparameters
Table
Shown when Optimise hyperparameters was ticked: every combination tried and
how it scored, so you can copy the best into the Annotate Images page.
A newly trained model goes straight to work. As soon as training
finishes it becomes the Fine-tuned Model option on the Annotate Images page,
and the Cellpose model / DenseNet model tick on the Downloads page.