Skip to main content

License PyPI version Python CI CI Paper

TotalSegmentator-KonfAI

Fast and lightweight CLI for whole-body CT or MRI segmentation using TotalSegmentator models within the KonfAI framework.


🧩 Overview

TotalSegmentator-KonfAI is a lightweight command-line interface (CLI) for running TotalSegmentator models for multi-organ medical image segmentation, through the KonfAI deep learning framework.

It provides fast and efficient inference for segmentation tasks, including on low-resource hardware. Pretrained models are automatically downloaded from Hugging Face Hub.


⭐ Key Advantages

📦 Lightweight model distribution

  • ~125 MB per model 1.5 mm model
  • 🔁 Compared to ~234 MB per model for the original TotalSegmentator
  • ~66.2 MB 3 mm models
  • 🔁 Compared to ~135 MB (original)

➡️ Faster setup, smaller disk footprint


⚡ Efficient inference

🔬 Performance comparison

Same input, same weights (Datasets 291–295, 1.5 mm, 5-model total), same PyTorch build (2.12.1, cu13.0), single NVIDIA RTX PRO 5000 (24 GB), TotalSegmentator 2.18.0. Peak RAM = process-tree resident set; peak VRAM = over baseline. Measured with KonfAI's benchmarks/perf/bench_apps.py (2026-09-09).

Case (voxels) Tool Time Peak RAM Peak VRAM
S (240 × 220 × 200) KonfAI 7.6 s 5.0 GB 12.3 GB
Original 29.9 s 22.6 GB 3.3 GB
M (249 × 246 × 246) KonfAI 17.7 s 5.2 GB 15.4 GB
Original 58.3 s 25.2 GB 7.1 GB
L (512 × 512 × 531) KonfAI 212 s 17.6 GB 10.6 GB
Original 377 s 47.9 GB 23.1 GB

📈 Key observations

  • 1.8–3.9× faster whole-body inference across sizes, 2.7–4.8× less host RAM.
  • KonfAI trades more VRAM on small/medium cases (larger patches, GPU accumulation) for the speed-up, while it stays inside a 24 GB card.
  • On large cases the streaming reassembly bounds VRAM (10.6 GB) where the original nears the card limit (23.1 GB / 24 GB), so KonfAI is then lighter on both RAM and VRAM.

🧠 Features

  • ⚡ Fast inference powered by KonfAI
  • 🤗 Automatic model download from Hugging Face
  • 🧠 Supports evaluation workflows with reference data
  • 🧾 Multi-format compatibility: supports all major medical image formats handled by ITK

🚀 Installation

From PyPI:

python -m pip install totalsegmentator-konfai

From source:

git clone https://github.com/fideus-labs/KonfAI.git
cd KonfAI
# konfai and konfai-apps must come from the same checkout: this app pins both to its own
# setuptools_scm version, which only exists on PyPI at a release tag.
python -m pip install -e . -e konfai-apps -e apps/totalsegmentator

⚙️ Usage

The CLI is organised into sub-commands, mirroring the KonfAI Apps operations:

Sub-command Purpose
segment Run the segmentation (inference).
eval Evaluate a segmentation against a reference.
pipeline Segment, then evaluate in one command.

Perform segmentation on an input volume:

totalsegmentator-konfai segment total -i path/to/image.nii.gz -o ./Output/

Evaluate against a reference, or run both at once:

totalsegmentator-konfai eval total -i image.nii.gz --gt reference.nii.gz -o ./Output/
totalsegmentator-konfai pipeline total -i image.nii.gz --gt reference.nii.gz --gpu 0

Arguments

Flag Description Default
TASK Model on Hugging Face (total, total_mr, total-3mm, total_mr-3mm), which determines what is predicted required
-i, --inputs Input medical image(s) or a dataset directory required
-o, --output Output directory ./Output/
--models Explicit model identifiers/paths to ensemble (segment / pipeline) unset
--gt Reference segmentation(s): required by eval, optional in pipeline unset
--mask Evaluation mask(s) (eval / pipeline) unset
--gpu GPU id(s), e.g. 0 or 0 1 CPU if unset
--cpu Number of CPU worker processes unset
-q, --quiet Suppress console output False

Note: TotalSegmentator models do not expose an uncertainty workflow, so there is no uncertainty sub-command.


📖 Reference

If you use TotalSegmentator-KonfAI in your work, please cite the original TotalSegmentator work in addition to this CLI tool.

  • Wasserthal, J. et al. (2023).
    TotalSegmentator: Robust Segmentation of 104 Anatomic Structures in CT Images.
    Radiology: Artificial Intelligence, 5(5). https://doi.org/10.1148/ryai.230024

  • Akinci D’Antonoli, T. et al. (2025).
    TotalSegmentator MRI: Robust Sequence-independent Segmentation of Multiple Anatomic Structures in MRI.
    Radiology, 314(2). https://doi.org/10.1148/radiol.241613

  • Boussot, V., & Dillenseger, J.-L. (2025).
    KonfAI: A Modular and Fully Configurable Framework for Deep Learning in Medical Imaging.
    arXiv preprint arXiv:2508.09823


⚡ Performance & VRAM

Benchmarked on a single NVIDIA RTX PRO 5000 (24 GB) with a real whole-body CT (295 × 259 × 219, 2 mm), patch [96, 128, 160], 5-model ensemble (total), half precision (autocast). The app measures its batch size on your GPU (a forward of one patch, then of two, then the largest power of two that fits half of the free VRAM); override it in SlicerKonfAI (⚙ Advanced) or on the CLI with --patch-size / --batch-size.

Free VRAM Batch (auto) Peak VRAM Time / case
8 GB 2 n/a n/a
16 GB 4 n/a n/a
24 GB 4 ~20 GB ~42 s

The 5-model total head (117 classes) needs ~20 GB for its forward, so the ensemble targets a 24 GB card; on smaller cards use total-3mm (1 model, 3 mm). Its whole-volume accumulator is too large for the GPU, so reassembly runs on the host (~19 GB RAM). A larger batch saturates the card and slows inference. Inference scales with the case size.



Metadata

Release files for totalsegmentator-konfai 1.9.0

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

Source distribution (sdist)

Source distribution for totalsegmentator-konfai 1.9.0
File Size Uploaded Provenance Actions
totalsegmentator_konfai-1.9.0.tar.gz 13.6 kB With provenance Details for totalsegmentator_konfai-1.9.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for totalsegmentator-konfai 1.9.0
File Interpreter ABI Platform Actions
totalsegmentator_konfai-1.9.0-py3-none-any.whl Python 3 none any Details for totalsegmentator_konfai-1.9.0-py3-none-any.whl

Total release size: 24.4 kB

Release files / totalsegmentator_konfai-1.9.0.tar.gz

Download URL totalsegmentator_konfai-1.9.0.tar.gz
Size 13.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ff21c4535f17074dd254a35f93d7777bef3e50ced95f6c5e02acd83f5f7d4606
BLAKE2b-256 checksum
How to use checksums
e48e3c005fb3119d0647885b960ad798702808dab4e13923f6aaa708d3dbfc45
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 Nov 26, 2026.

Transparency log

Release files / totalsegmentator_konfai-1.9.0-py3-none-any.whl

Download URL totalsegmentator_konfai-1.9.0-py3-none-any.whl
Size 10.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
20c89e44204138fe0da30a52b0db213707cff909666f834d75af05b7d74fbf5e
BLAKE2b-256 checksum
How to use checksums
d69836764c6920abda5a39e9f1c4ec5bf418097fce73679d8833d8c9c8f03aa8
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 Nov 26, 2026.

Transparency log

Security for totalsegmentator-konfai 1.9.0

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for totalsegmentator_konfai-1.9.0.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 Nov 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.

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