Marginalized Generalized IoU (MGIoU): A Unified Objective Function for Optimizing Any Convex Parametric Shapes

Duy-Tho Le, Trung Pham, Jianfei Cai, Hamid RezatofighiarXiv 2025 · DOI · arXiv

Abstract

Marginalized Generalized IoU (MGIoU) is a novel, efficient loss function designed to unify the optimization of arbitrary convex shapes, such as rotated boxes, ellipses, and 3D cuboids. By projecting these shapes onto their unique surface normals, MGIoU provides a fully differentiable approximation of Intersection over Union (IoU) that is 10–40x faster than existing methods. This paper demonstrates that MGIoU consistently improves accuracy across 2D/3D detection and trajectory prediction tasks while maintaining scale invariance and computational efficiency.

Introduction

In computer vision, Intersection over Union (IoU) is the gold standard for measuring the overlap between predicted and ground-truth shapes. However, directly optimizing IoU is mathematically complex for anything beyond axis-aligned boxes. For shapes like rotated rectangles, 3D cuboids, or ellipsoids, the analytical IoU is often non-differentiable or computationally expensive, leading to unstable training gradients.

To circumvent these issues, researchers often rely on "proxy" losses like $L_1/L_2$ regression or task-specific Gaussian approximations. These proxies frequently lack essential properties like scale invariance and fail to generalize across different geometric domains. MGIoU addresses this fragmentation by providing a single, unified objective function applicable to any convex parametric shape.

The MGIoU Framework

The core innovation of MGIoU is dimensionality reduction via projection. Instead of calculating complex $D$-dimensional volume overlaps, the method leverages the Separating Axis Theorem (SAT) logic to project shapes onto their unique surface normals.

Geometric intuition of MGIoU: projecting complex shapes onto unique surface normals to compute a marginalized 1D GIoU.

The optimization process follows four primary steps:

  1. Identify Normals: Extract unique normal directions (e.g., two for a 2D rectangle, three for a 3D cuboid).
  2. 1D Projection: Project the vertices of the predicted ($P$) and ground-truth ($G$) shapes onto these normal vectors, transforming the problem into 1D interval overlaps.
  3. 1D GIoU: Compute a simplified 1D version of the Generalized IoU for each normal.
  4. Marginalization: The final MGIoU is the average of these 1D GIoU values across all unique normals.

This framework eliminates the need for manual "loss balancing" between position, size, and rotation parameters, as the projection-based loss handles all geometric aspects holistically.

Experimental Evaluation

The authors evaluated MGIoU across several standard benchmarks, including DOTAv1.5 (2D oriented detection), ICDAR2017 (text detection), and the massive Omni3D benchmark for monocular 3D recognition.

Qualitative results of MGIoU on various 3D detection benchmarks including Hypersim, KITTI, Nuscenes, and Objectron.

Key Results

  • Computational Efficiency: MGIoU is significantly faster than existing IoU-based losses. On the DOTA dataset, it proved to be 17x to 51x faster than KFIoU, GWD, or KLD, performing nearly as fast as simple $L_1$ regression.
  • 3D Detection Performance: On the Omni3D benchmark, MGIoU outperformed the state-of-the-art "Distangled-L1 + Chamfer" loss across all sub-datasets, yielding a 9.01% overall relative improvement in $AP_{3D}$.
  • Collision Avoidance: A specialized variant, MGIoU-, was applied to trajectory prediction on the Waymo Open Dataset. By minimizing overlap, it reduced collisions by 14% without requiring changes to the underlying model architecture.

Conclusion and Future Work

MGIoU provides a mathematically sound, scale-invariant, and highly efficient objective function for convex shape optimization. While currently limited to convex geometries, its ability to unify disparate detection tasks under a single loss function represents a significant step forward in geometric deep learning. Future research may extend this projection-based logic to non-convex shapes and more complex spatio-temporal optimization problems.

Summary updated

Abstract

Optimizing the similarity between parametric shapes is crucial for numerous computer vision tasks, where Intersection over Union (IoU) stands as the canonical measure. However, existing optimization methods exhibit significant shortcomings: regression-based losses like L1/L2 lack correlation with IoU, IoU-based losses are unstable and limited to simple shapes, and task-specific methods are computationally intensive and not generalizable accross domains. As a result, the current landscape of parametric shape objective functions has become scattered, with each domain proposing distinct IoU approximations. To address this, we unify the parametric shape optimization objective functions by introducing Marginalized Generalized IoU (MGIoU), a novel loss function that overcomes these challenges by projecting structured convex shapes onto their unique shape Normals to compute one-dimensional normalized GIoU. MGIoU offers a simple, efficient, fully differentiable approximation strongly correlated with IoU. We then extend MGIoU to MGIoU+ that supports optimizing unstructured convex shapes. Together, MGIoU and MGIoU+ unify parametric shape optimization across diverse applications. Experiments on standard benchmarks demonstrate that MGIoU and MGIoU+ consistently outperform existing losses while reducing loss computation latency by 10-40x. Additionally, MGIoU and MGIoU+ satisfy metric properties and scale-invariance, ensuring robustness as an objective function. We further propose MGIoU- for minimizing overlaps in tasks like collision-free trajectory prediction. Code is available at https://ldtho.github.io/MGIoU
BibTeX
@misc{le2025marginalized,
  author = {Duy-Tho Le and Trung Pham and Jianfei Cai and Hamid Rezatofighi},
  title = {{Marginalized Generalized IoU (MGIoU): A Unified Objective Function for Optimizing Any Convex Parametric Shapes}},
  year = {2025},
  eprint = {2504.16443},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2504.16443},
}
Figure