Less is More: Focus Attention for Efficient DETR

Link
Abstract

DETR-like models have significantly boosted the performance of detectors and even outperformed classical convolutional models. However, all tokens are treated equally without discrimination brings a redundant computational burden in the traditional encoder structure. The recent sparsification strategies exploit a subset of informative tokens to reduce attention complexity maintaining performance through the sparse encoder. But these methods tend to rely on unreliable model statistics. Moreover, simply reducing the token population hinders the detection performance to a large extent, limiting the application of these sparse models. We propose Focus-DETR, which focuses attention on more informative tokens for a better trade-off between computation efficiency and model accuracy. Specifically, we reconstruct the encoder with dual attention, which includes a token scoring mechanism that considers both localization and category semantic information of the objects from multiscale feature maps. We efficiently abandon the background queries and enhance the semantic interaction of the finegrained object queries based on the scores. Compared with the state-of-the-art sparse DETR-like detectors under the same setting, our Focus-DETR gets comparable complexity while achieving 50.4AP (+2.2) on COCO. The code is available at torch-version† and mindspore-version‡.

Synth

Problem:: DETR은 모든 토큰을 사용한 Encoder의 연산량이 너무 높음/기존의 토큰 선별 방법은 부정확함/Deformable Attention은 장거리 정보 결합에 한계가 있음

Solution:: 정확한 Foreground 토큰 선별(Top-down Score Modulation)/세부 범주 기반 추가 토큰 정제(Multi-category Score Predictor)/장거리 정보 결합 강화(Dual Attention)

Novelty:: Encoder의 Layer별로 토큰을 선택하여 연산량 감소/Encoder에서 Background도 이용한 Cross-Attention 방식 도입

Note:: Sparse DETR을 먼저 읽었어야 했을 듯

Summary

Motivation

Method

file-20250316213904565.png

  1. Multi Scale Feature에 대해 Top-down Score Modulation으로 모든 Level의 Feature에 대해 Foreground Score 추정
    • Backbone에서 나온 서로 다른 스케일의 다중 특징맵(Multi-scale features)을 이용
    • 고해상도에서 저해상도 특징맵 순서로 하향식(top-down) 으로 점수를 전달하여, 높은 semantic 정보를 가진 고수준(high-level)의 특징맵을 이용해 저수준(low-level)의 특징맵에 존재하는 토큰의 Foreground 가능성 점수를 보완해줌
    • 이를 통해 전체 스케일(Level)의 특징맵에서 보다 정확한 Foreground Score를 추정 가능
  2. Foreground Score를 이용해 각 레이어마다 특정 개수의 Foreground Token 추출
    • 추정된 Foreground Score 기반으로 각 레이어(layer)의 특징맵에서 일정 비율의 토큰을 Foreground로 판단하고 추출
    • 논문에서의 실제 비율은 각 레이어별로 미리 정해졌으며, 다음과 같음:
      • 레이어별 유지 토큰 비율: [1,0.8,0.6,0.6,0.4,0.2]×0.5×Total Num of Tokens
      • 예시로 가장 높은 레이어(첫 번째 레이어)는 전체 토큰의 절반(50%), 가장 낮은 레이어(마지막 레이어)는 전체 토큰의 10%(0.2×0.5=0.1)만 유지하여 Foreground 토큰을 점차 줄이는 방식을 사용함
    • 이 과정을 통해 각 레이어에서 더 효율적인 연산 수행
  3. Multi-Category Score Predictor를 이용해 Foreground Token에 대한 Category Probability 추정
    • 앞서 선정된 Foreground Token을 대상으로, 추가적인 분류(Category) 점수를 예측하여 더욱 정밀한 Fine-grained Token 선별을 수행
    • Category Score Predictor는 각 토큰이 특정 객체 범주(Category)에 해당될 확률을 추정하여 보다 의미 있는 토큰 선별을 도와줌
  4. Foreground Score와 Category Probability로 Encoder의 Dual Attention의 Self-Attention을 수행할 Fine-grained Token 추출
    • 앞서 얻은 두 가지 점수를 결합하여 최종적인 토큰 중요도(pj) 계산: pj=sj×cj
      • sj: Foreground Score
      • cj: Category Probability
    • 위의 중요도 점수(pj)로 전체 Foreground Token 중에서 상위 토큰 (논문에서는 기본적으로 300개)을 선택하고, 이를 "Fine-grained Token"이라 부름
    • 이 토큰들이 추가적인 의미론적 연산을 수행하기 위해 Dual Attention의 Self-Attention 과정에서 사용됨
  5. Encoding 과정이 끝난 모든 토큰들 중 Top 900개를 Decoder의 Query로 이용
    • Encoder의 Dual Attention 과정을 통해 계산된 모든 토큰 중, 최종적으로 importance 점수가 높은 상위 900개를 선택하여 Decoder의 Query로 전달
    • 이를 통해 불필요한 많은 배경 정보를 배제하고 중요한 정보만으로 효율적인 Decoder 계산이 가능

Foreground Token Selector

ll(i,j)={1,(x,y)DBboxdl(i,j)[rbl,rel]0,(x,y)DBboxdl(i,j)[rbl,rel] dl(i,j)=max(h2,w2)

Top-down Score Modulation

file-20250316225234677.png|475

Multi-Category Score Predictor

Dual Attention

Method 검증