D^2ETR: Decoder-Only DETR with Computationally Efficient Cross-Scale Attention

Junyu Lin, Xiaofeng Mao, Yuefeng Chen, Lei Xu, Yuan He, Hui Xue

Abstract

DETR is the first fully end-to-end detector that predicts a final set of predictions without post-processing. However, it suffers from problems such as low performance and slow convergence. A series of works aim to tackle these issues in different ways, but the computational cost is yet expensive due to the sophisticated encoder-decoder architecture. To alleviate this issue, we propose a decoder-only detector called D^2ETR. In the absence of encoder, the decoder directly attends to the fine-fused feature maps generated by the Transformer backbone with a novel computationally efficient cross-scale attention module. D^2ETR demonstrates low computational complexity and high detection accuracy in evaluations on the COCO benchmark, outperforming DETR and its variants.

Introduction

The DEtection TRansformer (DETR) revolutionized object detection by introducing a truly end-to-end pipeline, eliminating the need for hand-crafted components like anchors and Non-Maximum Suppression (NMS). Despite its elegance, DETR faces two significant challenges: high computational complexity and slow convergence. The Transformer encoder's self-attention mechanism requires quadratic memory and compute relative to the number of spatial locations, which becomes prohibitive for high-resolution or multi-scale feature maps. Furthermore, the original DETR required 500 epochs to converge, a substantial barrier for practical application.

While subsequent variants like Deformable DETR addressed convergence and small object detection, they often increased architectural complexity. $D^2ETR$ (Decoder-only DETR) challenges the necessity of the standalone encoder, proposing a more streamlined approach.

Methods: The Decoder-Only Architecture

The core innovation of $D^2ETR$ is shifting the responsibility of feature refinement and fusion from a separate encoder to the backbone itself. This is achieved through the Computationally Efficient Cross-scale Attention (CECA) module.

Architecture comparison between standard DETR and the proposed D^2ETR, including the internal structure of the fusing stage.

Computationally Efficient Cross-scale Attention (CECA)

Instead of global self-attention across all scales, CECA utilizes a hierarchical "fusing stage." It treats high-level (coarse) feature maps as queries and lower-level (fine) feature maps as keys and values. This asymmetric interaction allows the model to capture fine-grained details necessary for localization without the computational explosion associated with dense pixel-to-pixel attention across scales.

Backbone Integration and Auxiliary Losses

The model employs a Pyramid Vision Transformer (PVT) as the backbone, with CECA modules interleaved between stages to generate "fine-fused" features. To further enhance performance, the authors introduce:

  • Token Labeling Loss: Encourages patch-wise classification within the backbone to learn more robust features.
  • Location-aware Loss: Predicts IoU and "centerness" for each bounding box to align classification confidence with localization accuracy during inference.

Key Results

Evaluated on the COCO 2017 benchmark, $D^2ETR$ demonstrates superior efficiency and accuracy compared to established baselines.

Performance comparison of D^2ETR against various DETR-based models on the COCO benchmark.
  • Efficiency: $D^2ETR$ (with PVT2) achieves 43.2 AP with only 82 GFLOPs, surpassing the original DETR (42.0 AP / 86 GFLOPs) while requiring only 50 training epochs—a 10x reduction in training time.
  • State-of-the-Art Performance: The "Deformable $D^2ETR$" variant reaches 50.0 AP with 93 GFLOPs. In comparison, standard Deformable DETR achieves 44.5 AP while consuming nearly double the computation (173 GFLOPs).
  • Throughput: When optimized with TensorRT on a V100 GPU, $D^2ETR$ nearly doubles the inference throughput of Deformable DETR (355 vs 187 images/sec).

Discussion and Insights

The success of $D^2ETR$ suggests that the Transformer encoder in traditional DETR models primarily serves as a feature refiner, a role that can be more efficiently integrated into the backbone. The asymmetric attention in CECA proves that semantic information from higher layers can effectively "query" fine details from lower layers, maintaining high localization accuracy at a fraction of the cost.

Limitations and Future Work

While $D^2ETR$ reduces total GFLOPs, the sequential nature of the fusing stages introduces some latency constraints, though these can be mitigated through parallel execution. Additionally, the current design is optimized for hierarchical Vision Transformers like PVT. Future research may explore adapting CECA for non-pyramidal backbones or extending the unified backbone-fusion approach to tasks like instance segmentation.

Summary updated

BibTeX
@misc{lin2022d,
  author = {Junyu Lin and Xiaofeng Mao and Yuefeng Chen and Lei Xu and Yuan He and Hui Xue},
  title = {{D^2ETR: Decoder-Only DETR with Computationally Efficient Cross-Scale Attention}},
  year = {2022},
  eprint = {2203.00860},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2203.00860},
}
Figure