End-to-End Object Detection with Adaptive Clustering Transformer

Minghang Zheng, Peng Gao, Renrui Zhang, Kunchang Li, Hongsheng Li, Hao Dong

TL;DR

The Adaptive Clustering Transformer (ACT) significantly reduces the computational burden of the Detection Transformer (DETR) by clustering redundant query features using Locality Sensitive Hashing (LSH). It transforms the quadratic $O(N^2)$ complexity of self-attention into a much leaner $O(NK)$ process, serving as a "drop-in" replacement that requires no retraining to achieve a superior balance between accuracy and inference speed.

What Problem Does This Paper Address?

Object detection has traditionally relied on complex, hand-crafted components like non-maximum suppression (NMS) and anchor generation. The Detection Transformer (DETR) simplified this by treating detection as a direct set-prediction problem. However, DETR has a major "Achilles' heel": its computational cost.

Because DETR uses a standard Transformer encoder, every pixel-sized feature must attend to every other feature. This results in quadratic complexity relative to the input resolution. To detect small objects, you need high-resolution images, but high resolution makes the Transformer encoder prohibitively slow and memory-intensive. While other "efficient Transformers" exist, most require changing the model architecture and retraining from scratch—a process that, for DETR, can take nearly 2,000 GPU hours.

Methods

The authors introduce Adaptive Clustering Transformer (ACT) to solve this bottleneck without forcing a total model redesign. The core idea is to exploit redundancy in the encoder's attention maps.

  1. Adaptive Clustering via LSH: The model uses Exact Euclidean Locality Sensitive Hashing (E2LSH) to group similar query features into clusters. LSH is efficient because it ensures that "nearby" vectors in high-dimensional space are likely to fall into the same hash bucket.
  2. Prototype Interaction: Instead of calculating attention for every single query, ACT calculates a "prototype" (the average) for each cluster. It then computes the attention interaction only between these prototypes and the keys.
  3. Feature Broadcasting: Once the prototype features are updated via attention, the results are broadcast back to all original queries in that cluster based on their Euclidean distance.
  4. Multi-Task Knowledge Distillation (MTKD): While ACT works "out of the box" without training, the authors found they could close the small remaining accuracy gap by using a pre-trained DETR as a "teacher" to fine-tune the ACT-equipped model for a few epochs.

Datasets

The researchers evaluated their method on the COCO 2017 detection dataset, which includes 118k training images and 5k validation images. This is the standard benchmark for modern object detection, featuring a wide variety of object scales and categories.

Key Insights and Ideas

  • Attention Redundancy: The "aha moment" of the paper is the observation that features that are semantically similar and spatially close produce nearly identical attention maps. Computing all of them is a waste of resources.
  • The "Drop-in" Advantage: Unlike many efficiency-focused papers that require training a new model from scratch, ACT is compatible with pre-trained DETR weights. This makes it a practical tool for practitioners who don't have thousands of GPU hours to spare.
  • Layer-wise Adaptivity: The authors observed that as you go deeper into the Transformer encoder, features become more redundant. ACT naturally adapts to this; it uses fewer prototypes in deeper layers, further saving computation where it's most effective.
  • Regression Sensitivity: Interestingly, the authors found that the bounding box regression branch is more sensitive to approximation errors than the classification branch. Their distillation strategy (MTKD) specifically targets this by focusing on transferring regression knowledge.

Key Results

ACT delivers significant efficiency gains with minimal impact on performance:

  • Computation: It reduces the encoder's FLOPs from 73.4 Gflops to 58.2 Gflops (excluding the backbone).
  • Accuracy: Without any retraining, the drop in Average Precision (AP) is only 0.7%. With a few epochs of MTKD fine-tuning, that gap shrinks to a negligible 0.2%.
  • Real-world Speed: On an Nvidia GTX TITAN X, inference time per image dropped from 0.246s to 0.183s (for $L=16$ rounds), and memory usage was cut by roughly 38% (from 1862MiB to 1142MiB).
  • Scale Performance: ACT is particularly strong at detecting large and medium objects, where it sometimes matches or even slightly exceeds the baseline DETR performance.

Limitations and Future Work

While ACT is highly effective for the encoder, the paper focuses less on the decoder side of DETR. Additionally, while the method is "training-free," the best results still require a few epochs of distillation.

For future work, the authors suggest:

  • Exploring the performance of ACT when a model is trained with it from the very beginning (from scratch).
  • Applying ACT to multi-scale feature architectures, such as Feature Pyramid Networks (FPN), to see if the clustering benefits scale across different resolutions.

Summary updated

BibTeX
@inproceedings{zheng2021end,
  author = {Minghang Zheng and Peng Gao and Renrui Zhang and Kunchang Li and Hongsheng Li and Hao Dong},
  title = {{End-to-End Object Detection with Adaptive Clustering Transformer}},
  booktitle = {BMVC},
  year = {2021},
}
Figure