An Extendable, Efficient and Effective Transformer-based Object Detector

Hwanjun Song, Deqing Sun, Sanghyuk Chun, Varun Jampani, Dongyoon Han, Byeongho Heo, Wonjae Kim, Ming-Hsuan YangarXiv 2022

Abstract

Transformers have been widely used in numerous vision problems especially for visual recognition and detection. Detection transformers are the first fully end-to-end learning systems for object detection, while vision transformers are the first fully transformer-based architecture for image classification. In this paper, we integrate Vision and Detection Transformers (ViDT) to construct an effective and efficient object detector. ViDT introduces a reconfigured attention module to extend the recent Swin Transformer to be a standalone object detector, followed by a computationally efficient transformer decoder that exploits multi-scale features and auxiliary techniques essential to boost the detection performance without much increase in computational load. In addition, we extend it to ViDT+ to support joint-task learning for object detection and instance segmentation. Extensive evaluation results on the Microsoft COCO benchmark dataset demonstrate that ViDT obtains the best AP and latency trade-off among existing fully transformer-based object detectors, and its extended ViDT+ achieves 53.2AP owing to its high scalability for large models.

Introduction

Object detection has traditionally relied on complex, hand-engineered components like anchor boxes and Non-Maximum Suppression (NMS). While the Detection Transformer (DETR) introduced a fully end-to-end system, it suffered from high computational costs due to its reliance on a heavy transformer "neck" (encoder-decoder) following a CNN backbone. Conversely, Vision Transformers (ViT) like the Swin Transformer have excelled in classification but face challenges in detection, such as quadratic complexity or poor multi-scale feature utilization.

ViDT (Vision and Detection Transformers) addresses these issues by synergizing these two worlds into a single, highly efficient standalone detector. It eliminates the heavy neck encoder and reconfigures the attention mechanism to handle detection tokens directly within the backbone.

Architecture and Methods

The core of ViDT is the integration of detection capabilities directly into the vision transformer backbone, creating a more streamlined pipeline compared to previous architectures.

Comparison of object detection architectures: DETR, YOLOS, and the proposed ViDT.

Reconfigured Attention Module (RAM)

ViDT introduces the RAM to manage interactions between image patches and detection tokens efficiently. Instead of a standard global attention block, RAM decomposes the operation into three specialized components:

  1. [PATCH] × [PATCH]: Local self-attention for spatial features, preserving the linear complexity of the Swin Transformer.
  2. [DET] × [DET]: Global self-attention among a small set of learnable detection tokens.
  3. [DET] × [PATCH]: Cross-attention allowing detection tokens to attend to image features.

By activating cross-attention only in the final stage of the backbone, ViDT significantly reduces computational overhead while maintaining high accuracy.

Encoder-free Neck and ViDT+ Extensions

Unlike traditional detection transformers that use a heavy encoder in the "neck," ViDT relies on its RAM-equipped backbone to extract detection-ready features. For multi-tasking, the extended ViDT+ incorporates an Efficient Pyramid Feature Fusion (EPFF) module for multi-scale mixing and a Unified Query Representation (UQR) module to encode segmentation masks into the frequency domain using Discrete Cosine Transform (DCT).

Key Results and Performance

Evaluated on the Microsoft COCO 2017 benchmark, ViDT demonstrates a state-of-the-art trade-off between accuracy (Average Precision) and inference speed (latency).

AP vs. Latency trade-off on COCO dataset. ViDT models (red) show superior efficiency compared to existing transformer-based detectors.
  • Efficiency: The ViDT (Swin-nano) model achieves 40.4 AP with only 15M parameters, making it significantly lighter and faster than the original DETR (41M parameters, 42.0 AP).
  • High Accuracy: The large-scale ViDT+ (Swin-base) reaches 53.2 AP, outperforming many larger, more complex models.
  • Latency: ViDT is approximately 2x faster than Deformable DETR at comparable accuracy levels.

Conclusion

ViDT represents a significant step forward in making transformer-based object detectors practical for real-world applications. By treating the backbone as the detector and optimizing token interactions, it achieves high performance without the typical computational burden of heavy "neck" architectures. While the frequency-domain encoding in the UQR module can lose fine-grained details for very small objects, ViDT's scalability and efficiency make it a robust foundation for future vision-transformer research.

Summary updated

BibTeX
@misc{song2022extendable,
  author = {Hwanjun Song and Deqing Sun and Sanghyuk Chun and Varun Jampani and Dongyoon Han and Byeongho Heo and Wonjae Kim and Ming-Hsuan Yang},
  title = {{An Extendable, Efficient and Effective Transformer-based Object Detector}},
  year = {2022},
  eprint = {2204.07962},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2204.07962},
}
Figure