Rethinking Rotated Object Detection with Gaussian Wasserstein Distance Loss

Xue Yang, Junchi Yan, Qi Ming, Wentao Wang, Xiaopeng Zhang, Qi Tian

TL;DR

This paper introduces a novel regression loss for rotated object detection by modeling bounding boxes as 2D Gaussian distributions and calculating the Gaussian Wasserstein Distance (GWD) between them. This approach creates a smooth, differentiable loss that elegantly solves long-standing issues like boundary discontinuities and "square-like" object ambiguity, significantly outperforming standard regression losses across multiple aerial and text benchmarks.

The Challenge of Rotated Object Detection

In standard object detection, models predict horizontal boxes. However, in fields like aerial imaging or scene text recognition, objects are often tilted. Detecting these requires an extra parameter: the rotation angle ($\theta$).

Traditional methods use "Smooth L1" loss to regress the five parameters $(x, y, w, h, \theta)$ independently. This leads to three major headaches:

  1. Metric Inconsistency: A small L1 loss doesn't always mean a high Intersection over Union (IoU). The parameters are coupled in reality, but the loss treats them as separate.
  2. Boundary Discontinuity: Because angles are periodic (e.g., -90° is effectively the same as 0° in some definitions), the loss can suddenly "jump" at the boundary, making training unstable.
Comparison of loss functions across different angle differences.
  1. The Square-like Problem: For objects that are nearly square, the model gets confused about which side is the "width" and which is the "height," leading to massive loss spikes for visually minor errors.
Comparison of loss functions across different aspect ratios.

Directly optimizing for rotational IoU would solve these issues, but rotational IoU is notoriously difficult to calculate and is not differentiable for backpropagation.

The GWD Solution

The authors propose a clever mathematical detour: convert the box into a 2D Gaussian distribution.

  • The Conversion: A rotated bounding box can be uniquely represented as a 2D Gaussian $N(\mathbf{m}, \mathbf{\Sigma})$. The box center becomes the mean ($\mathbf{m}$), and the width, height, and angle are used to construct the covariance matrix ($\mathbf{\Sigma}$).
  • The Distance: Instead of comparing box coordinates, the model calculates the Wasserstein Distance between the predicted Gaussian and the ground truth Gaussian.
  • The Loss Function: Because the raw Wasserstein distance can be sensitive to large outliers, the authors wrap it in a non-linear transformation (like a square root or log) to create the GWD Loss.

This method is standard-compliant: if the boxes are horizontal, the GWD loss simplifies to something very similar to the standard $l_2$ norm used in horizontal detection.

Key Insights

  • Parameter Coupling: By using a Gaussian representation, the width, height, and angle are mathematically "entangled" in the covariance matrix. This forces the model to learn how these parameters interact, rather than treating the angle as just another number.
  • Box-Definition Neutrality: There are several ways to define a rotated box (e.g., the "OpenCV protocol" vs. the "Long Edge definition"). Usually, researchers have to pick one and stick to it. GWD is mathematically invariant to these definitions—the underlying Gaussian is the same regardless of how you label the box.
  • Gradient for Non-overlapping Boxes: Standard IoU loss is zero if two boxes don't overlap, providing no "direction" for the model to learn. GWD provides a continuous gradient even when boxes are far apart, which is crucial for detecting small objects.

Datasets and Results

The authors evaluated their method on five diverse datasets to prove its generality, including DOTA and UCAS-AOD (aerial images), HRSC2016 (ships), and ICDAR2015 & MLT (oriented scene text).

The GWD loss consistently outperformed the baseline (Smooth L1) and other specialized losses:

  • DOTA: On a RetinaNet baseline, GWD improved the mAP by 3.2%. When combined with more advanced detectors like R3Det, it achieved a state-of-the-art 80.23% mAP.
  • High-Precision Detection: The gains were most dramatic at high IoU thresholds. On the HRSC2016 ship dataset, the $AP_{75}$ (accuracy at 75% IoU) jumped by over 22% for some detectors.
  • Scene Text: On the MLT dataset, the H-mean (a common text metric) increased by 6.16%, proving the method isn't just for aerial photos.

Limitations and Future Work

While GWD is highly effective, the paper notes a few areas for consideration. The loss introduces a hyperparameter $\tau$ and a non-linear function $f$ to modulate the distance. While the authors provide recommended settings ($\tau=2$, $f=sqrt$), these might need adjustment for vastly different datasets. Furthermore, without the non-linear transformation, the Wasserstein distance grows very quickly, which can make the model sensitive to outliers during the early stages of training.

The authors suggest that this Gaussian modeling approach could be extended beyond 2D boxes to 3D object detection or even video tracking, opening exciting new avenues for spatial regression tasks.

Summary updated

BibTeX
@inproceedings{yang2021rethinking,
  author = {Xue Yang and Junchi Yan and Qi Ming and Wentao Wang and Xiaopeng Zhang and Qi Tian},
  title = {{Rethinking Rotated Object Detection with Gaussian Wasserstein Distance Loss}},
  booktitle = {International Conference on Machine Learning},
  year = {2021},
  url = {https://openreview.net/forum?id=k2g0dT5RFo},
}
Figure