2024.12.10 - [Study/computer vision] - DETR : End-to-End Object Detection with Transformers
RT-DETR : DETRs Beat YOLOs on Real-time Object Detection
Zhao, Yian, et al. "Detrs beat yolos on real-time object detection." Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. 2024.
2024년에 따끈따끈하게 올라온 DETR을 Real-Time Object Detection하기 위해 나온 논문이다.
(accept는 2024년이지만 아카이브는 2023년에 올라온 것 같다)
1. Introduction
현재 Real-Time Object Detector 중 가장 유명한 것은 YOLO,
그러나 이러한 Detector들은 post-processing 과정에서 NMS를 요구하는데, 이는 추론 속도 저하 및 속도와 정확성 모두에 불안정을 초래하는 hyper parameter를 통해 계산된다.
이러한 문제를 해결하기 위해 Transformer기반의 DETR이 나왔으나,
높은 cost로 인해 Real-Time Detector 요구 조건을 충족하지 못한다.
(이전 DeTR paper를 리뷰했을 때, DeTR의 가장 큰 문제점은 작은 scale에 대한 정확도가 낮은것 이는 multi-scale 처리하지않고 ResNet을 통해 하나의 Featrue map을 추출하여서 그런 것)
1. 최초의 Real-Time End-to-End Object Detector인 RT-DETR을 제안
2. multi-scale features를 빠르게 처리하기 위해 efficient hybrid encoder 설계
-> inference speed 향상
3. encoder feature(object query)의 low localization confidence가 낮은 경우를 피하기 위해, uncertainty-minimal query selection 제안
-> accuracy 향상
2. Related Work
skip
3. End-to-end Speed of Detectors
3.1. Analysis of NMS
NMS를 수많은 박스들 중 최적의 박스를 찾는 post-processing algorithm
NMS는 confidence threshold와 IoU threshold가 필요(hyperparameter)
box가 갖는 score가 confidence threshold이하이면 filtered out,
이후 박스의 IoU threshold 넘는 box들 중에 low score를 제거
이 process는 모든 category의 box가 처리될 때 까지 반복적으로 수행
따라서 NMX excution time은 box의 수와 두 threshold에 의해 결정
-> 이를 관찰하기 위해 YOLOv5(anchor-based)와 YOLOv8(anchor-free)을 분석
분석에 있어서 confidence threshold를 0.001부터 0.25까지 샘플링하여 두 detector의 남아있는 상자를 계산
이를 통해 NMS는 hyper parameter에 취약하다는 것을 언급
-> 당연하게도, confidence threshold가 높을수록 초기 fitering되는 것이 많을 것이다.
추가적으로, COCO val2017 dataset에 대해 YOLOv8 정확도 평가
다양한 hyperparameter에서의 NMS 연산의 실행시간 테스트
T4-GPU에서 TensorRT FP16으로 수행
이 또한 hyper parameter에 취약하다는 것을 증명하기 위한 실험이다.
Confience threshold를 감소시킬수록 남는 box가 많아지니까 NMS시간 증가
IoU Threshold를 증가시킬수록 시간이 증가하는 이유는?
IoU Threshold가 높을수록 NMS를 수행해야될 overlapping box의 수가 적어진다. 그런데 왜 시간이 증가할까?
-> 한 번의 iteration에서 overlapping box 후보군이 줄어드니까 비교해야되는 box는 적지만, iteration을 많이 해야됨
3.2. End-to-end Speed Benchmark
Real-Time detector의 end-to-end speed를 공정하게 비교하기 위해 benchmark 수렵했다.
NMS의 execution time이 input에 (hyperparamter) 영향을 미치는 것을 고려할 때,
benchmark dataset을 선택하고, avg execution time을 계산하는 것이 필요하다.
accuracy에 상응하는 NMS threshold를 기준으로 detector의 avg Inference time을 test
(빨간박스 anchor-based, 초록박스 anchor-free)
결론적으로, anchor-free detector와 anchor-based detector를 비교했을 때,
동등한 accuracy라면, anchor-free detector가 우수한 성능을 발휘한다.
-> why? anchor-free가 anchor-based에 비해 적은 NMS 시간을 요구하기 때문에(해당 test에서는 NMS 시간 약 3배차이)
-> 왜 더 적은 NMS시간을 요구? NMS에 사용되는 prediction box 수가 anchor-based가 많으므로
4. The Real-time DETR
4.1. Model Overview
Backbone, efficient hybird encoder, auxiliary prediction heads를 갖춘 transformer decoder로 구성
1. backbone 마지막 세 단계 {S3,S4,S5}에서 추출한 feature를 encoder 입력
2. efficient hybird encoder는 multi-scale feature{S3,S4,S5}를
intra-scale features interaction과 cross-scale feature fusion을 통해 image feature sequence 변환
3. uncertainty-minial query selection을 통해 encoder feature 중
고정된 수의 feature를 selection하여 decoder의 초기 object query로 사용
4. decoder with auxiliary predection heads는
object query를 반복적으로 optimize하여 categories와 boxes를 생성
4.2. Efficient Hybrid Encoder
Computational bottlenet analysis
multi scale feature은 train convergence를 가속화하고 성능을 향상시킨다.
그러나, deformable attention이 cost를 줄이더라고,
증가한 sequence의 길이(multi-scale feature로 인한)는 encoder bottleneck 유발
Encoder는 Deformable-DETR에서 전체 연상량의 49%를 차지하지만, AP에 기여하는 비율은 11%에 불과하다.
이러한 bottleneck을 극복하기 위해, 우리는 multi-scale Transformer Encdoer에 존재하는 계산 중복성을 분석했다.
직관적으로, low-level feature에서 high-level feature이 추출되기에,
결합된 multi-scale feature에서 상호작용을 수행하는 것은 불필요(중복되므로).
그러므로, 우리는 cross-scale feature interaction이 비효율적임을 증명하기 위해
다양한 유형의 encoder를 가진 variants를 설계했다.
A : DINO-Deformble-R50에서 multi-scale Transformer Encoder 제거한 변형 모델
A->B : A에 single-scale Transformer Encoder를 삽입하여 scale 내 상호작용 수행,
multi-scale feature는 encoder sharing, 결과를 concat
B->C : B에 cross-scale feature fusion을 도입하여 concat된 feature를 multi-scale transformer encoder에 입력하여
intra-scale 및 cross-scale faeture interation 수행
C->D : intra-scale interation에는 single-scale Transformer,
cross-scale fusion에는 PANet-style structure를 사용하여 encoder decouple
D->E : efficient hybrid encoder를 채택하여 D의 intra-sclae interaction, cross-scale fusion 강화
Hybird design
위의 분석을 바탕으로, "Attention-based Intra-scale Feature Interaction (AIFI)"와 "CNN-based Cross-scale Feature Fusion (CCFF)"라는 두 가지로 구성된 hybrid encoder 제안
AIFI는 single-scale Transformer encoder 사용하여 S5에서만 scale interaction 수행
D 기반으로 computational cost 줄임.
-> high-level features에 대해 self-attention 연산을 수행함으로써
conceptual entity 간의 connection을 포착하여 subsequent module이 object를 localization, recognition하는 데 도움
-> low-level features의 intra-scale interation은 semantic concept이 부족, high-level feature와 duplication, confusion 위험
위를 검증하기 위해, 모델 D에서 S5에서만 intra-scale interaction수행
실험 결과 D 대비 35% 더 빠른 latency와 0.4% AP 향상 달성
CCFF는 cross-scale fusion module을 기반으로 optimized,
fusion path에 여러 funsion blocks 삽입.
fusion block은 두 인접 scale feature를 새 feature로 fusion하는 역할
1x1 conv를 통해 weight wised sum하고, N개의 RepBlocks를 통해 feature fusion
fusion에서는 두 경로의 출력을 element-wise add
Hybrid Encoder를 수식적으로 나타내면 다음과 같다.
(multi-head self-attention, Reshape는 S5와 동일한 모양으로 flatten 역연산)
4.3. Uncertainty-minimal Query Selection
기존 query initialization 방식을 optimize하기 위해서 다양한 방법이 제안됐다.
하지만, 기존 방식들은 confidence score를 사용하여 상위 K개의 feature selection을 선택하여 initalization
하지만, category와 localization을 동시에 모델링해야 한다.
우리는 detector의 uncertainty를 category uncertainty와 localization uncertainty로 정의한다.
Eq(2)에 따르면, feature uncertainty U는 localiation P와 classification C의 predicted distridution 차이로 정의한다.
D차원의 feature vector를 사용했다.
(동인한 feature vector x에 대해서 localization과 classification 정보간의 일관성을 알 기 위해 해당 식을 사용한 것 같다.)
Query의 uncertainty를 optimization하기 위해, loss function uncertainty를 통합하여,
graident기반 optimization 수행한다.
예측된 box와 실제 box, 예측된 class와 실제 class와 uncertainty를 더해서 optimization한다.
(3개에 대해서는 어떻게 수행하는 지 추가적인 학습을 해봐야될 듯하다.)
Effectiveness analysis
COCO val2017 dataset에 대해 selection된 feature들의 classification score, IoU score 시각화
clasification score가 0.5보다 큰 feature에 대한 scatter plotting
보라색 점은 우리의 방식으로 query selection feature, 초록색 점은 기존 query selection feature
오른쪽 상단 즉, IoU score와 Classification Score가 놓을 수록 feature quality가 높아진다.
즉, 예측된 category와 box가 실제 object를 설명할 가능성이 높다.
가장 큰 특징은 보라색점이 오른쪽 상단에 집중되어 있으며, Vanilla의 경우 오른쪽 하단에 집중된다.
또한 보라색 점이 초록색 점보다 138% 더 많으며, 이는 classification score가 0.5보다 작은, 낮은 quality feature가 초록색 점에 있다는 것이다.
추가적으로, 두 score모두 0.5보다 높은 feature는 보라색점이 초록색 점보다 120% 더 많았다.
(결론적으로, 이는 uncertainty minimal query selection이 효과적임을 입증한다.)
4.4. Scaled RT-DETR
Real-Time Detector는 다양한 시나리오에 맞추기 위해 여러 scale model을 제공한다.
RT-DETR 역시 다양한 scale model 지원한다.
구체적으로, hybrid encoder의 경우 embeding dimension과 channel수를 조정하여 width를 제어하고,
Transformer Layer와 RepBlock의 수를 조정하여 depth를 제어한다.
decoder의 weight, depth는 object quries의 수와 decoder layer 수를 조작하여 제어 가능하다.
위의 표를 확인함으로써 마지막 몇 개의 decoder layer를 제거하는 것은 정확도 영향을 최소화하였지만,
latency를 크게 향상시킴을 보인다.
'Study > computer vision' 카테고리의 다른 글
BoostTrack++: using tracklet information to detect more objects in multiple object tracking (1) | 2024.12.13 |
---|---|
RT-DETR project (0) | 2024.12.13 |
DETR : Inference code review (0) | 2024.12.10 |
DETR : End-to-End Object Detection with Transformers (0) | 2024.12.10 |
[ResNet] Skip connection 제대로 이해 (1) | 2024.12.07 |