Learning Dynamic Query Combinations for Transformer-based Object Detection and Segmentation

Yiming Cui, Linjie Yang, Haichao Yu

Abstract

Standard Transformer-based detectors (DETR) rely on a fixed set of learned "object queries" to identify and localize objects within an image. These static queries act as global priors, which may not be optimal for the diverse spatial and semantic distributions found in different images. This paper introduces the Dynamic Query (DQ) module, a lightweight plug-in that generates image-dependent queries by taking a convex combination of a larger pool of basic queries. By constraining dynamic queries to a meaningful subspace, the method achieves consistent performance gains across object detection, instance segmentation, and panoptic segmentation with negligible computational overhead.

Introduction

In the DEtection TRansformer (DETR) paradigm, object queries are the core mechanism for interacting with image features to predict object categories and bounding boxes. In most state-of-the-art models, these queries are static: they are learned during training and remain fixed during inference. While effective, static queries represent a fixed global distribution (e.g., "expect a person in the center") that does not adapt to the specific context of an individual image, such as the difference between a crowded urban scene and a sparse landscape.

Previous attempts to create dynamic queries often involved generating them directly from image features. However, these methods frequently suffer from optimization difficulties because the generated queries may fall outside the "meaningful subspace" that the transformer decoder has learned to process. This paper proposes a novel approach: generating Modulated Queries through the convex combination of a static query basis.

The Dynamic Query Module

The authors' approach is grounded in the empirical observation that random convex combinations of learned, high-quality queries still function effectively as queries. This suggests that the space of "valid" queries is a convex subspace. The proposed Dynamic Query (DQ) module exploits this via four key components:

  1. Basic Queries ($Q^B$): The model maintains a large pool of static, learned queries (e.g., 1,200), which serve as the basis for the dynamic generation.
  2. Dynamic Coefficients ($W^D$): A lightweight mini-network—consisting of Global Average Pooling, a two-layer MLP, and a Softmax activation—analyzes the input image's global feature map to produce a set of image-specific coefficients.
  3. Convex Combination: The module groups the basic queries and applies the dynamic coefficients to calculate a weighted sum. This produces a smaller, optimized set of Modulated Queries ($Q^M$, e.g., 300) tailored to the specific image content.
  4. Dual-Branch Training: To ensure the basic queries remain a robust basis, the model is trained using a dual-branch strategy. One branch uses the modulated queries, while the other uses the original basic queries. During inference, the basic query branch is discarded, ensuring no additional cost beyond the tiny MLP.

Experimental Results

The researchers evaluated the DQ module across several competitive benchmarks, including MS COCO (2017), CityScapes, and YouTube-VIS-2019. The results demonstrate that the DQ module provides a consistent "plug-and-play" boost to existing architectures:

  • Object Detection (MS COCO): Integrating DQ into DAB-Deformable-DETR with a ResNet-50 backbone yielded a 1.6% mAP improvement. When paired with a Swin-Base backbone, the improvement was 1.1% mAP. Deformable-DETR saw an even larger jump of 2.3% mAP with a Swin-Base backbone.
  • Segmentation: On the CityScapes dataset, DQ-Mask2Former improved Panoptic Quality (PQ) by 1.1 points.
  • Video Instance Segmentation: DQ-SeqFormer achieved a 1.9% mAP boost on the YouTube-VIS benchmark.
  • Efficiency: The module is highly efficient; inference speed (FPS) decreased by less than 4%, making it suitable for real-time applications.

Analysis and Insights

Subspace Constraint

By forcing dynamic queries to be convex combinations of static ones, the authors ensure the queries stay within a range the decoder can interpret. This constraint makes the model significantly easier to train compared to methods that generate queries from scratch, which often struggle with convergence.

Semantic Awareness

To understand what the DQ module learns, the authors used t-SNE to visualize the learned coefficients ($W^D$). They found that images with similar semantic content (e.g., "transportation" or "wild animals") naturally clustered together. This indicates that the model successfully adjusts its search strategy based on high-level image semantics, selecting different combinations of basic queries for different types of scenes.

Conclusion and Future Work

The Dynamic Query module offers a simple yet effective way to transition from static to image-adaptive object detection. By leveraging the concept of a query subspace, the authors provide a method that is both easy to optimize and computationally efficient. While the current implementation uses simple sequential grouping for basic queries, future work could explore more sophisticated ways to structure the query pool or apply the dynamic combination philosophy to other components of the Transformer architecture.

Summary updated

BibTeX
@inproceedings{cui2023learning,
  author = {Yiming Cui and Linjie Yang and Haichao Yu},
  title = {{Learning Dynamic Query Combinations for Transformer-based Object Detection and Segmentation}},
  booktitle = {International Conference on Machine Learning},
  year = {2023},
  url = {https://openreview.net/forum?id=SAgKrtDkn1},
}
Figure