Skip to main content

🧩 RankSEG

Metric-Aware Dice/IoU Post-Processing Without Retraining

PyPI License Python PyTorch GitHub Stars Documentation Hugging Face Spaces Open In Colab 中文文档

JMLR NeurIPS

News | Quick Start | Benchmarks | Integrations | Docs | Citation


RankSEG replaces argmax or fixed thresholds with metric-aware post-processing designed to improve Dice or IoU—no retraining or fine-tuning. Use it with frozen PyTorch segmentation models for multiclass, binary, and multilabel tasks, from natural images to 3D medical scans.

RankSEG on 3D CT · Same model. No retraining.

Pancreas CT slice: ground truth, argmax (Dice 35.0), and RankSEG (Dice 49.3). White outlines mark ground truth.

20-volume mean Dice: 50.30 → 54.87 (+4.57 pp)
Frozen MONAI BTCV Swin UNETR · MSD Pancreas.

Illustrative slice above; white outline = ground truth. Research use only.
Evaluation protocol and example selection.

📰 News

  • August 2026 — RankSEG joins the official MONAI Tutorials! Try metric-aware post-processing for 3D medical segmentation. Tutorial · Colab

⚡ Quick Start

pip install -U rankseg

Optional Linux x86-64 GPU acceleration: pip install "rankseg[cuda]" (setup and activation).

For multiclass model logits shaped (batch, classes, *spatial), with at least two classes:

from rankseg import RankSEG

probs = model_logits.softmax(dim=1)
preds = RankSEG(metric="dice")(probs)  # replaces argmax; shape: (batch, *spatial)

For binary/multilabel examples, the functional API, and solver options, see the Getting Started guide.

RMA Dice offers optional memory-saving screening with safe_screening="auto". The default remains False, preserving the original computation path. Opting in may change masks near numerical ties. Details.

New in 0.0.9: spatial dependence with DEP. For Dice, solver="DEP" models label dependence between nearby pixels (NeurIPS 2026). Try it on 2D images with ambiguous regions, using the same probabilities:

preds_dep = RankSEG(metric="dice", solver="DEP", theta=300.0)(probs)

DEP supports CPU/CUDA and both output modes. It requires smooth=0 and does not accept safe_screening. theta is the spatial bandwidth in pixels; theta=0 removes dependence between distinct pixels but does not guarantee the same predictions as RMA. RMA remains the default. DEP usage and parameters.

Try it online: Colab · Interactive demo

📊 Benchmarks

Same probabilities. No retraining. Selected results compare argmax with RankSEG-RMA using the Dice objective. Scores are percentages; gains are percentage points (pp).

Selected RankSEG benchmark results comparing Dice and IoU with argmax on five datasets

Gains vary by dataset. Full results, metric definitions, runtime, and reproduction commands: rankseg-benchmark. For the algorithm and additional experiments, see our NeurIPS 2025 paper.

🔌 Integrations

Choose your workflow:

Ecosystem Get started Try online
PyTorch Docs · Example Colab
Hugging Face Docs · Notebook Colab
SAM family Docs · Notebook Colab
MONAI Docs · Official tutorial Colab
PaddleSeg (externally maintained) Docs · Community branch —

🔗 Citation

If you use RankSEG in your research, please cite our papers:

  • Dai, B., & Li, C. (2023). RankSEG: A Consistent Ranking-based Framework for Segmentation. Journal of Machine Learning Research, 24(224), 1-50. [link]
  • Wang, Z., & Dai, B. (2025). RankSEG-RMA: An Efficient Segmentation Algorithm via Reciprocal Moment Approximation. Advances in Neural Information Processing Systems (NeurIPS 2025). [link]
  • Wang, Z., & Dai, B. (2026). On the Relaxation of Conditional Independence Assumption for Image Segmentation. Advances in Neural Information Processing Systems (NeurIPS 2026).
@article{dai2023rankseg,
  title={RankSEG: A Consistent Ranking-based Framework for Segmentation},
  author={Dai, Ben and Li, Chunlin},
  journal={Journal of Machine Learning Research},
  volume={24},
  number={224},
  pages={1--50},
  url={https://www.jmlr.org/papers/v24/22-0712.html},
  year={2023}
}

@inproceedings{wang2025rankseg,
  title={RankSEG-RMA: An Efficient Segmentation Algorithm via Reciprocal Moment Approximation},
  author={Wang, Zixun and Dai, Ben},
  booktitle={Advances in Neural Information Processing Systems},
  url={https://arxiv.org/abs/2510.15362},
  year={2025}
}

@inproceedings{wang2026rankseg,
  title={On the Relaxation of Conditional Independence Assumption for Image Segmentation},
  author={Wang, Zixun and Dai, Ben},
  booktitle={Advances in Neural Information Processing Systems},
  year={2026}
}

Star us on GitHub if RankSEG helps your project! ⭐

Metadata

Release files for rankseg 0.0.9

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

Source distribution (sdist)

Source distribution for rankseg 0.0.9
File Size Uploaded Provenance Actions
rankseg-0.0.9.tar.gz 121.2 kB Without provenance Details for rankseg-0.0.9.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rankseg 0.0.9
File Interpreter ABI Platform Actions
rankseg-0.0.9-py3-none-any.whl Python 3 none any Details for rankseg-0.0.9-py3-none-any.whl

Total release size: 175.4 kB

Release files / rankseg-0.0.9.tar.gz

Download URL rankseg-0.0.9.tar.gz
Size 121.2 kB
Tags Source
SHA-256 checksum
How to use checksums
65c7b06f8f665196a4072b8867f85be76f70dbc8ebb22451a8dfa89f938790a5
BLAKE2b-256 checksum
How to use checksums
2bf5417eb13bcafa115d589aa206b13b4a0f74e434520adc9908f89224fec204
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

Release files / rankseg-0.0.9-py3-none-any.whl

Download URL rankseg-0.0.9-py3-none-any.whl
Size 54.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7ec9ef33f709a0b216c85b521d8224970fc940fa0c42dbb222a788e225fe9825
BLAKE2b-256 checksum
How to use checksums
76cabc300c3d281825c77f258b09ea6a44e900f2f61ff4954e33c9e2106183b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

Security for rankseg 0.0.9

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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