Abstract
The design of the query is crucial for the performance of DETR and its variants. Each query consists of two components: a content part and a positional one. Traditionally, the content query is initialized with a zero or learnable embedding, lacking essential content information and resulting in sub-optimal performance. In this paper, we introduce a novel plug-and-play module, Self-Adaptive Content Query (SACQ), to address this limitation. The SACQ module utilizes features from the transformer encoder to generate content queries via self-attention pooling. This allows candidate queries to adapt to the input image, resulting in a more comprehensive content prior and better focus on target objects. However, this improved concentration poses a challenge for the training process that utilizes the Hungarian matching, which selects only a single candidate and suppresses other similar ones. To overcome this, we propose a query aggregation strategy to cooperate with SACQ. It merges similar predicted candidates from different queries, easing the optimization. Our extensive experiments on the COCO dataset demonstrate the effectiveness of our proposed approaches across six different DETR's variants with multiple configurations, achieving an average improvement of over 1.0 AP.
Introduction
In the DEtection TRansformer (DETR) architecture, object queries are fundamental to the detection process. These queries are composed of a positional component and a content component. While significant research has focused on optimizing positional queries, the content component is often initialized as a "blank slate"—either as zeros or generic learnable embeddings. This lack of image-specific prior information often leads to slow training convergence and sub-optimal detection performance.
Furthermore, the standard one-to-one (Hungarian) matching strategy used in DETR training can introduce optimization instability. When multiple queries accurately identify the same object, the algorithm forces the model to select only one and suppress the others. This "winner-take-all" approach can be brittle, especially during early training phases, as the model struggles to consistently assign a single query to a specific target.
Methodology
To address these challenges, we propose two "plug-and-play" modules designed to enhance query initialization and stabilize training.
Self-Adaptive Content Query (SACQ)
The SACQ module replaces static initialization with image-aware content queries. It employs a Self-Attention Pooling Module (SAPM) that processes features from the transformer encoder. By generating attention maps, the SAPM "softly" isolates potential objects and pools these features to initialize content queries. This ensures that queries enter the decoder with a meaningful content prior tailored to the specific input image.
Query Aggregation (QA)
To mitigate the instability of one-to-one matching, we introduce Query Aggregation. Instead of forcing a competition between similar high-quality queries, this strategy merges predicted candidates from different queries into a single unified result before the matching process. Similarity is calculated based on category prediction (using KL divergence) and bounding box overlap (using Intersection over Union, IoU). This collaborative approach simplifies the loss landscape for the optimizer.
Experimental Evaluation
We evaluated the proposed modules on the COCO 2017 dataset, the industry standard for object detection. To demonstrate the generalizability of our approach, we integrated SACQ and QA into six prominent DETR variants, including Deformable-DETR, DINO, and DN-DETR.
Results and Discussion
The integration of SACQ and QA yielded consistent performance gains across all tested architectures:
- Deformable-DETR: Achieved a significant improvement of +1.5 AP (increasing from 45.4 to 46.9).
- DN-DETR: Observed a boost of +1.3 AP.
- DINO: Even the state-of-the-art DINO model improved by +0.4 AP, reaching 49.4 AP.
Qualitative analysis confirms that SACQ enables the model to focus more precisely on target objects. As shown in the comparison below, the proposed method results in highly concentrated query points compared to the more scattered attention seen in vanilla implementations.
Computational Considerations
While effective, these modules introduce a modest computational overhead. For Deformable-DETR, training time increased from 37.3 to 44.5 hours on 8 GPUs. Additionally, there is a slight decrease in inference speed; for instance, DINO's performance dropped from 18.5 to 15.7 FPS. Future work will focus on optimizing these modules to reduce the impact on inference latency.
Conclusion
By introducing image-aware content query initialization (SACQ) and a collaborative query matching strategy (QA), we have demonstrated a robust method for improving DETR-based object detectors. These modules are orthogonal to existing improvements and provide a significant performance boost across various state-of-the-art architectures.
Summary updated