π§© RankSEGΒΆ
RankSEG is a statistically grounded framework for semantic segmentation that provides plug-and-play modules designed to improve samplewise Dice/IoU during inference without retraining.
RankSEG-based methods are statistically consistent with respect to Dice and IoU under the methodβs assumptions. Actual gains depend on the quality of the input probabilities and the deployment distribution, so compare RankSEG with the baseline decoder on representative data.
News β August 2026
RankSEG is now featured in the official MONAI RankSEG integration tutorial as optional third-party array and dictionary post-processing transforms. The notebook is also available in Google Colab.
Note
RankSEG optimizes metrics using a samplewise aggregation: the score is computed per sample and then averaged across the dataset (akin to aggregation_level='samplewise' in TorchMetrics DiceScore). See Metrics for details.
Key PropertiesΒΆ
π― Metric-Optimized |
Directly optimizes for Dice or IoU metrics instead of using generic ad-hoc argmax during inference. |
π Plug-and-Play |
Works with pre-trained probabilistic segmentation models 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. |
β¨ Quick StartΒΆ
Install rankseg using pip:
pip install rankseg
Basic usage example:
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')
# Get optimized predictions
preds = rankseg(probs)
Functional API for one-off prediction:
from rankseg.functional import rankseg
preds = rankseg(probs, metric='dice')
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).
Performance Improvements Across Models and Datasets:
The NeurIPS 2025 benchmarks below report improvements over standard argmax without 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% |
Note
Results from our NeurIPS 2025 paper. RankSEG uses Dice metric with RMA solver. Results can vary with probability quality, metric definition, and deployment distribution; validate the decoder on representative data.
Learn MoreΒΆ
Learn how to use RankSEG with your segmentation models
Integration guides for PyTorch, Transformers, SAM, and MONAI
Notebook tutorials for quickstart, Transformers, SAM, MONAI, and PaddleSeg
Detailed documentation of all classes and functions
How to cite RankSEG in your research
Source code, issues, and contributions
ReferencesΒΆ
Ben Dai and Chunlin Li. Rankseg: a consistent ranking-based framework for segmentation. Journal of Machine Learning Research, 24(224):1β50, 2023.
Zixun Wang and Ben Dai. Rankseg-rma: an efficient segmentation algorithm via reciprocal moment approximation. In Advances in Neural Information Processing Systems. 2025.
AΒ Yu Volkova. A refinement of the central limit theorem for sums of independent random indicators. Theory of Probability & Its Applications, 40(4):791β794, 1996.