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 (cu13.0), single NVIDIA RTX PRO 5000 (24 GB). Peak RAM = process-tree resident set; peak VRAM = over baseline.

Case (voxels) Tool Time Peak RAM Peak VRAM
S — 240 × 220 × 200 KonfAI 12 s 6.0 GB 12.0 GB
Original 35 s 21 GB 3.7 GB
M — 533 × 390 × 177 KonfAI 17 s 6.5 GB 12.9 GB
Original 61 s 26.5 GB 5.1 GB
L — 512 × 512 × 531 KonfAI 314 s 19.3 GB 10.4 GB
Original 459 s 51.8 GB 23.3 GB

📈 Key observations

  • 1.5–3.6× faster whole-body inference across sizes, 2.7–4.1× 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.4 GB) where the original nears the card limit (23.3 GB / 24 GB) — 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
python -m pip install -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) — 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 auto-selects the batch size from your free GPU VRAM (vram_plan); 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
16 GB 4
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.


🔗 Links


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

totalsegmentator_konfai-1.7.0.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

totalsegmentator_konfai-1.7.0-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file totalsegmentator_konfai-1.7.0.tar.gz.

File metadata

  • Download URL: totalsegmentator_konfai-1.7.0.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for totalsegmentator_konfai-1.7.0.tar.gz
Algorithm Hash digest
SHA256 a9d2fc2556cccabe0fbdd953c4bf6ff926225932eb654e0d8620c5d53b9bba7b
MD5 9dbcb29d6547597d73b06a8a1e92c776
BLAKE2b-256 63fdc55d2e53a4954424db869a1b2bf165c9f0d3146eee2c9075efee8bf7c4d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for totalsegmentator_konfai-1.7.0.tar.gz:

Publisher: publish.yml on fideus-labs/KonfAI

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file totalsegmentator_konfai-1.7.0-py3-none-any.whl.

File metadata

File hashes

Hashes for totalsegmentator_konfai-1.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 efc0922d385085e1b85d429b1349a2916958c42326d4e74760f21619f071d48f
MD5 f07c5bf6c85ab34f51f9db27349330f3
BLAKE2b-256 af22b098b0e06cafaf8676f552405fc5d4d754581aa2b68b0b1ced8c6d97642d

See more details on using hashes here.

Provenance

The following attestation bundles were made for totalsegmentator_konfai-1.7.0-py3-none-any.whl:

Publisher: publish.yml on fideus-labs/KonfAI

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

1.8.1

2 files

1.8.0

2 files

This release

1.7.0 This release

2 files

1.6.0

2 files

1.5.9

2 files

1.5.8

2 files

1.5.7

2 files

1.5.6

2 files

1.5.5

2 files

1.5.4

2 files

1.5.3

2 files

1.5.2

2 files

1.5.1

2 files

1.5.0

2 files

1.4.9

2 files

1.4.8

2 files

1.4.7

2 files

1.4.6

2 files

1.4.5

2 files

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