• Focal Loss for Dense Object Detection
  • ResNet + Feature Pyramid Net

논문링크 : https://arxiv.org/abs/1708.02002

 

Contribution

 one-stage detector에서 class imbalance 문제를 해결하기 위한 새로운 loss function 제시 +  당시 sota

 

Motivation

Class Imbalance : 이미지 안에서 positive sample과 negative sample 갯수의  불균형

RetinaNet 저자는 one-stage detector의 낮은 정확도의 원인은 객체와 배경 클래스 간의 불균형이 원인이라는 것을 발견

Two-stage detector 계열의 모델은 class imbalance 문제를 해결하기 위해 두 가지 측면에서의 해결책을 적용했습니다. 첫 번째로 two-stage cascade, 즉 region proposals를 추려내는 방법을 적용하여 대부분의 background sample을 걸러주는 방법을 사용했습니다. 이에 대한 예시로 selective search, edgeboxes, deepmask, RPN 등이 있습니다. 두 번째로 positive/negative sample의 수를 적절하게 유지하는 sampling heuristic 방법을 적용했습니다. hard negative mining, OHEM 등이 이러한 방법에 해당합니다. 

하지만 위에서 언급된 two-stage detector에서의 class imbalance 문제를 해결하는 방법은 one-stage detector에 적용하기 어렵습니다.  one-stage detector는 region proposal 과정 없이, 전체 이미지를 빽빽하게 순회하면서 sampling하는 dense sampling 방법을 수행하기 때문에 two-stage detector에 비해 훨씬 더 많은 후보 영역을 생성합니다. 다시 말해 class imbalance 문제가 two-stage detector보다 더 심각합니다. 기존의 sampling heuristic 방법을 적용해도 여전히 배경으로 쉽게 분류된 sample이 압도적으로 많기 때문에 학습이 비효율적으로 진행됩니다.
[출처 : https://herbwood.tistory.com/19]                                                                                       

적은 수의 hard negative, 많은 수의 easy negative가 있는 상태에서 easy negative가 detector의 학습을 망침

 

Core idea

 Focal Loss는 예측하기 쉬운 example에는 0에 가까운 loss를 부여하고, 예측하기 어려운 negative example에는 기존보다 높은 loss를 부여한다. 

 

Cross Entropy

y: Ground truth, p:Prediction

  • p_t가 0.5이상이면 분류하기 쉬운 easy example
  • easy example은 loss값이 작지만, 엄청나게 많아지면 대부분의 loss를 차지하게 됨 -> hard example의 비중 감소

 

Focal Loss

모든 data에 대해, loss에 같은 가중치를 주지 말자

  • cross entropy loss에 인자를 하나 추가함. 이 인자는 'modulating factor'라 부름. easy example의 영향을 감소시키고 hard example에 집중하도록 만든다.
  • '감마'는 하이퍼파라미터. '감마'를 통해 easy/hard example의 가중치를 조절한다.
  • example이 잘못 분류됬으면 pt는 낮은 값을 갖습니다. pt가 낮으면 modulating factor은 1에 가까운 값을 갖게 됩니다. 따라서 loss는 커지게 됩니다.
  • example이 예측하기 쉽다면 pt는 큰 값을 가질 것입니다. (1- pt)에서 pt가 크면 0에 가까운 값을 지니게 됩니다. 따라서 loss도 0에 가까운 값을 갖게 됩니다.
  • 즉, pt에 따라 loss값을 조절하여 easy example의 영향을 낮추고 hard example의 영향을 높인다.

 

Model architecture

  • ResNet-FPN을 backnone으로 하여 2개의 sub-network를 사용
  • 첫 번째 sub-network는 object classification을 수행, 두 번째 sub-network는 bounding box regression을 수행

<이미지 출처 : https://csm-kr.tistory.com/5>

 

1. Feature Pyramid Network

  • ResNet구조에 FPN을 backbone으로 사용
  • 각 pyramid level에서 1000개의 top-scoring perdiction을 가진 box를 사용. 모든 level에서 box가 병합되고, NMS를 수행하여 sub-network로 전달됨

2. Anchors

  • 각 pyramid level에 aspect ratio={1:2, 1:1, 2:1}, size={20,21/3,22/320,21/3,22/3}을 사용하여, 총 9개의 anchor를 할당함
  • 각 Anchor은 one-hot K vertor (K개의 class중 해당하는 class는 1, 나머지는 0)와 바운딩박스 offset 4개를 할당. 따라서 하나의 Anchor에는 K*4의 vector가 할당됨
  • Anchor은 IOU가 0.5이상이면 ground-thuth에 할당. IoU가 0~0.4이면 배경으로 할당. 0.4~0.5 IOU를 가진 anchor는 무시함

<이미지 출처 : https://csm-kr.tistory.com/5>

3. Classification Subnet

  • Anchor의 object class를 예측하는 network
  • K는 class의 갯수, A는 anchor의 갯수
  • classification subnet의 출력값에 Focal Loss를 적용

4. Box Regression Subnet

  •  anchor와 ground-truth의 offset을 계산하는 network

 

<이미지 출처 : https://csm-kr.tistory.com/5>

 

 

Reference

(원본논문) Focal Loss for Dense Object Detection

https://csm-kr.tistory.com/5

https://deep-learning-study.tistory.com/504

https://jackyoon5737.tistory.com/219

반응형

'머신러닝_딥러닝 > Object Detection' 카테고리의 다른 글

(논문리뷰) Yolo v3 (2018)  (0) 2021.09.13
(논문리뷰) Mask R-CNN  (0) 2021.09.13
(논문리뷰) OHEM (2016)  (0) 2021.09.13
(논문리뷰) Feature Pyramid Net, FPN (2017)  (0) 2021.09.13
(논문리뷰) SSD (2016)  (0) 2021.09.13

+ Recent posts