Sparse DETR: Efficient End-to-End Object Detection with Learnable Sparsity
DETR is the first end-to-end object detector using a transformer encoder-decoder architecture and demonstrates competitive performance but low computational efficiency on high resolution feature maps. The subsequent work, Deformable DETR, enhances the efficiency of DETR by replacing dense attention with deformable attention, which achieves 10x faster convergence and improved performance. Deformable DETR uses the multiscale feature to ameliorate performance, however, the number of encoder tokens increases by 20x compared to DETR, and the computation cost of the encoder attention remains a bottleneck. In our preliminary experiment, we observe that the detection performance hardly deteriorates even if only a part of the encoder token is updated. Inspired by this observation, we propose Sparse DETR that selectively updates only the tokens expected to be referenced by the decoder, thus help the model effectively detect objects. In addition, we show that applying an auxiliary detection loss on the selected tokens in the encoder improves the performance while minimizing computational overhead. We validate that Sparse DETR achieves better performance than Deformable DETR even with only 10% encoder tokens on the COCO dataset. Albeit only the encoder tokens are sparsified, the total computation cost decreases by 38% and the frames per second (FPS) increases by 42% compared to Deformable DETR. Code is available at https://github.com/kakaobrain/sparse-detr
Problem:: Deformable DETR에서 DETR보다 Encoder Token 수의 급격한 증가로 인해 Encoder가 연산의 병목이 되는 문제
Solution:: 중요한 토큰만 업데이트하는 Sparsification/Decoder를 이용한 토큰 선택 기준점 제안
Novelty:: Deformable DETR의 Key Sampling과 함께 사용 가능한 Query Sparsification 제안/Encoder에 Layerwise Aux Loss 사용
Note:: Deformable DETR에 Encoder Aux Loss, Topk Decoder Query의 개념을 처음 도입한 것으로 보임/Objectness Score가 제안한 DAM 보다 효과적이지 않음을 보인 것과 Encoder에서 추출한 Query와 Decoder가 참조하는 Query간의 Corr를 측정한게 인상깊음
Summary
Motivation
- Transformer 기반 DETR은 Competitive한 성능을 제공하지만, 특히 높은 해상도 특징 맵 처리에서 효율성이 크게 저하됨
- 이를 개선한 Deformable DETR은 Deformable Attention을 통해 효율성을 높였지만, 다중 스케일 Feature 사용으로 인해 Encoder Token 개수가 급격히 증가하여 연산 비용 문제가 다시 발생
- 저자들의 분석에 따르면, Decoder는 실제로 Encoder의 모든 토큰을 참조하지 않고 일부(약 45%)만 활용함
- 결과적으로, Decoder가 실제로 참조하는 토큰만 Encoder에서 처리하면, 계산 효율성을 크게 개선할 수 있음
Method

중요한 것: Scoring Network, Encoder Aux. Head, Encoder 내부 중요 쿼리들만 Self-Attn의 쿼리로 이용
- 핵심 아이디어: Decoder가 참조할 가능성이 높은 Encoder 토큰만 선택적으로 업데이트함 (Scoring Network, DAM, Encoder Sparsification)
Key Idea

- 두 가지의 주요 토큰 선택 방식:
1. Objectness Score (OS): Backbone Feature 기반으로 개체성을 판단(Aux. Head 이용)해 토큰 선택 → Sub-Optimal (Decoder와 관련 X)
2. Decoder Cross-Attention Map (DAM): Decoder가 실제 참조하는 토큰에 대한 중요도를 예측하는 별도의 Scoring Network를 학습해 토큰 선택 - Decoder의 Attention Weight를 이용해 DAM 생성 → Flatten하여 Scoring Network의 라벨로 이용
- Encoder에서 선택된 Query와 DAM의 Query와의 Corr를 비교하면 DAM을 사용한 경우가 OS보다 높음
- 생각보다 학습 초기에 불안정성이 없음
- 해당 방식으로 토큰 개수를 줄여도 성능 하락이 없음

- Encoder Sparsification: 중요도 상위 토큰들만 Encoder에서 Self-Attention 및 FFN을 통해 업데이트하고, 나머지 토큰은 업데이트 없이 통과함

- Deformable DETR이 연산되는 Key의 개수를 줄였다면, Sparse DETR은 Query의 개수를 줄임
- 나머지 토큰은 Query로 이용되지 않을 뿐 Key와 Value로 이용됨
- 계산 복잡도 감소: DETR의
→ Deformable DETR의 → Sparse DETR의 로 개선 ( 는 Sparsified 토큰 수, 는 Attention Key 개수, )
Method 검증
- COCO 2017 검증 데이터셋에서 다양한 DETR 계열 모델들과 성능 비교:
- Deformable DETR 대비 10% Encoder Token만 사용하고도 더 높은 성능 달성 (ResNet-50 Backbone: 46.0 AP, Swin-T Backbone: 48.2 AP)
- Encoder Token 30% 이상 사용 시 모든 기존 방법 대비 우수한 성능을 달성하면서 연산 비용도 낮음
- Deformable DETR 대비 전체 계산 비용을 최대 38% 감소, 초당 프레임 처리속도(FPS)는 최대 42% 증가시킴
- Encoder Auxiliary Loss 적용 시 성능 안정성 및 깊은 구조의 학습 성능 개선 확인
- Dynamic Sparsification을 통해 Inference 단계에서 유연한 모델 적용 가능성 입증
- 추론시 인코더에 사용되는 토큰 수를 전체의 10%까지 줄여도 50%에 비해 2.5mAP만 감소됨