Abstract
In medical image segmentation, the combination of Binary Cross-Entropy (BCE) and Soft Dice loss is widely considered the state-of-the-art approach for handling class imbalance. However, this study demonstrates that such hybrid models often exhibit significant performance degradation when encountering Out-of-Distribution (OoD) samples—specifically, images that contain no lesions. Through a comparative analysis of five loss strategies across multiple architectures, we show that while hybrid losses excel in "In-Distribution" scenarios where every image contains a lesion, vanilla BCE provides superior robustness in clinical settings where "healthy" samples are prevalent. We further propose "Hard Fine-tuning" as a balanced strategy to maintain boundary precision without sacrificing global stability.
Introduction
Medical image segmentation typically involves identifying small regions of interest, such as tumors or ulcers, within a much larger anatomical context. This "needle in a haystack" problem creates a severe class imbalance where background pixels vastly outnumber lesion pixels. To address this, researchers frequently employ the Soft Dice loss, which optimizes for the overlap between predictions and ground truth, alongside standard Binary Cross-Entropy (BCE).
While this combination performs well on standard benchmarks, most academic datasets are curated to include only images containing lesions. In real-world clinical workflows, a significant portion of the data consists of "negative" or healthy samples. This paper investigates how different loss functions behave when faced with these Out-of-Distribution (OoD) cases, revealing that the very mechanisms that help Dice loss handle imbalance can lead to "hallucinations" in healthy tissue.
Methodology
Loss Strategies
The authors evaluated five distinct loss strategies to determine their impact on robustness:
- Binary Cross-Entropy (BCE) Only: Standard per-pixel classification loss.
- Loss Addition (BCE + Dice): A simple summation of both loss components.
- Soft Fine-tuning: A linear transition strategy that begins with BCE and gradually increases the weight of the Dice loss throughout training.
- Hard Fine-tuning: A two-stage approach where the model is trained on BCE for 90% of the training duration, followed by a brief 10% refinement phase using Dice loss.
- Soft Dice Only: Optimization based solely on the Dice coefficient.
Architecture and Training
The study utilized a "cascade" architecture consisting of two sequential encoder-decoder networks. To ensure the findings were generalizable, the researchers tested backbones ranging from MobileNet to ResNet152 and ResNeXt-101. Optimization was performed using the Adam optimizer with a cosine learning rate decay.
The Problem of Dice Degeneracy
A core insight of this research is the mathematical instability of the Soft Dice loss when applied to images without lesions ($y=0$). In the standard Dice formula, as a model successfully learns to predict zero for all pixels in a healthy image, the denominator approaches zero. This numerical instability can cause the model to become erratic, leading to false positives in healthy tissue as it attempts to find a foreground that does not exist. Conversely, BCE treats every pixel as an independent classification task, providing a stable gradient even when the target mask is entirely empty.
Experimental Results
Datasets
The models were evaluated on two primary benchmarks:
- DFUC 2022 (Diabetic Foot Ulcer Challenge): 4,000 images, including "remission" cases (healthy feet) to test OoD robustness.
- Endotect 2021: A polyp segmentation dataset supplemented with images of ulcerative colitis (containing no polyps) to serve as secondary OoD data.
Performance Analysis
The results highlight a clear trade-off between specialized accuracy and general robustness:
- In-Distribution (ID) Performance: When testing only on images containing polyps, the hybrid BCE + Dice loss was the clear winner. For a ResNet101 backbone, it achieved a Dice Score (DSC) of ~90.96%, compared to 90.49% for BCE alone.
- Out-of-Distribution (OoD) Performance: When healthy images were introduced, the ranking flipped. The BCE-only model maintained a high DSC of 89.33%, while the previously superior BCE + Dice combination dropped to 87.92%.
- The Failure of Dice-Only: Using Soft Dice loss in isolation resulted in the poorest performance across nearly all metrics when OoD data was present, confirming its sensitivity to lesion-free images.
Discussion and Conclusion
The study concludes that while hybrid losses are effective for boundary refinement, they introduce a "hallucination" risk in clinical settings. The authors found that Hard Fine-tuning (switching to Dice at the very end of training) offers a compelling middle ground, capturing the boundary-refining benefits of Dice loss while retaining the global stability of BCE.
By applying these insights—specifically utilizing a ResNeXt-101 backbone and a robust loss selection strategy—the authors achieved 3rd place in the DFUC 2022 global challenge. For practitioners, the takeaway is clear: the "gold standard" hybrid loss should be used with caution if the deployment environment includes a high volume of healthy or negative samples. Future work will explore how these dynamics shift in multi-class scenarios and how ensembling might further mitigate the trade-off between calibration and robustness.
Summary updated