본문 바로가기
AI Paper Review

[논문 리뷰] Computer Vision - Fast R-CNN

by coding-choonsik 2023. 9. 6.
728x90
반응형
SMALL

📃 [논문]  https://arxiv.org/pdf/1504.08083.pdf

 

  • 기존 R-CNN 모델은 학습 시간이 매우 오래 걸리며, detection 속도 역시, 이미지 한 장당 47초나 걸려 매우 느린 추론 속도
  • 3가지의 모델(AlexNet, linear SVM, Bounding box regressor)을 독립적으로 학습시켜, 연산을 공유하거나 가중치값을 update하는 것이 불가능하다는 문제
  • 기존 R-CNN 모델보다 속도면에서의 큰 개선을 보인 모델

 

Preview

  • Fast R-CNN은 단 1장의 이미지를 입력받으며, region proposals의 크기를 warp시킬 필요 없이 RoI(Region of Interest) pooling을 통해 고정된 크기의 feature vector를 fully connected layer(이하 fc layer)에 전달
  • multi-task loss를 사용하여 모델을 개별적으로 학습시킬 필요 없이 한 번에 학습시킴 → 학습 및 detection 시간이 크게 감소

Main Ideas

 

1. RoI(Region of Interest) Pooling

  • feature map에서 region proposals에 해당하는 관심 영역(Region of Interest)을 지정한 크기의 grid로 나눈 후 max pooling을 수행하는 방법
  • 각 channel별로 독립적으로 수행하며, 이 같은 방법을 통해 고정된 크기의 feature map을 출력하는 것이 가능

  • 원본 이미지를 CNN 모델에 통과시켜 feature map을 얻음
  • 동시에 원본 이미지에 대해 Selective search 알고리즘을 적용하여 region proposals를 얻음
  • feature map에서 각 region proposals에 해당하는 영역을 추출
    • RoI Projection을 통해 가능
    • Selective search를 통해 얻은 region proposals는 sub-sampling 과정을 거치지 않은 반면, 원본 이미지의 feature map은 sub-sampling 과정을 여러 번 거쳐 크기가 작아짐
    • 작아진 feature map에서 region proposals이 encode(표현)하고 있는 부분을 찾기 위해 작아진 feature map에 맞게 region proposals를 투영해주는 과정이 필
    • region proposal의 크기와 중심 좌표를 sub sampling ratio에 맞게 변경시켜줌으로써 가능
  • 추출한 RoI feature map을 지정한 sub-window의 크기에 맞게 grid로 나눔
  • grid의 각 셀에 대하여 max pooling을 수행하여 고정된 크기의 feature map을 얻음
💡 region proposal의 크기가 서로 달라도 고정된 크기의 feature mapn을 얻을 수 있음!

 

 

2. Multi-task loss

  • Fast R-CNN 모델에서는 feature vector를 multi-task loss를 사용하여 Classifier와 Bounding box regressior을 동시에 학습시킴
  • 각각의 RoI에 대해 multi task loss를 사용하여 학습

 

3. Hierarchical Sampling(계층적 샘플링)

  • R-CNN 모델은 학습 시 region proposal이 서로 다른 이미지에서 추출되고, 이로 인해 학습 시 연산을 공유할 수 없다는 단점을 보완하고자 학습 시 feature sharing을 가능하게 하는 Hierarchical sampling 방법을 제시
  • SGD mini-batch를 구성할 때 N개의 이미지를 sampling하고, 총 R개의 region proposal을 사용한다고 할 때, 각 이미지로부터 R/N개의 region proposals를 sampling하는 방법
  • 같은 이미지에서 추출된 region proposals끼리는 forward, backward propogation 시, 연산과 메모리를 공유할 수 있음

 

4. Truncated SVD

  • detection 시간을 감소시키기 위해 **Truncated SVD(Singular Vector Decomposition)**을 통해 fc layer를 압축하는 방법을 제시
  • 네트워크를 효율적으로 압축하는 것이 가능하며, 논문의 저자는 Truncated SVD를 통해 detection 시간이 30% 정도 감소

 


Training Fast R-CNN

1. Initializing pre-trained network

  • feature map을 추출하기 위해 VGG16 모델을 사용
    • VGG16 모델의 마지막 max pooling layer를 RoI pooling layer로 대체
      • 이 때 RoI pooling을 통해 출력되는 feature map의 크기인 H, W는 후속 fc layer와 호환 가능하도록 크기인 7x7로 설정
    • 네트워크의 마지막 fc layer를 2개의 fc layer로 대체
      • 첫 번째 fc layer는 K개의 class와 배경을 포함한 (K+1)개의 output unit을 가지는 Classifier
      • 두 번째 fc layer는 각 class별로 bounding box의 좌표를 조정하여 (K+1) * 4개의 output unit을 가지는 bounding box regressor

    • conv layer3까지의 가중치값은 **고정(freeze)**시켜주고, 이후 layer(conv layer4~ fc layer3)까지의 가중치값이 학습될 수 있도록 **fine tuning(**논문에서는 fc layer만 fine tuning했을 때보다 conv layer까지 포함시켜 학습시켰을 때 더 좋은 성능을 보임)
    • 네트워크가 원본 이미지와 selective search 알고리즘을 통해 추출된 region proposals 집합을 입력으로 받을 수 있도록 변환
     

2. Region Proposal by Selective Search

  • 원본 이미지에 대하여 Selective search 알고리즘을 적용하여 미리 region proposals를 추출
 💡 Input : 224x224x3 sized image
Process : feature extraction by VGG16
Output : 14x14x512 feature maps

 

3. Feature extraction(~layer13 pre-pooling) by VGG16

  • VGG16 모델에 224x224x3 크기의 원본 이미지를 입력하고, layer13까지의 feature map을 추출
  • 마지막 pooling을 수행하기 전에 14x14 크기의 feature map 512개가 출력
 💡 Input : 224x224x3 sized image
Process : feature extraction by VGG16
Output : 14x14x512 feature maps

 

4. Max pooling by RoI pooling

  • region proposals를 layer13을 통해 출력된 feature map에 대하여 RoI projection을 진행한 후, RoI pooling을 수행
  • 고정된 7x7 크기의 feature map을 추출
💡 Input : 14x14 sized 512 feature maps, 2000 region proposals
Process : RoI pooling
Output : 7x7x512 feature maps

 

5. Feature vector extraction by FC layers

  • region proposal별로 7x7x512(=25088)의 feature map을 flatten한 후 fc layer에 입력하여 fc layer를 통해 4096 크기의 feature vector를 얻음
💡 Input : 7x7x512 sized feature map
Process : feature extraction by fc layers
Output : 4096 sized feature vector

 

6. Class predictation by Classifier

  • 4096 크기의 feature vector를 K개의 class와 배경을 포함하여 (K+1)개의 output unit을 가진 fc layer에 입력
  • 하나의 이미지에서 하나의 region proposal에 대한 class prediction을 출력
💡 Input : 4096 sized feature vector
Process : class prediction by Classifier
Output : (K+1) sized vector(class score)

 

7. Detailed localization by Bounding box regressor

  • 4096 크기의 feature vector를 class별로 bounding box의 좌표를 예측하도록 (K+1) x 4개의 output unit을 가진 fc layer에 입력
  • 하나의 이미지에서 하나의 region proposal에 대한 class별로 조정된 bounding box 좌표값을 출력
💡 Input : 4096 sized feature vector
Process : Detailed localization by Bounding box regressor
Output : (K+1) x 4 sized vector

 

8. Train Classifier and Bounding box regressor by Multi-task loss

  • Multi-task loss를 사용하여 하나의 region proposal에 대한 Classifier와 Bounding box regressor의 loss를 반환
  • Back propagation(역전파)을 통해 두 모델(Classifier, Bounding box regressor)을 한 번에 학습시킴
💡 Input : (K+1) sized vector(class score), (K+1) x 4 sized vector
Process : calculate loss by Multi-task loss function
Output : loss(Log loss + Smooth L1 loss)

 


Detection Fast-RCNN

  • 실제 Detection 시 4096 크기의 feature vector를 출력하는 fc layer에 Truncated SVD를 적용
  • 예측한 bounding box에 대하여 Non maximum suppression 알고리즘이 추가되어 최적의 bounding box만을 출력

 

 

 

728x90
반응형
LIST