Introduction
The Detection Transformer (DETR) introduced a streamlined end-to-end approach to object detection, eliminating the need for complex hand-crafted components like anchor generation and non-maximum suppression. Despite its elegance, DETR's practical utility was hindered by an exceptionally slow training process, often requiring 500 epochs to achieve competitive performance. This slow convergence stems from the decoder's co-attention mechanism, where object queries must learn to localize objects from scratch across the entire image. This paper presents Spatially Modulated Co-Attention (SMCA), a novel module that significantly accelerates training by introducing a spatial inductive bias.
Spatially Modulated Co-Attention (SMCA)
The core limitation of standard DETR is that its attention mechanism is initially "blind" to spatial structure. SMCA addresses this by modulating the co-attention with a dynamic Gaussian prior. For each object query, the model predicts a center and scale to generate a 2D Gaussian weight map. This map acts as a spatial constraint, effectively "telling" the query to focus its attention on a specific region of interest.
The architecture incorporates several key refinements:
- Multi-head Modulation: Each attention head can independently predict spatial offsets and scales, allowing the model to attend to different parts of an object simultaneously.
- Multi-scale Integration: To handle objects of varying sizes, the encoder processes features at multiple resolutions. SMCA utilizes an efficient "intra-scale" then "multi-scale" self-attention design to manage the increased computational load.
- Automatic Scale Selection: The decoder learns to weigh features from different resolutions, ensuring that small objects are detected using high-resolution maps while large objects utilize coarser features.
Experimental Results
The authors evaluated SMCA on the COCO 2017 detection benchmark. The results demonstrate a dramatic improvement in training efficiency without sacrificing accuracy.
As shown in the convergence plots, SMCA achieves 41.0 mAP in just 50 epochs, a milestone that the original DETR takes hundreds of epochs to reach. When trained for 108 epochs with multi-scale features, SMCA reaches 45.6 mAP, surpassing the 500-epoch performance of the DETR-DC5 baseline (43.3 mAP). This represents a 10x acceleration in convergence speed.
Discussion and Conclusion
The success of SMCA highlights the importance of re-introducing minimal inductive biases into Transformer-based architectures. While pure Transformers are flexible, the spatial nature of object detection benefits immensely from a "local-first" attention strategy. SMCA provides a "plug-and-play" solution that maintains the global context of the original DETR while focusing its learning capacity where it matters most. Future work may involve extending SMCA to other query-based vision tasks, such as instance segmentation or video object tracking, where spatial priors are equally critical for efficient learning.
Summary updated