Abstract
Heatmap regression with a deep network has become one of the mainstream approaches to localize facial landmarks. However, the loss function for heatmap regression is rarely studied. In this paper, we analyze the ideal loss function properties for heatmap regression in face alignment problems. Then we propose a novel loss function, named Adaptive Wing loss, that is able to adapt its shape to different types of ground truth heatmap pixels. This adaptability penalizes loss more on foreground pixels while less on background pixels. To address the imbalance between foreground and background pixels, we also propose Weighted Loss Map, which assigns high weights on foreground and difficult background pixels to help the training process focus more on pixels that are crucial to landmark localization. To further improve face alignment accuracy, we introduce boundary prediction and CoordConv with boundary coordinates. Extensive experiments on different benchmarks, including COFW, 300W and WFLW, show our approach outperforms the state-of-the-art by a significant margin on various evaluation metrics.
Introduction
Face alignment—the task of localizing specific landmarks such as eyes, nose, and jawline—is a cornerstone of facial recognition and 3D reconstruction. Most modern systems utilize heatmap regression, where a neural network predicts a Gaussian distribution centered on each landmark.
The industry standard for training these networks has long been Mean Squared Error (MSE). However, MSE suffers from two critical flaws in this context:
- Insensitivity to Small Errors: MSE’s gradient decreases as the error gets smaller. In heatmap regression, the most important pixels are at the peak (the "mode") of the Gaussian. If the model is slightly off at the peak, MSE doesn't penalize it enough, leading to "blurry" predictions and shifted landmarks.
- Foreground-Background Imbalance: In a typical $64 \times 64$ heatmap, foreground pixels (the landmark blobs) make up only about 1.2% of the data. The overwhelming amount of "empty" background pixels dominates the loss, causing the model to struggle with difficult cases like occlusions or heavy blur.
Methodology
Adaptive Wing (AWing) Loss
Building on the previous "Wing Loss" (originally designed for direct coordinate regression), AWing loss is designed to change its curvature based on the ground truth pixel value ($y$).
- For Foreground Pixels ($y \approx 1$): The loss behaves like a modified log function, providing a very strong gradient for small errors. This forces the model to pinpoint the exact center of the landmark.
- For Background Pixels ($y \approx 0$): The loss behaves more like MSE, which is smoother and helps the training process converge without being distracted by tiny fluctuations in empty space.
Weighted Loss Map (WLM)
To solve the data imbalance, the authors introduce a Weighted Loss Map. They identify "difficult background pixels"—those immediately surrounding a landmark—using a dilation operation on the ground truth. By assigning much higher weights to these pixels and the foreground pixels, the network is forced to focus on the areas that actually matter for localization.
Structural Enhancements
The model also incorporates Boundary Prediction (an extra channel that predicts the lines of the face) and CoordConv (encoding spatial coordinates into the feature maps). This gives the network a better "sense of space" and global facial structure, improving accuracy in sparse landmark scenarios.
Experimental Results
The AWing approach set new records across several rigorous benchmarks, including WFLW, 300W, and COFW. On the COFW dataset, which focuses on heavy occlusions, the failure rate (at 10% NME) was reduced from 3.73% to 0.99%.
Key findings from the experiments include:
- SOTA on WFLW: The method outperformed previous best methods by a significant margin, particularly in the "Pose" and "Occlusion" subsets.
- Efficiency: A lightweight version of the model (using only one "Hourglass" stack) outperformed previous state-of-the-art models while running at 120 FPS on a standard GPU.
- Generalization: When applied to human pose estimation (LSP dataset), AWing loss significantly boosted accuracy over MSE, suggesting it is a superior general-purpose loss for any heatmap-based keypoint detection.
Conclusion
Adaptive Wing Loss addresses the fundamental limitations of MSE in heatmap regression by introducing pixel-intensity adaptivity. By ensuring the gradient remains high even when errors are small for landmarks, the model achieves higher precision. Furthermore, the Weighted Loss Map successfully mitigates the foreground-background imbalance. While the loss introduces new hyperparameters that may require tuning for different domains, its performance on face alignment and human pose estimation benchmarks demonstrates its robustness and versatility.
Summary updated