RankSEG: A Statistically Consistent Segmentation Prediction Solver for Dice and IoU Metrics Optimization
Project description
🧩 RankSEG
🚀 RankSEG: Boost Segmentation Metrics without Retraining
Improve your existing segmentation models performance in Dice/IoU metrics instantly.
RankSEG is a plug-and-play post-processing module that improves segmentation results during inference. It works with ANY pre-trained logit/prob-outcome segmentation model (SAM, DeepLab, SegFormer, UPerNet, etc.) without any retraining or fine-tuning.
Instead of using simple thresholding or argmax (which don't care about Dice/IoU scores), RankSEG directly optimizes for these metrics - giving you better results without any extra training.
Explore RankSEG by reading our documentation.
⚡ Quick Start
Get started in seconds. RankSEG is designed to be dropped into your existing inference pipeline.
1. Installation
pip install -U rankseg
2. Optimize Predictions
Add 3 lines of code to your inference loop:
import torch
import torch.nn.functional as F
from rankseg import RankSEG
# 1. Initialize RankSEG (optimizing for Dice score)
rankseg = RankSEG(metric='dice', solver='RMA')
# 2. Get your model's probability outputs (Batch, Class, Height, Width)
# Example: probs = model(images).softmax(dim=1)
probs = F.softmax(torch.randn(4, 21, 256, 256), dim=1)
# 3. Get optimized predictions (No retraining needed!)
preds = rankseg.predict(probs)
✨ Key Features
- 🚀 Instant Metric Boost: Consistently improves mIoU and mDice scores over standard
argmax. - 🔌 Plug-and-Play: Compatible with any PyTorch segmentation model.
- 🆓 Training-Free: Purely post-processing. No gradients, no backprop, no dataset needed.
- ⚡ Efficient: Optimized solvers (RMA) for real-time inference.
- 🧩 Flexible: Supports multi-class and multi-label segmentation.
📊 Why RankSEG?
Standard segmentation methods use argmax or thresholding, which are not optimized for evaluation metrics like Dice or IoU. RankSEG solves this by directly optimizing the target metric during inference.
Performance Comparison (No Retraining):
| Model | Dataset | mIoU (Argmax) | mIoU (RankSEG) | mDice (Argmax) | mDice (RankSEG) |
|---|---|---|---|---|---|
| DeepLabV3+ (ResNet101) | PASCAL VOC | 77.25% | 78.14% ↑0.89% | 82.08% | 83.14% ↑1.06% |
| SegFormer (MiT-B4) | PASCAL VOC | 77.57% | 78.59% ↑1.02% | 82.15% | 83.22% ↑1.07% |
| UPerNet (ConvNeXt) | PASCAL VOC | 79.52% | 80.31% ↑0.79% | 84.11% | 84.98% ↑0.87% |
| PSPNet (ResNet101) | Cityscapes | 65.89% | 66.53% ↑0.64% | 73.55% | 74.28% ↑0.73% |
| DeepLabV3+ (ResNet101) | Cityscapes | 66.17% | 66.68% ↑0.51% | 73.71% | 74.33% ↑0.62% |
| UPerNet (ConvNeXt) | Cityscapes | 68.83% | 69.57% ↑0.74% | 76.08% | 76.97% ↑0.89% |
| SegFormer (MiT-B4) | ADE20K | 40.00% | 40.82% ↑0.82% | 46.50% | 47.57% ↑1.07% |
| UPerNet (ConvNeXt) | ADE20K | 42.86% | 43.84% ↑0.98% | 49.61% | 50.85% ↑1.24% |
| CPT (Swin-Large) | ADE20K | 44.59% | 45.56% ↑0.97% | 51.27% | 52.58% ↑1.31% |
Results from our NeurIPS 2025 paper.
🛠️ Integrations
RankSEG works out-of-the-box with any PyTorch-based segmentation framework.
| Framework | Task | Integration Guide |
|---|---|---|
| PyTorch (Native) | Semantic Seg. | |
| SegmentAnything | Semantic Seg. | |
| MMSegmentation | Semantic Seg. | Coming Soon |
| PaddleSeg | Semantic Seg. | Coming Soon |
Note: Don't see your favorite framework? Open an issue or submit a PR!
📚 Documentation & Resources
- Full Documentation: rankseg.readthedocs.io
- JMLR Paper: RankSEG: A Consistent Ranking-based Framework for Segmentation
- NeurIPS Paper: RankSEG-RMA: An Efficient Segmentation Algorithm via Reciprocal Moment Approximation
🔗 Citation
If you use RankSEG in your research, please cite our papers:
@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},
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},
year={2025}
}
🤝 Contributing
We welcome contributions! Please feel free to submit issues or pull requests on our GitHub repository.
If you find RankSEG useful, please give it a star! ⭐
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rankseg-0.0.3.tar.gz.
File metadata
- Download URL: rankseg-0.0.3.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
260b2611771d32a2e9f28ba4f80b9767c2f8040e979da77202406f2f924d89bc
|
|
| MD5 |
5d736522ff3c3275e7f04110d83adc16
|
|
| BLAKE2b-256 |
078894bac026d6b325df02c9e7a271831e78cffd1605bfec7ef39699a1f5c348
|
File details
Details for the file rankseg-0.0.3-py3-none-any.whl.
File metadata
- Download URL: rankseg-0.0.3-py3-none-any.whl
- Upload date:
- Size: 15.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
998502d1826b4ba377542ba68ffa26e39d3ae7afc9cc1dd14d3bef72b97a17c0
|
|
| MD5 |
ca479396f0c9a7f72126137291963fb3
|
|
| BLAKE2b-256 |
bd8e97f5b014c9adf35102cf4d8f8efba7c77242c2e401b4b523ad084c81d051
|