TL;DR
Class imbalance in semantic segmentation often forces a choice between missing small objects (low recall) or seeing them everywhere (low precision). This paper introduces Recall Loss, a dynamic weighting strategy that adjusts class importance based on real-time training performance, significantly boosting the detection of minority classes without the "hallucination" effect common in traditional methods.
What Problem Does This Paper Address?
In semantic segmentation, some classes are ubiquitous (roads, buildings), while others are rare (pedestrians, poles, bicycles). Standard training methods like Cross-Entropy (CE) tend to ignore these "minority" classes because the model can achieve high overall accuracy just by getting the big classes right.
Existing solutions usually fall into two traps:
- Static Weighting: Methods like Inverse Frequency Weighting give rare classes a massive, permanent boost. This often backfires, causing the model to produce "excessive false positives"—predicting a pedestrian where there is only a tree trunk—which tanks the model's precision and Mean Intersection over Union (mIoU).
- Difficulty-based Weighting: Focal Loss focuses on "hard" samples. However, the authors argue that a minority class isn't necessarily a "hard" class; it's just rare.
The challenge is to improve recall (finding all instances of a rare class) while maintaining precision (not misidentifying other things as that rare class).
Methods
The authors propose Recall Loss, a performance-balanced loss function. Unlike static methods that use pre-computed dataset statistics, Recall Loss is dynamic.
- The Core Idea: The loss weights each class based on its instantaneous recall performance during training. If the model is currently bad at identifying "bicycles," the weight for the bicycle class increases. As the model improves, the weight gradually decreases.
- The Formula: It reshapes the standard cross-entropy loss by multiplying it by $(1 - \text{Recall}_c)$, where $\text{Recall}_c$ is the current recall for class $c$ at that optimization step.
- Gradient Analysis: The authors mathematically demonstrate that the gradient of Recall Loss consists of two parts: one that encourages higher recall (increasing the score for the correct class) and one that acts as a regularizer for precision (decreasing the score for classes that are being predicted as false positives).
Datasets
The researchers evaluated their approach on two major benchmarks for autonomous driving:
- Synthia (Synthia-sequence Summer split): A large-scale synthetic dataset of urban scenes. It is particularly useful for testing imbalance because it contains very small, rare classes like traffic signs and poles.
- Cityscapes: A widely used real-world dataset of urban street scenes from European cities, featuring manual pixel-wise annotations.
Key Insights and Ideas
- Minority $\neq$ Hard: A key "aha moment" is the realization that rarity and difficulty are distinct. Weighting by rarity alone (static) is too blunt an instrument. By weighting by performance, the model only focuses on classes it is actually struggling with.
- The "Upper-Right" Goal: In a plot of Mean Accuracy (Recall) vs. Mean IoU (which accounts for Precision), most loss functions move the model to the top-left (high recall, low precision). Recall Loss is designed to move the model toward the upper-right quadrant, improving detection rates without sacrificing overall segmentation quality.
- Self-Correction: Because the weights change dynamically, the loss naturally "backs off" once a class is learned. This prevents the model from over-fitting to minority classes at the expense of the rest of the scene.
Key Results
The Recall Loss consistently outperformed standard Cross-Entropy and other balanced losses (like Focal Loss or Class-Balanced Loss) in balancing the two metrics:
- Synthia Dataset: Using a DeepLab-ResNet18 architecture, Recall Loss achieved a 9% relative improvement in mean accuracy compared to standard Cross-Entropy while maintaining a competitive mIoU.
- Small Class Mastery: On the "bike" class—the smallest in the Synthia dataset (occupying only 0.002% of pixels)—Recall Loss boosted accuracy from a dismal 5.35% to 72.69%. Crucially, it improved the IoU from 5% to 24.8%, whereas other weighting methods often saw IoU drop as they "hallucinated" bikes elsewhere.
- Qualitative Finesse: Visualizations show that Recall Loss produces much finer details for thin objects like poles and lights, which are often completely suppressed or "thickened" into blobs by other loss functions.
Limitations and Future Work
- Easy Minority Classes: The authors note that if a minority class is very "easy" to learn (like poles in certain high-contrast datasets), applying heavy weighting can actually be slightly detrimental. The model might not need the extra help.
- Hyperparameter Sensitivity: While less sensitive than Focal Loss, the dynamic nature of the recall calculation depends on how recall is estimated over batches or epochs, which could be explored further.
- Generalization: While tested on urban segmentation, the authors suggest this dynamic performance-based weighting could be applied to other imbalanced tasks like object detection or medical imaging, though those were not the focus of this specific paper.
Summary updated