Skip to main content

License PyPI version Python CI Paper

MRSegmentator-KonfAI

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


🧩 Overview

MRSegmentator-KonfAI is a lightweight command-line interface (CLI) for running MRSegmentator models through the KonfAI deep learning framework.

It provides fast and efficient inference for whole-body MRI segmentation, including on low-resource hardware.

Pretrained models are automatically downloaded from Hugging Face Hub.

⭐ Key Advantages

📦 Lightweight model distribution

  • ~128 MB per model, with up to 5 folds available
  • Download only the folds you need
  • Total size with 5 folds: ~640 MB
  • 🔁 Compared to ~1.07 GB for the original full MRSegmentator model distribution

➡️ Faster setup, smaller disk footprint


⚡ Efficient inference

🔬 Performance comparison

Same input, same weights (5-fold ensemble), 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 (249 × 246 × 246) KonfAI 14 s 6.0 GB 13.0 GB
Original 26 s 8.6 GB 3.7 GB
M (533 × 390 × 177) KonfAI 25 s 7.5 GB 15.7 GB
Original 65 s 14.6 GB 5.3 GB
L (512 × 512 × 531) KonfAI 120 s 6.2 GB 16.7 GB
Original 192 s 37.5 GB 14.6 GB

📈 Key observations

  • 1.6–2.6× faster whole-body inference, 1.4–6.0× less host RAM.
  • The GPU-resident accumulator trades more VRAM for the speed and low host RAM, while streaming keeps it bounded: on the large case host RAM stays at 6.2 GB where the original grows to 37.5 GB.
  • Byte-identical to KonfAI's own CPU reassembly path.

🧠 Features

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

🚀 Installation

From PyPI:

python -m pip install mrsegmentator-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/mrsegmentator

⚙️ 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.
uncertainty Estimate uncertainty (fold-ensemble spread).
pipeline Segment, then evaluate and estimate uncertainty in one command.

Run segmentation on an MRI scan:

mrsegmentator-konfai segment -i path/to/input.nii.gz -o ./Output/

Evaluate against a reference, or run everything at once:

mrsegmentator-konfai eval -i input.nii.gz --gt reference.nii.gz -o ./Output/
mrsegmentator-konfai pipeline -i input.nii.gz --gt reference.nii.gz --gpu 0 -f 3 -uncertainty

Arguments

Flag Description Default
-i, --inputs Input MRI volume(s) or a dataset directory required
-o, --output Output directory ./Output/
-f, --folds Number of model folds to ensemble, 1–5 (segment / pipeline) 2
-uncertainty Also write the inference stack (segment / pipeline) False
--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

📖 Reference

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

  • Häntze, H. et al. (2025).
    Segmenting Whole-Body MRI and CT for Multiorgan Anatomic Structure Delineation.
    Radiology: Artificial Intelligence, 7(6). https://doi.org/10.1148/ryai.240777

  • 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 MR (295 × 259 × 219, 2 mm), patch [96, 128, 160], 5-fold ensemble, 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 4 ~8 GB n/a
16 GB 8 ~15 GB n/a
24 GB 8 ~22 GB ~27 s

On a 24 GB card the accumulator stays on the GPU, keeping host RAM low with a byte-identical result. The plan stops short of filling the card: a still-larger batch (12 → ~24 GB) saturates the allocator and slows inference ~2× without running faster. 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

mrsegmentator_konfai-1.8.1.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

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

mrsegmentator_konfai-1.8.1-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file mrsegmentator_konfai-1.8.1.tar.gz.

File metadata

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

File hashes

Hashes for mrsegmentator_konfai-1.8.1.tar.gz
Algorithm Hash digest
SHA256 70fa65cde291ec7f83df3f9cef8479dea7fa19deb3be33417dfc21166bf80411
MD5 ddb2920f920f5e54840d96cf3e32297d
BLAKE2b-256 3717776e2cd3fc5b5042eaf2b59d47fa657b3d70214952dcb849281ffffdc301

See more details on using hashes here.

Provenance

The following attestation bundles were made for mrsegmentator_konfai-1.8.1.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 mrsegmentator_konfai-1.8.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mrsegmentator_konfai-1.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f7fde4d9f58fb82798ed0225d69d667020875ed517ff2088a137bd2bca784a96
MD5 7194f1d767f44a6520821beb9b3535f9
BLAKE2b-256 e0521f9f1c0d9d22f7d1f395d1375eec3ae0a1d124cef762dba410cc5fbc3ee6

See more details on using hashes here.

Provenance

The following attestation bundles were made for mrsegmentator_konfai-1.8.1-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

This release

1.8.1 This release

2 files

1.8.0

2 files

1.7.0

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