platypus weights
Trained weights for pyplatypus and the rplatypus R
package - segmentation and object detection. Every weights file has a .json beside it
recording what it was trained for and on.
Weights are loaded by name, and a name is pinned to a commit of this repository, so it always means the same numbers:
from pyplatypus import Engine, from_dict
engine = Engine(from_dict({
"data": {"train_path": "images/", "validation_path": "images/",
"colormap": [[0, 0, 0], [255, 255, 255]]},
"models": [{"name": "nuclei", "input_shape": [256, 256], "channels": 3, "n_class": 2,
"blocks": 4, "filters": 16, "weights": "dsbowl-unet", "fit": False}],
}))
engine.fit() # loads the weights, trains nothing
masks = engine.predict("nuclei", split="validation")
library(rplatypus)
spec <- platypus_spec(
data = segmentation_data("images/", "images/", colormap = binary_colormap),
models = list(u_net("nuclei", input_shape = c(256, 256), blocks = 4, filters = 16,
weights = "dsbowl-unet", fit = FALSE))
)
masks <- predict(platypus_fit(spec), split = "validation")
Fetching by name needs pip install "pyplatypus[hub]". A local path to a downloaded file works
without it, which is the route for machines with no internet access.
The licences differ per file, which is why the repository declares other.
dsbowl-unet, dsbowl-instances and bccd-yolo3 are MIT. fives-unet and hc18-unet are
CC BY 4.0, because FIVES and HC18 are, and weights trained on them are plausibly a
derivative work - attribution travels with those. Each file's .json carries its own
weights_licence, and each section below says so.
dsbowl-unet
A plain U-Net that separates cell nuclei from background in light microscopy images.
| Architecture | U-Net, 4 blocks, 16 base filters |
| Input | 256 × 256, 3 channels |
| Output | 2 classes: background, nucleus |
| Parameters | 1,942,594 |
| File | 7.8 MB, safetensors |
| Loss | CCE-Dice |
What it was trained on
BBBC038v1, the 2018 Data Science Bowl image set, stage1_train, from the
Broad Bioimage Benchmark Collection. 670 images of
nuclei in varied cell types, magnifications and imaging modalities, split 536 / 134 by image with
seed 1.
The data is CC0: "the various contributors of the imagesets have waived all copyright and related or neighboring rights to BBBC038v1". Taken from the Broad rather than from the Kaggle mirror on purpose — the images are the same, but the Kaggle copy is governed by competition rules accepted at download, and weights are a derivative of the data behind them.
Citation, which CC0 does not require and which is owed anyway:
Caicedo et al., Nucleus segmentation across imaging experiments: the 2018 Data Science Bowl, Nature Methods, 2019. Image set BBBC038v1, Broad Bioimage Benchmark Collection.
How it scores
On the 134 held-out images, per image rather than pooled:
| metric | mean | sd | median | min | max |
|---|---|---|---|---|---|
| Dice | 0.9205 | 0.0532 | 0.9314 | 0.7240 | 0.9861 |
| IoU | 0.8570 | 0.0865 | 0.8716 | 0.5675 | 0.9725 |
The minimum is there deliberately. A mean of 0.92 with a worst case of 0.72 is a different model
from a mean of 0.92 with a worst case of 0.90, and only one of those numbers tells you which you
have. The five worst images are listed in dsbowl-unet.json.
Why a U-Net, and not one of the others
pyplatypus builds four architectures from one specification, so the question was settled by
running all four on this data - same split, same augmentation, same 60 epochs, one command:
| model | parameters | s/epoch | epochs | Dice mean | sd | median | min |
|---|---|---|---|---|---|---|---|
| U-Net | 1,942,594 | 15.5 | 60 | 0.9217 | 0.054 | 0.9353 | 0.7227 |
| U-Net++ | 2,263,730 | 18.8 | 44 | 0.9212 | 0.055 | 0.9323 | 0.7459 |
| LinkNet | 1,746,754 | 14.0 | 60 | 0.9203 | 0.053 | 0.9293 | 0.7205 |
| Res-U-Net | 2,029,682 | 14.2 | 55 | 0.9187 | 0.058 | 0.9293 | 0.6706 |
The spread across all four is 0.0030. The spread across images within any one of them is 0.054. The architectures are eighteen times closer to each other than the images are, which means they are not distinguishable on this data.
One number makes it plainer. These published weights score 0.9205; the U-Net in the table, same configuration and a different random seed, scored 0.9217. That 0.0012 of seed noise is 40% of the entire spread between the four architectures — switching from LinkNet to U-Net++ buys about what re-running the same model buys.
So only one set of weights is published, and the choice of U-Net is arbitrary but measured. If you are deciding where to spend effort on a problem like this one, the table says it is not on the architecture: more data, better augmentation or a longer run will all move the number further than swapping the decoder.
Reproduce it with python examples/compare_dsbowl_architectures.py.
What it does not do
It does not separate touching nuclei. This is semantic segmentation: every nucleus pixel gets the same class, so two nuclei in contact come back as one region. The 2018 Data Science Bowl was scored on instances, and the numbers above are not comparable to that leaderboard — they answer "which pixels are nuclei", not "how many nuclei are there". If you need counts, or per-nucleus measurements, you need an instance step on top (watershed on a distance transform is the usual starting point) and these weights are a reasonable input to it, not a replacement for it.
It has seen one collection. BBBC038v1 is varied by design, which is the point of the challenge, but generalisation was measured on a held-out split of the same collection and nothing else. On a microscope or a stain unlike anything in it, measure before trusting.
It is an alpha. pyplatypus is pre-1.0 and its API still moves. The weights will keep
working - a pinned commit does not change - but the code that loads them may.
Reproducing it
pip install "pyplatypus[hub]"
python examples/publish_dsbowl_weights.py --out weights/
The script downloads BBBC038v1 from the Broad, splits it with the same seed, trains, measures per image, and writes the weights with this provenance in their sidecar. Trained on a GTX 1070: 60 epochs, about 15 seconds each.
dsbowl-instances
A U-Net trained to tell touching nuclei apart, on the same images as dsbowl-unet.
| Architecture | U-Net, 4 blocks, 16 base filters |
| Input | 256 × 256, 3 channels |
| Output | 3 channels: background, interior, rim - separation: rim, width 2 |
| Parameters | 1,942,611 |
| File | 7.8 MB, safetensors |
| Loss | CCE-Dice |
| Licence | MIT |
What it was trained on
BBBC038v1, the 2018 Data Science Bowl's
stage1_train: 670 light-microscopy fields with one mask per nucleus, 536 for training
and the same 134 held-out cases dsbowl-unet reports, taken by case name. 5,999
ground-truth objects in that half, which is the number that says it is the same 134 -
any other 134 directories would give a different count. CC0. Seed 0, 120 epochs, 102
minutes on one GTX 1070.
The per-object masks are what make this model possible and they say nothing about what kind of object it is: every nucleus is one class.
How it scores
Instance average precision on the 134 held-out images - objects matched to objects, averaged over ten IoU thresholds from 0.50 to 0.95 - one score per image:
| decoding | AP | sd | median | worst | objects found |
|---|---|---|---|---|---|
nearest_seed | 0.5445 | 0.2554 | 0.5275 | 0.0154 (538b7673) | 5,378 of 5,999 |
watershed | 0.5390 | 0.2532 | 0.5267 | 0.0136 (538b7673) | 5,378 of 5,999 |
connected_components | 0.4822 | 0.2440 | 0.4533 | 0.0066 (538b7673) | 4,914 of 5,999 |
| Foreground Dice | 0.9118 - the mask all three rows share |
| Class Dice | 0.8542 - the training metric, a mean over the three channels |
Name the decoding, or the number means nothing
These are one file of weights and three scores. The network predicts channels; turning
them into objects is a separate step, the specification takes a list of decodings, and
evaluate() returns a row per decoding on one forward pass - a second decoding of these
134 images costs 1.41 s against 102 minutes of training. The spread between the best and
the worst row above is 0.0623, about seven times this configuration's run-to-run noise, so
a score quoted from this card without its decoding is not a property of the weights.
connected_components is in that table as the yardstick rather than as a recommendation:
it labels connected foreground and ignores the signal these weights were trained to carry,
so touching nuclei come back as one object. The signal is therefore worth +0.0623 here.
Substituting a perfect semantic mask into the same route is worth +0.2398, and a
perfect mask through connected_components scores 0.7655 - the ceiling every row above
sits under. The mask is the limit on this data by nearly four to one, and
these weights do not change that.
A bigger model was measured and it is not the answer
The published run, and then three more with one field changed in each, 120 epochs every time:
| foreground Dice | AP (nearest_seed) | |
|---|---|---|
| as published | 0.9118 | 0.5445 |
| seed 1, nothing else changed | 0.9133 | 0.5527 |
filters: 32 instead of 16 | 0.9096 | 0.5435 |
| ResNet-34 encoder, pretrained, 5 frozen epochs | 0.8770 | 0.4389 |
Doubling the filters moved the score by less than a tenth of the run-to-run spread. A pretrained ResNet-34 encoder lost 0.1053 - twelve times that spread - and lost the mask with it. Where the mask moved far enough to read at all, the score followed it at about 2.7 points of average precision per point of foreground Dice, against the 2.85 implied by substituting a perfect mask. Two ways of asking and one answer: effort spent on the mask pays here and effort spent on capacity does not.
What it does not do
- One kind of object. Nuclei against background.
- Trained at 256 × 256 on light microscopy. The dataset spans stains, magnifications and fluorescence, and a slide unlike anything in it is outside what was measured.
- 621 objects of 5,999 are not found by the best row above, and 1,085 by the worst. An average precision is not a count, and counting nuclei with these weights means accepting that.
- The number is one machine's. A seed reproduces a direction and not digits: the same configuration with the seed changed scored 0.0082 away, and the run-to-run spread recorded for this family is 0.009 - which is the spread every claim above is measured against, and a third of the band the publishing script refuses outside.
dsbowl-unet is the sibling to compare it with
The same dataset and the same 134 images, with one foreground class: it finds the nuclei and cannot tell two touching ones apart. These weights can, at the cost of a thinner interior - the rim band is carved out of the object. Choose by whether the answer you want is an area or a count.
Reproducing it
# BBBC038v1 is fetched by the script from the Broad's own address
python examples/publish_dsbowl_instance_weights.py --out weights/
The script re-draws nothing: it takes the split by case name, refuses to write anything unless all three decodings land within ±0.027 of the numbers above - two-sided, because a run far above that band is a different recipe than this section describes - and writes the sidecar, the per-case scores and this section's numbers. It uploads nothing.
bccd-yolo3
A YOLOv3 that finds red blood cells, white blood cells and platelets in blood-smear photographs.
| Architecture | YOLOv3, Darknet-53 backbone, 3 anchors per grid |
| Input | 416 × 416, 3 channels, letterboxed |
| Output | 3 classes: RBC, WBC, Platelets |
| Parameters | 61,534,504 |
| File | 246 MB, safetensors |
| Anchors | fitted to this data, recorded in the sidecar |
The anchors are not optional. A detector's weights decode boxes relative to the anchors
they were trained with, so the same numbers read with other anchors produce boxes scaled by a
fixed factor - plausible boxes, plausible scores, wrong places, and nothing in the output to
say so. pyplatypus takes them from the sidecar when it loads, and refuses a specification
that names its own.
What it was trained on
BCCD: 364 blood-smear photographs with 4,888 boxes, in the dataset's own train/validation/test split of 205 / 87 / 72. MIT licence, copyright 2017 shenggan, with the original images and annotations from cosmicad and akshaylamba, re-organised into Pascal VOC format.
Taken from that repository rather than the Kaggle mirror. The images are the same, but the
Kaggle copy is governed by competition rules accepted at download, and weights are a
derivative of the data behind them — the same reasoning as dsbowl-unet above.
The split is the dataset's own, which is the only reason these numbers can be compared with anybody else's on BCCD.
How it scores
On the 72 held-out test images, at IoU 0.5 and averaged over 0.50–0.95, with precision and recall read at confidence 0.5:
| class | AP@0.5 | IoU of matches | truth | precision | recall |
|---|---|---|---|---|---|
| RBC | 0.7934 | 0.810 | 805 | 0.715 | 0.793 |
| WBC | 0.9587 | 0.849 | 71 | 0.922 | 1.000 |
| Platelets | 0.8191 | 0.715 | 69 | 0.543 | 0.913 |
| all | 0.8571 | 0.8058 | 945 |
mAP@[.50:.95] is 0.5003. The gap between that and 0.8571 is localisation: the objects are
found and the boxes fit them loosely, which mean_matched_iou says in one number instead of
through the difference between two.
These are the median seed, and that matters here
Five runs of this exact recipe, differing only in the seed:
| mean | sd | min | max | |
|---|---|---|---|---|
| mAP@0.5 | 0.8660 | 0.0159 | 0.8533 | 0.8868 |
| mAP@[.50:.95] | 0.5159 | 0.0199 | 0.5003 | 0.5436 |
| IoU of matches | 0.8041 | 0.0026 | 0.8002 | 0.8068 |
Published here is the median by mAP@0.5, not the best. The spread is wide enough that a single reported number would be whichever seed got chosen: the best run scores 0.8868, three points above this one, on the same code and the same data.
And one row of that table is six times steadier than another. How well the boxes fit barely
varies between seeds; how many are found does. Which rank the model gives a borderline cell
moves average precision and leaves the overlap alone. On a dataset this size, read
mean_matched_iou first.
What it does not do
Platelets are the unreliable class, and that is where almost all of the variance lives. Across the five seeds:
| class | AP spread | IoU spread |
|---|---|---|
| RBC | ± 0.0100 | ± 0.0048 |
| WBC | ± 0.0052 | ± 0.0049 |
| Platelets | ± 0.0409 | ± 0.0208 |
Platelets are small — a median side of 41 pixels against 103 for a red cell — and their boxes fit worst (IoU 0.715) and vary four to eight times more than the other two classes. Precision on them at confidence 0.5 is 0.543, meaning roughly half the platelets it reports are not there. If platelets are what you are counting, these weights are a starting point and not an answer.
It has seen one small collection. 205 training images of blood smears at one magnification, stained one way. BCCD is a demonstration dataset, not a clinical one, and generalisation was measured on its own held-out split and nowhere else.
It is not a diagnostic tool. Nothing about this was validated for clinical use, and a cell count from it is not a laboratory result.
About 0.1% of the training boxes could not be represented at all — 3 of 2,804. Two cells
of similar shape whose centres land in the same grid cell share a target slot, so the second
is dropped: never shown to the model, never counted as missed. At 416 on this data it is
negligible, and pyplatypus reports the figure before training rather than after.
It is an alpha. The weights will keep working — a pinned commit does not change — but the
code that loads them still moves, and detection is not in a released pyplatypus yet.
Reproducing it
# BCCD from https://github.com/Shenggan/BCCD_Dataset
python examples/detect_blood_cells.py --data path/to/BCCD --epochs 150 --seed 1 \
--save weights/bccd-yolo3.safetensors
150 epochs, about 37 minutes on a GTX 1070. The script writes the YAML of the run beside its
results, so the recipe in bccd-yolo3.json can be read back and run again.
fives-unet
A U-Net that segments the retinal vessel tree in colour fundus photographs.
| Architecture | U-Net, 4 blocks, 16 base filters |
| Input | 512 × 512, 3 channels, tiled over the 2048 × 2048 source |
| Output | 2 classes: background, vessel |
| Parameters | 1,942,594 |
| File | 7.8 MB, safetensors |
| Loss | CCE-Dice |
| Licence | CC BY 4.0, not MIT - see below |
What it was trained on
FIVES, the dataset's own split: 600 training and 200 test images, 50 of each of normal, AMD, diabetic retinopathy and glaucoma in the test set. Seed 1.
Images are 2048 × 2048 and the model sees 512 × 512 tiles. Scores below are measured on masks reassembled from the tiles, not on the tiles, because a vessel tree cut into quarters is not the structure the metric is asking about.
How it scores
On the 200 held-out images, one score per image:
| mean | sd | median | worst | |
|---|---|---|---|---|
| Dice | 0.8789 | 0.1051 | 0.9092 | 0.1055 (122_G) |
| IoU | 0.7956 | 0.1280 | 0.8335 | 0.0557 (122_G) |
| clDice | 0.8779 | 0.1099 | 0.9082 | 0.1343 (123_G) |
The clDice row was re-measured on 2026-11-06 under 0.8.0a73, after 0.8.0a72 changed
the soft skeleton's erosion to the cross the reference implementation uses. The Dice and
IoU rows are unchanged and reproduce to seven decimals from the same weights, which is
what says this is one metric's definition moving rather than a different scoring pass.
And it is measured at 12 skeleton peels, which is not the engine's default of 5. At
the default this same file scores 0.7971, which is 0.0809 lower - so the figure above
cannot be reproduced from the weights alone, and the sidecar states the parameter in
cldice_iterations beside the engine in cldice_measured_with. 12 is the example's own
setting, argued there against vessels a few pixels across; it is not a better number, it
is a different question, and a clDice quoted off this card without the peel count means
nothing.
clDice is there because Dice on a vessel tree rewards filling in thick vessels and barely notices a broken thin one. It measures the overlap of the skeletons instead.
Read the per-disease table with the quality grading beside it
| all images | sd | n graded clean | graded clean | sd | |
|---|---|---|---|---|---|
| AMD | 0.9107 | 0.0518 | 42 | 0.9229 | 0.0413 |
| diabetic retinopathy | 0.8818 | 0.0671 | 36 | 0.9056 | 0.0396 |
| glaucoma | 0.8347 | 0.1774 | 22 | 0.9315 | 0.0219 |
| normal | 0.8884 | 0.0556 | 33 | 0.9006 | 0.0341 |
The left-hand column is not a finding about disease. FIVES ships a quality grading - every image rated for illumination and contrast, blur, and low contrast - that nothing in the training pipeline uses, and 14 of the 15 test images flagged for low contrast are glaucoma. Joined to the scores it inverts the reading:
| n | Dice | sd | |
|---|---|---|---|
| graded clean on all three axes | 133 | 0.9141 | 0.0380 |
| flagged on at least one | 67 | 0.8089 | 0.1515 |
That gap - 0.1052 of Dice - is larger than the 0.0761 between the best and worst disease
over all images, and larger again than the 0.0309 between them once the flagged images are
set aside. glaucoma is the weakest group over all images and normal over the clean
ones, so a per-disease number taken off this card is a statement about picture quality as
much as about pathology. A clinical conclusion drawn from the left-hand column would be
wrong.
The five worst images are 122_G 0.11, 123_G 0.14, 136_G 0.52, 119_G 0.58, 153_N
0.65 - four of the five glaucoma, and the two below 0.15 are both flagged for low
contrast.
What it does not do
It is not a diagnostic tool. Nothing here was validated for clinical use. A vessel mask from it is not a measurement of anybody's retina.
Vessels, not lesions. One foreground class, the vessel tree. It says nothing about haemorrhages, exudates, the optic disc or the fovea.
It was trained on tiles. Predicting a resized 512 × 512 whole image instead of tiling gives vessels about a quarter the width the model was trained on, and the score falls.
The digits are one machine's. A seed gives identical results to twelve decimal places
on a processor and differs in the fourth on a card, so these numbers reproduce in
direction and not in digits. trained_with in the sidecar records the engine version.
It is an alpha, like the other two: the weights keep working, because a pinned commit does not change, but the code that loads them still moves.
The licence is CC BY 4.0, which the other two are not
FIVES is published under CC BY 4.0. These weights are plausibly a derivative work of it,
so attribution travels with them and the sidecar carries the citation, the source and
weights_licence. dsbowl-unet was trained on CC0 data and bccd-yolo3 on MIT, so
neither constrained anything.
Jin et al., FIVES: A Fundus Image Dataset for Artificial Intelligence based Vessel Segmentation, Scientific Data 9, 475 (2022). figshare 19688169.
Reproducing it
# FIVES from the figshare link above, unpacked so that the four disease folders are under it
python examples/publish_fives_weights.py --data path/to/FIVES --out weights/
40 epochs asked for, stopped by early_stopping at epoch 24 with the best epoch
restored, 3.7 hours on a GTX 1070. The script writes the sidecar and this section's
numbers; it uploads nothing.
hc18-unet
A U-Net that segments the fetal skull in 2D ultrasound, trained on HC18, for
measuring head circumference in millimetres. 597 training images,
199 validation and 199 test, divided by
examination rather than by row: the dataset contains several images of the same
echoscopic examination, and a row-wise split puts near-duplicates on both sides of
it.
The headline here is not an overlap score, and that is deliberate.
| what | value |
|---|---|
| median absolute error against the sonographer's measurement | 2.44 mm |
| mean absolute error against it | 3.84 mm |
| 75th and 90th percentile | 4.63 mm, 7.23 mm |
| bias against it | +1.46 mm |
| worst case | 48.07 mm |
| mean absolute error against the truth mask's own circumference | 3.41 mm |
| bias against it | +0.33 mm |
| mean Dice (foreground) | 0.9494 |
| worst Dice | 0.6135 |
The median and the mean are both here because they disagree. The error distribution has a long tail - half the cases are inside 2.44 mm and a tenth are outside 7.23 mm - so the mean describes the tail rather than a typical case, and the median alone would hide that some cases are out by the width of a head. Read the worst case as the reason this model is not a measuring instrument without a human looking at it.
Two references, and both belong here. The first pair is against what the
sonographer recorded, which is what somebody acting on the number sees; it carries
+0.69 mm that belongs to the dataset rather than to this
model. HC18's annotation is a drawn curve 2.52 px wide and
the training masks are that curve filled, so every mask is half a line width
outside the ellipse the sonographer drew: pi * w * pixel predicts
+0.69 mm against the +0.69 measured
by putting the truth masks through this same pipeline, a correlation of
0.9994 over 200 cases with
0.008 mm left unexplained. The second pair is against the
circumference of the truth mask - the same arithmetic on both sides - and is
therefore this model's own contribution.
Do not choose these weights on the Dice
The two columns rank the same cases differently: Spearman
0.15 between the ordering by Dice and the ordering by absolute
millimetre error. Of the 144 test cases scoring 0.95 or better - a figure anybody would publish - 85 are still wrong by more than 2 mm (59%), the worst of them 575_HC at Dice 0.9531 and +9.13 mm. The best decile by Dice averages 0.9864 and
still has a mean absolute error of 2.15 mm, worst
3.59 mm.
And the magnitude of that disagreement is one draw. The same recipe was run 3 times and the Spearman moved from 0.62 to 0.15. The direction holds in all 3 - every one of them is far from 1, and every run that counted the share found tens of publishable cases wrong by more than 2 mm - so read this section as the two orderings disagree rather than as any one number.
| run | mean Dice | Spearman | of the publishable, over 2 mm |
|---|---|---|---|
the run measure_fetal_head_circumference.py measures | 0.9347 | 0.62 | not counted |
| a second run, nothing changed, refused by the floor | 0.9418 | 0.43 | 43% |
| the run published here | 0.9494 | 0.15 | 59% |
Which way it moves is worth the sentence: the better the Dice, the less it orders anything, which is what a rank statistic does when the thing it ranks has a narrower spread. 3 runs is a direction and not a law, and the published row is the one this card's figures come from.
Why: a ragged boundary barely moves an integral over the region, and a mask that is systematically fat or thin moves it linearly. Those are the two errors Dice is respectively most and least able to see, and they are the wrong way round for anybody measuring a length.
Measuring with them
Predict on the source grid and measure there. The pixel size is a property of the file, so a prediction resized to this model's input shape has pixels of a size nobody recorded, and multiplying by the file's number would be wrong by the ratio of the two shapes.
from pyplatypus import ellipse_circumference
for case, prediction in engine.predict_stream("skull", split="test", space="source"):
mask = prediction.argmax(axis=-1) == 1
mm = ellipse_circumference(mask, spacing=(pixel_mm, pixel_mm))
From R, the same thing is ellipse_measure(mask, spacing = c(px, px)).
Data and licence
HC18, CC BY 4.0 (https://zenodo.org/records/1327317). These weights are released under CC BY 4.0 rather than MIT because the data is, and attribution travels with them.
van den Heuvel, de Bruijn, de Korte and van Ginneken, Automated measurement of fetal head circumference using 2D ultrasound images, PLoS ONE 13(8), e0200412 (2018). Zenodo 10.5281/zenodo.1327317.
Trained with pyplatypus 0.8.0a39, 40 epochs, 32 minutes on one GTX 1070.