hye-log

[부스트캠프 AI Tech]WEEK 09_DAY 42 본문

Boostcourse/AI Tech 4기

[부스트캠프 AI Tech]WEEK 09_DAY 42

iihye_ 2022. 11. 18. 04:02

🌿 개별학습


[4] Neck

1. Neck

1) Overview

(1) 구조

- input이 주어지고, backbone을 통과하면, 가장 마지막 feature map으로 RPN(Region Proposal Network)를 진행함

- backbone의 다른 feature map을 활용할 수는 없을까?

(2) Neck이 필요한 이유

- 다양한 크기의 객체를 더 잘 탐지하기 위해서

- low level feature : semantic 약함, localization 강함 <-> high level feature : sematic 강함, localization 약함

 

2) Feature Pyramid Network(FPN)

(1) backbone의 low level feature부터 high level feature까지의 RoI와 Prediction을 진행함 -> 작은 크기의 객체도 잘 탐지(2) FPN 이전의 try

Lin, T. Y., Dollár, P., Girshick, R., He, K., Hariharan, B., & Belongie, S. (2017). Feature pyramid networks for object detection. In  Proceedings of the IEEE conference on computer vision and pattern recognition  (pp. 2117-2125).
- Featurized image pyramid : 이미지의 크기를 점점 줄여봄- Single feature map : 이미지의 마지막 feature map으로 predict을 함- Pyramidal featue hierarchy : 이미지의 중간 feature map을 활용해서 predict 함 -> SSD(3) FPN의 특징- high level에서 low level로 semantic 정보 전달 필요- top-down path way 추가(4) Bottom-up : low level feature -> high level feature 로 전달
Lin, T. Y., Dollár, P., Girshick, R., He, K., Hariharan, B., & Belongie, S. (2017). Feature pyramid networks for object detection. In  Proceedings of the IEEE conference on computer vision and pattern recognition  (pp. 2117-2125).
(5) Top-down : high level feature -> low level feature 로 전달
Lin, T. Y., Dollár, P., Girshick, R., He, K., Hariharan, B., & Belongie, S. (2017). Feature pyramid networks for object detection. In  Proceedings of the IEEE conference on computer vision and pattern recognition  (pp. 2117-2125).
- Lateral connections : 1x1 conv를 통해서 채널 수를 늘려주고, 2x up을 통해서 upsampling 함
(6) Summary- 다양한 크기의 객체를 탐지하기 위해 설계 -> 여러 feature map을 사용함- Bottom-up에서 다양한 크기의 feature map을 추출 -> Top-down 방식으로 semantic 교환(7) Code- Build laterals : 각 feature map 마다 다른 채널을 맞춰주는 단계

# build laterals
laterals = [lateral_conv(inputs[i]) for i, lateral_conv in enumerate(self.lateral_convs)]

- Build Top-down : 채널을 맞춘 후 Top-down 형식으로 feature map 교환

# build top-down
for i in range(3, 0, -1):
    prev_shape = laterals[i - 1].shape[2:]
    laterals[i - 1] += F.interpolate(laterals[i], size=prev_shape)

- Build outputs : 최종 3×3 conv를 통과하여 RPN으로 들어갈 feature 완성

# build outputs
outs = [self.fpn_convs[i](laterals[i]) for i in range(4)]

 

3) Path Aggregation Network (PANet)

(1) FPN의 단점- Bottom-up 과정에서 figure 상으로 경로가 짧아보이지만, 실제 network(resnet)에서는 경로가 매우 긺 -> low level feature가 high level feature까지 잘 전달되나?(2) Bottom-up Path Augmentation : Top-down 후에 Bottop-up을 한 번 더 추가 -> low-level feature를 high level feature로 전달

Liu, S., Qi, L., Qin, H., Shi, J., & Jia, J. (2018). Path aggregation network for instance segmentation. In  Proceedings of the IEEE conference on computer vision and pattern recognition  (pp. 8759-8768).
(3) Adaptive Feature Pooling : 모든 feature map에서 RoI Pooling을 하고 fc를 만들어 내자!
(4) Code- FPN : Top-down에 3×3 conv layer 통과하는 것까지 동일

# build outputs
inter_outs = [self.fpn_convs[i](laterals[i]) for i in range(4)]

- Add bottom-up : FPN 통과 후, bottom-up path를 더해줌

# part 2: add bottom-up path
for i in range(3):
	inter_outs[i + 1] += self.downsample_convs[i](inter_outs[i])

- Build outputs : 이후 FPN과 마찬가지로 학습을 위해 3×3 conv layer 통과

outs = []
outs.append(inter_outs[0])
outs.extend([self.pafpn_convs[i - 1](inter_outs[i]) for i in range(1, 4)])

 

2. After Neck

1) DetectoRS

(1) Motivation : Looking and thinking twice -> 반복적으로 여러 번 하면 좋은 성능이 나오는가?

- Region proposal networks(RPN) : 객체가 있었던 위치를 생각하고 class, box를 뽑아냄

- Cascade R-CNN : RoI Pooling을 여러 번 함

(2) 주요 구성

- Recursive Feature Pyramid(RFP) : backbone에서 neck으로, neck에서 backbone으로 정보를 전달함

Qiao, S., Chen, L. C., & Yuille, A. (2021). Detectors: Detecting objects with recursive feature pyramid and switchable atrous convolution. In  Proceedings of the IEEE/CVF conference on computer vision and pattern recognition  (pp. 10213-10224).

- Swtichable Atrous Convolution(SAC) 

(3) Atrous Convolution : conv filter에 dilation rate(빈 칸)을 주고 convolution 연산을 수행

https://github.com/vdumoulin/conv_arithmetic

 

2) Bi-directional Feature Pyramid (BiFPN)

(1) Pipeline

Tan, M., Pang, R., & Le, Q. V. (2020). Efficientdet: Scalable and efficient object detection. In  Proceedings of the IEEE/CVF conference on computer vision and pattern recognition  (pp. 10781-10790).

- feature map이 한 곳에서만 오는 노드를 제거함 -> parameter와 flops 수를 줄일 수 있음

(2) Weighted Feature Fusion : 각 feature 별로 가중치를 부여한 뒤 summation을 진행

 

3) NASFPN

(1) Motivation

- 단방향(top->bottom, bottom->top) 보다 좋은 방법이 있을까? -> NAS(Neural Architecture Search)

(2) Architecture

- 그림 다 이해 못함 -> "NAS를 통해서 FPN을 찾았다"

Ghiasi, G., Lin, T. Y., & Le, Q. V. (2019). Nas-fpn: Learning scalable feature pyramid architecture for object detection. In  Proceedings of the IEEE/CVF conference on computer vision and pattern recognition  (pp. 7036-7045).
Ghiasi, G., Lin, T. Y., & Le, Q. V. (2019). Nas-fpn: Learning scalable feature pyramid architecture for object detection. In  Proceedings of the IEEE/CVF conference on computer vision and pattern recognition  (pp. 7036-7045).

(3) 단점

- COCO dataset, Resnet 기준으로 찾았기 때문에 범용적이지 못함

- High search cost -> 데이터셋, 모델이 달라지면 새로 찾아야 함

 

4) AugFPN

(1) Overview

- FPN의 문제점 : 서로 다른 level feature 간의 semantic 차이, highest feature map의 정보 손실, 한 개의 feature map에서 RoI 생성

(2) 주요 구성

- Consistent Supervision

- Residual Feature Augmentation

- Soft RoI Selection

(3) Residual Feature Augementation

- P5의 경우 information loss가 발생할 수 있음 -> 정보 보완이 필요 

- M6를 만들어서 P5에 Top-down 방식으로 정보를 제공함(Residual Feature Augmentation)

(4) Soft RoI Selection

Guo, C., Fan, B., Zhang, Q., Xiang, S., & Pan, C. (2020). Augfpn: Improving multi-scale feature learning for object detection. In  Proceedings of the IEEE/CVF conference on computer vision and pattern recognition  (pp. 12595-12604).

- 모든 scale feature map에서 RoI projection 진행 후 RoI Pooling

- channe-wise multiply로 가중치 계산 후 가중치 합 사용

- PANet의 amx pooling을 학습 가능한 가중 합으로 대체함



🌿 오늘의 회고

오전부터 Neck 강의를 들었다. 사실 강의 듣기 전에 모델을 하나 돌려보려고 했는데 config 파일로 이루어져 있고 이 값들을 수정해야 하는데, 값들을 수정하려면 detection 관련 지식들이 필요한거 같아서 강의를 다 듣고 모델을 돌려보는 게 좋을거 같았다.. 그런데 생각보다 Neck에 대한 개념 강의는 얼마 되지 않지만, 이를 응용한 후속 연구에 대한 설명도 있어서 강의가 생각보다 길어졌다. 강의의 모든 내용을 소화할 수 있다면 좋겠지만, 어느 순간부터 모든 강의를 이해하는 것보다 필요한 것을 빠르게 이해하고 넘어가는 게 좋을거 같다는 생각이 든다.. 특히나 지금까지 대회가 겹쳤을 때라면..!!(ㅠㅠㅠ) 멘토님이 조언해주신 대로 모델 학습을 진행해봤는데, 처음에는 오류가 나서 이리저리 해결하다가 학습이 시작되서 너무 신났다!! 하지만 성능이 생각보다... 정말... 안나와서... 흐ㅡㄱㅎ그... 너무 슬펐다. 다른 optimizer나 learning rate를 조절해가면서 성능이 진~짜 안 나오는건지 확인해 봐야겠다. 대회 게시판을 참고해서 eda를 해봤는데 생각보다 outlier도 있고, class도 다양하고, box도 다양하고, 뭐 데이터가 그냥 다 다양해서 어디서부터 해결해야할지 잘 모르겠다 그래도 하나씩... 차근차근... 해쳐나가는걸로..😵‍💫😵‍💫

728x90
Comments