Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

pyplatypus

Computer vision for medical imaging — the engine behind the platypus R package.

0.3.0a2 — an alpha. This replaces the 2022 TensorFlow package with a PyTorch one. The API will still move and the R surface does not exist yet, so pin the exact version if you build on it.

Everything on PyPI so far is a pre-release, so pip install pyplatypus resolves to this one. pip install pyplatypus==0.1.0rc2 gets the old TensorFlow package.

What works today

Semantic segmentation in 2D, end to end:

  • One spec, two ways in. Build it from arguments or load it from YAML — both produce the same object, so nothing downstream can tell which you used.
  • Four architectures: U-Net, U-Net++, Res-U-Net, LinkNet, each composable with separable convolutions, spatial dropout, learned or interpolated upsampling, deep supervision and configurable block width.
  • Nine losses (IoU, Dice, CCE, CCE-Dice, Focal, Tversky, Focal-Tversky, Combo, Lovász) and three metrics, all reducing over every axis except batch and channel — so they already work on volumes.
  • Tiling that goes both ways: cut a large image into a grid instead of shrinking it, and get a full-size mask back.
  • DICOM, read properly: stored values converted to real units through the modality LUT, a fixed window rather than one taken from the image, and MONOCHROME1 inverted. Opening the file is the easy part; those three are what make two scans comparable.
  • Splitting by patient, not by slice: split_dataset() turns one directory into train/validation/test CSVs, keeping every group whole. Slices of one patient on both sides of a split is the most common way to publish a Dice that means nothing, and a group_by that matches nothing is an error rather than a silent fallback.
  • Scores per case, not one number: evaluate_cases() reports each image or patient separately and summarise_cases() gives the distribution and names the worst one. On the Data Science Bowl a model at 0.855 over the split turned out to score 0.006 on three images; the mean had no way of saying so.
  • Volumes, not only slices: NIfTI in, 3D U-Net out, patches through the same tiling that cuts 2D images. Every volume is reoriented to canonical (RAS) first - a NIfTI's affine, not its array order, says where the anatomy is, and two datasets read naively can be mirror images of each other. Masks may be label maps (labels: [0, 1]) as well as pictures, because that is how every volume format stores them.
  • Many models from one file, with a comparison table at the end.

Several volumes per sample - one per modality, as BraTS ships - is refused rather than half-read. Object detection, ensembling and pretrained backbones remain out of scope. So does augmentation in 3D: albumentations ships 3D transforms through a different call signature, and a 3D spec asking for augmentation is refused rather than silently ignored.

Also not done yet, deliberately: resampling to isotropic spacing. Spacing is read and carried (volume_spacing()), because losing it would make resampling impossible later, but applying it changes the voxel grid the model sees and that is a decision to make explicitly rather than inside a reader.

Try it

uv venv --python 3.11 .venv
uv pip install --python .venv/bin/python -e ".[dev]"
.venv/bin/python -m pytest

# The linter is pinned in pyproject.toml and installed on its own, so it agrees with CI
# and does not drag torch along to read text files.
uv run --only-group lint ruff check pyplatypus tests
from pyplatypus import Engine, from_yaml

engine = Engine(from_yaml("examples/data_science_bowl.yaml"))
engine.fit(verbose=True)

for row in engine.evaluate():
    print(row)

masks = engine.predict(engine.best_model("dice"), split="test")

examples/data_science_bowl.yaml trains a U-Net and a LinkNet on the 2018 Data Science Bowl and prints a comparison. On a GTX 1070 that is about 11 seconds per epoch at 160×160.

Requirements

Python ≥ 3.10, and torch ≥ 2.7.

If your GPU is a GTX 10-series (Pascal) or older, install the pascal extra:

pip install "pyplatypus[pascal]"

torch 2.8 and later ship CUDA 13 builds, and CUDA 13 dropped the Maxwell, Pascal and Volta generations outright - no driver update brings them back. The last torch built against CUDA 12 is 2.7.x, which the extra pins. On anything from Turing (RTX 20-series) onwards, ignore this.

Licence

MIT.

Metadata

Release files for pyplatypus 0.3.0a2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyplatypus 0.3.0a2
File Size Uploaded Provenance
pyplatypus-0.3.0a2.tar.gz 103.0 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pyplatypus 0.3.0a2
File Interpreter ABI Platform
pyplatypus-0.3.0a2-py3-none-any.whl Python 3 none any Details

Total release size: 174.4 kB

Release files / pyplatypus-0.3.0a2.tar.gz

Download URL pyplatypus-0.3.0a2.tar.gz
Size 103.0 kB
Tags Source
SHA-256 checksum
How to use checksums
476f54cc077ed771dc495b65a8986e163dbb0601405aaffeeea456dafb8e6eb9
BLAKE2b-256 checksum
How to use checksums
a0801b31a73f093327071028079e486516e3762bdf87ca245a66ccdb9f10b39e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release files / pyplatypus-0.3.0a2-py3-none-any.whl

Download URL pyplatypus-0.3.0a2-py3-none-any.whl
Size 71.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba93f327d03effb7279d66e3129a72121ea7db308cf1f07b563405a3c0571ec2
BLAKE2b-256 checksum
How to use checksums
76f4cf2e21f8ac098a5a4f6742a241b9ed132089d88cfd2696c3ccf622f6212a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Security for pyplatypus 0.3.0a2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pyplatypus-0.3.0a2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page