Skip to main content

RankSEG: A Statistically Consistent Segmentation Prediction Solver for Dice and IoU Metrics Optimization

Project description

🧩 RankSEG

RankSEG: A Statistically Consistent Segmentation Prediction Module
for Dice and IoU Metrics Optimization

PyPI License Python PyTorch GitHub Stars Documentation

JMLR NeurIPS

RankSEG is a new framework for semantic segmentation that provides plug-and-play modules to improve segmentation results during inference. It works with ANY pre-trained segmentation model without retraining.

image

RankSEG makes your segmentation model better at prediction time. 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.

Why RankSEG?

Traditional segmentation methods use argmax or thresholding to convert model outputs to predictions. However, these methods are not optimized for the actual evaluation metrics (Dice, IoU).

RankSEG consistently outperforms standard argmax prediction without any model 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. RankSEG uses Dice metric with RMA solver.

Key Features

  • 🎯 Metric-Optimized: Directly optimizes for Dice or IoU metrics instead of using generic ad-hoc argmax during inference
  • 🔌 Plug-and-Play: Works with ANY pre-trained segmentation model without retraining
  • ⚡ Efficient Solvers: Multiple solver options (BA, TRNA, RMA) for different speed-accuracy trade-offs
  • 🧩 Flexible Tasks: Supports both multi-class and multi-label segmentation tasks, whether objects overlap or not

Get Started with RankSEG

Installing RankSEG

rankseg is available on PyPI. Run the following command to get the latest version of the package:

pip install -U rankseg

First Steps with RankSEG

Once you installed rankseg, you can run the following code snippet to optimize predictions from your pre-trained segmentation model:

import torch
import torch.nn.functional as F
from rankseg import RankSEG

# Your pre-trained model's probability output
probs = F.softmax(torch.randn(4, 21, 256, 256), dim=1)  # (batch, classes, height, width)

# Create RankSEG predictor optimized for Dice metric
rankseg = RankSEG(metric='dice', solver='RMA')

# Get optimized predictions
preds = rankseg.predict(probs)

You can refer to the documentation to explore more options and detailed API reference.

Cite RankSEG

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}
}

Reproducing Paper Results

To reproduce the experimental results from our publications, we provide dedicated repositories with complete code, datasets, and configurations:

JMLR

Repository: statmlben/rankseg

NeurIPS

Repository: ZixunWang/RankSEG-RMA

Each repository includes detailed instructions for setting up the environment, downloading datasets, and running the experiments.

Useful Links

Contributing

We welcome contributions! Please feel free to submit issues or pull requests on our GitHub repository.

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

rankseg-0.0.2.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

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

rankseg-0.0.2-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file rankseg-0.0.2.tar.gz.

File metadata

  • Download URL: rankseg-0.0.2.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for rankseg-0.0.2.tar.gz
Algorithm Hash digest
SHA256 527543a1f16f28e0dad3d68ca1ce733efd32f12ce5667032c1c4eda6318dbe63
MD5 fe51cb8159c6ea4bfa008e9c03d5e7c6
BLAKE2b-256 541419d456479c09f299d855b218f7f593df4db5ea41ad53fa3db1cbdb5db149

See more details on using hashes here.

File details

Details for the file rankseg-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: rankseg-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for rankseg-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 677b3842cf463d39d6d876236a264fde8cab7a8b417fb0bad17e74ebc763aabf
MD5 994558572d2c6e0c1db29cbf1f20f74a
BLAKE2b-256 86bfc10ec13d8122e59026bc7738956668d0f2560215deb30bb5531077ccf679

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page