Conditional DETR V2: Efficient Detection Transformer with Box Queries

Xiaokang Chen, Fangyun Wei, Gang Zeng, Jingdong WangarXiv 2022 · DOI

Abstract

Conditional DETR V2 introduces a "box query" formulation and a memory-efficient Horizontal-Vertical Attention (HVA) mechanism to address the slow convergence and high computational complexity of the original Detection Transformer (DETR). By reformulating abstract object queries into image-dependent anchors and optimizing the encoder's attention, the model achieves significant improvements in training speed, inference efficiency, and detection accuracy on the COCO benchmark.

Introduction

Object detection has seen a paradigm shift with the introduction of the Detection Transformer (DETR), which treats detection as a set prediction problem and eliminates hand-crafted components like Non-Maximum Suppression (NMS). However, the original DETR architecture suffered from two primary drawbacks: notoriously slow convergence (often requiring 500 epochs) and quadratic computational complexity in the transformer encoder. While subsequent iterations like Conditional DETR improved spatial query handling, they still relied on static embeddings in the initial decoder layers.

Conditional DETR V2 addresses these bottlenecks by bridging the gap between transformers and traditional anchor-based detectors. It introduces image-dependent "box queries" and a novel attention mechanism that makes high-resolution transformer-based detection practical for real-world applications.

Methods

1. Box Queries from Image Content

In standard DETR, object queries are learnable positional embeddings. Conditional DETR V2 reformulates these into Box Queries, which are composed of a 2D reference point and a transformation representing scale and shape.

Overview of the Conditional DETR V2 architecture, highlighting the transition from image input to box query-based prediction.

Unlike previous models that use fixed parameters, V2 predicts these queries directly from the image content. The encoder identifies high-probability object locations to select reference points, while local feature embeddings are used to predict initial box scales. This approach effectively transforms abstract queries into dynamic, image-specific anchor boxes, combining the end-to-end benefits of transformers with the localized priors of classical detectors like Faster R-CNN.

2. Horizontal-Vertical Attention (HVA)

To mitigate the $O(N^2)$ complexity of global self-attention in the encoder, the authors propose Horizontal-Vertical Attention (HVA). This mechanism restricts attention to a query pixel's own row and column rather than the entire image.

The Horizontal-Vertical Attention (HVA) mechanism, which reduces complexity by performing row and column attention in parallel.

HVA utilizes 1D global average pooling to create shared key sets for rows and columns, maintaining a global field of view while reducing complexity from quadratic ($HW \times HW$) to linear ($HW \times (H+W)$). By performing row and column attention in parallel and concatenating the results, the model preserves distinct spatial information from both axes, leading to a performance boost over sequential axial attention methods.

Results and Discussion

The model was evaluated on the COCO 2017 dataset, demonstrating superior performance-efficiency trade-offs, particularly with high-resolution backbones.

  • Accuracy and Convergence: On a DC5-ResNet-50 backbone, V2 achieves 44.8 AP, outperforming the original Conditional DETR. Crucially, it reaches higher accuracy in just 50 epochs than the original DETR did in 500. When using an HRNet-W48 backbone, the model reaches 49.8 AP.
  • Efficiency: The HVA mechanism allows the model to run 1.6x faster (16.4 FPS) while reducing memory consumption by 74% compared to its predecessor.
  • Dynamic Scaling: Visualizations indicate that box queries allow the model to adaptively scale its attention. For instance, the attention spread is wide for large objects like buses and tight for smaller objects like cats.

Conclusion

Conditional DETR V2 successfully optimizes the DETR framework by introducing content-aware box queries and the efficient HVA mechanism. While the current work focuses on single-scale feature maps, the principles of image-dependent query initialization and linear-complexity attention provide a robust foundation for future extensions into multi-scale detection, instance segmentation, and video object tracking.

Summary updated

BibTeX
@misc{chen2022conditional,
  author = {Xiaokang Chen and Fangyun Wei and Gang Zeng and Jingdong Wang},
  title = {{Conditional DETR V2: Efficient Detection Transformer with Box Queries}},
  year = {2022},
  eprint = {2207.08914},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2207.08914},
}
Figure