Marginalized Generalized IoU (MGIoU): Unifying Parametric Shape Optimization

1 Monash University   2 NVIDIA

Abstract

Optimising the similarity between parametric shapes is crucial across computer-vision tasks. Intersection-over-Union (IoU) is the canonical metric, yet existing objective functions either correlate weakly with IoU, are limited to simple shapes, or are computationally expensive. Marginalised Generalised IoU (MGIoU) addresses these limitations by projecting structured convex shapes onto their unique normals and computing a 1-D normalised GIoU. MGIoU is simple, differentiable, efficient, and highly correlated with true IoU. We extend it to MGIoU+ for unstructured convex shapes, unifying shape optimisation across diverse domains. Experiments show consistent performance gains and 10-40 × faster loss computation. Finally, MGIoU- minimises overlaps, enabling collision-avoidance objectives such as safer trajectory prediction.

MGIoU and MGIoU+

Visualisation of MGIoU and MGIoU+ optimising various 2-D and 3-D shapes. Observe how each shape gradually adjusts to minimise the loss.

Identifying Shape Normals and compute MGIOU

Given two arbitrary shapes \(P, G \subseteq \mathbb{R}^D\) (with \(D=2\) in 2-D and \(D=3\) in 3-D) and vertex sets \(\mathbf P\in\mathbb R^{N_P\times D}\), \(\mathbf G\in\mathbb R^{N_G\times D}\), MGIoU first builds a set of unique shape normals \(\mathcal A\). In 2-D polygons the normals are 90° rotations of edge vectors; in ellipses they align with the semi-axes; in 3-D they become face normals. Duplicate or parallel directions are pruned, leaving a compact basis (e.g. a rotated rectangle needs only two normals, a cuboid needs three), reducing abundant computations.

For every Normal \(\mathbf a\in\mathcal A\) and the projection of \(P\) and \(G\) onto \(\mathbf a\), we compute the 1-D GIoU:

One-dimensional IoU, GIoU and MGIoU equations

where \(C_{a}\) is the smallest 1-D interval enclosing the projections \(P_{a}\) and \(G_{a}\) onto normal \(\mathbf a\).

MGIoU and MGIoU+ thus compute a marginalised one-dimensional version of GIoU along all unique normals, yielding a fast, scale-invariant loss.

Metric Properties of MGIoU

Owing to its derivation from the Jaccard index via the Generalised IoU formulation, the MGIoU loss \(\mathcal{L}_{\text{MGIoU}} = (1-\operatorname{MGIoU})/2\) fulfils all axioms of a metric and remains scale-invariant:

One-dimensional IoU, GIoU and MGIoU equations

These guarantees endow the loss with theoretical robustness and a tight correlation with Intersection-over-Union, ensuring consistent optimisation behaviour across varied shapes, scales, and applications.

Qualitative Results on 2-D and 3-D Datasets

MGIoU-

MGIoU- converts MGIoU into a repulsion loss by (i) taking the smallest 1-D GIoU across the set of shared shape normals and (ii) passing that value through a ReLU activation to stop penalising as soon as the shapes are non-overlapping.

\[ K_{ij}^t = \operatorname{ReLU}\!\Bigl( \min_{\mathbf a\in\mathcal A_{ij}^t} \operatorname{GIoU}^{1D}(P_{\mathbf a},G_{\mathbf a}) \Bigr), \]

where \(\mathcal A_{ij}^t\) contains the unique normals of the two convex shapes at time t.

\[ \boxed{ \mathcal L_{\text{MGIoU}^-} = \sum_{i=1}^{B} s_i \sum_{t=1}^{T} m_i^t \sum_{\substack{j=1\\ j\ne i}}^{B} K_{ij}^t } \]

where \(B\) is the number of agents, \(T\) is the number of time-steps, zero loss is achieved only when every pair of visible agents is non-overlapping at all timesteps, making the objective ideally suited to collision-free trajectory prediction, layout design (without considering temporal information \(T\)), and any task requiring differentiable overlap avoidance.

Visualisation of MGIoU- progressively pushing shapes apart to minimise overlap.

Qualitative Results on Waymo Dataset

Prediction / GT legend

Qualitative Results Waymo dataset, showing that MGIoU- can be used to optimise the trajectory of multiple agents in a scene, reducing the overlap/collision in predicted trajectories of road agents.

BibTeX

@article{le2025marginalized,
  title={Marginalized Generalized IoU (MGIoU): A Unified Objective Function for Optimizing Any Convex Parametric Shapes},
  author={Le, Duy-Tho and Pham, Trung and Cai, Jianfei and Rezatofighi, Hamid},
  journal={arXiv preprint arXiv:2504.16443},
  year={2025}
}