NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Jaccard Metric Losses: Optimizing the Jaccard Index with Soft Labels

Zifu Wang, Xuefei Ning, Matthew B. Blaschko

TL;DR

Jaccard Metric Losses (JMLs) solve a fundamental compatibility issue between Intersection-over-Union (IoU) optimization and "soft" labels. By reformulating IoU losses as true mathematical metrics, the authors enable seamless integration with advanced training techniques like knowledge distillation and label smoothing, leading to significant performance gains and better model calibration across a wide range of semantic segmentation benchmarks.

What Problem Does This Paper Address?

In semantic segmentation, we usually care about the Jaccard Index (also known as IoU) because it better reflects perceptual quality than simple pixel-wise accuracy. However, IoU is a discrete metric defined for binary "hard" labels. To train neural networks, researchers use differentiable surrogates like the Soft Jaccard Loss (SJL).

The problem is that these standard surrogates are designed for hard labels (0 or 1). When researchers try to use "soft" labels—probabilities between 0 and 1 used in techniques like Knowledge Distillation (KD) or Label Smoothing (LS)—these losses break down. For instance, the standard SJL is often not even minimized when a model’s prediction perfectly matches a soft target label. This lack of flexibility prevents IoU-based losses from benefiting from modern training pipelines that rely on soft supervision.

Methods

The authors introduce Jaccard Metric Losses (JMLs), specifically two variants: $\Delta_{JML,1}$ and $\Delta_{JML,2}$. Unlike previous surrogates, JMLs are true mathematical metrics on the unit hypercube $[0, 1]^p$. This means they satisfy four key properties: reflexivity (loss is zero if and only if prediction equals target), positivity, symmetry, and the triangle inequality.

To further enhance segmentation, they propose Boundary Label Smoothing (BLS). Standard label smoothing applies a uniform distribution across all pixels, but the authors observed that ambiguity (and thus the need for regularization) is highest at object boundaries. BLS uses a max-pooling approach to identify boundary pixels and applies smoothing only there.

For Knowledge Distillation, they use JML to directly distill the teacher's IoU information to the student. They also introduce a confidence-based filtering scheme to ensure the student only learns from the teacher's most reliable class predictions.

Key Insights and Ideas

  • The Power of the Triangle Inequality: Because JML is a metric, it satisfies the triangle inequality. This provides a mathematical guarantee that minimizing the student-teacher gap also minimizes the upper bound of the student's error relative to the ground truth.
  • SJL Pushes to Extremes: Standard SJL tends to push predictions toward 0 or 1 even when the target label is soft (e.g., 0.5). JML correctly identifies the soft target as the global minimum.
  • Boundary Sensitivity: In segmentation, "dark knowledge" (the subtle relationships between classes) is most valuable at the edges of objects. BLS captures this better than global smoothing.
  • Calibration Matters: While IoU losses often improve accuracy, they can sometimes hurt model calibration. Using JML with soft labels (JML-BLS or JML-KD) significantly mitigates this issue.
JML loss correctly minimized at the target prediction value.

Key Results

The researchers evaluated their methods across four diverse semantic segmentation datasets (Cityscapes, PASCAL VOC, ADE20K, DeepGlobe Land) and 13 different architectures. The results show that JML is a "plug-and-play" improvement over standard Cross-Entropy (CE) and existing IoU losses:

  • Accuracy Boost: JML consistently improved mIoU by over 2% on Cityscapes, PASCAL VOC, and ADE20K compared to CE alone.
  • SOTA in Distillation: JML-KD outperformed complex, state-of-the-art distillation methods despite being a much simpler approach.
  • Transformer Compatibility: The gains were consistent across both CNNs and Vision Transformers. For example, on ADE20K with SegFormer-B5, JML-BLS improved mIoU from 48.17% to 50.22%.
Results on Cityscapes showing JML-BLS and JML-KD achieving the highest mIoU.

Limitations and Future Work

  • Class Imbalance: Like many IoU-based losses, JML can struggle with extreme class imbalance. The authors suggest oversampling or class-agnostic computation as potential fixes.
  • Distributed Training: The loss behavior can change depending on the per-GPU batch size, potentially leading to suboptimal results if the batch size is too small.
  • Expansion: The authors suggest that the metric properties of JML could be useful in other fields beyond segmentation, such as quantifying similarity between feature vectors in representation learning.

Summary updated

BibTeX
@inproceedings{wang2023jaccard,
  author = {Zifu Wang and Xuefei Ning and Matthew B. Blaschko},
  title = {{Jaccard Metric Losses: Optimizing the Jaccard Index with Soft Labels}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=OFMPrCAMKi},
}
Figure