안녕하세요~

 

이번글에서는 RCNN의 단점을 극복하고자 나온 SPP-Net object detection 모델에 대해서 알아보도록 할게요~

 

 

 

<1. Motivation>

 

 

1) Too CNN operation

 

RCNN은 selective search를 통해 대략 2000개의 candidate bounding box를 만들어내요. 

 

 

 

2000개의 candidate bounding box를 CNN에 입력하게되면 하나의 이미지에 대해서 학습하거나 detection(test) 하는데 굉장한 시간이 소요된답니다. 실시간 성능은 꿈에도 못 꾸겠죠..

 

<사진1>

 

 

 

2) Distortion by warping

 

RCNN은 candidate bounding box 내의 feature를 뽑아내기 위해 AlexNet을 이용한다고 했어요. 그래서 candidate bounding box가 227x227 size로 warping 된다고 설명드린바 있습니다.

 

그런데 이 warping 과정에서 이미지 왜곡현상이 일어날수가 있어요 . 만약 실제 객체의 aspect ratio 비율과 warping된 객체의 aspect ratio가 warping 때문에 굉장히 차이가 나게되면 두 이미지는 아예 다른 이미지가 될 확률이 높아요.

 

 

 

 

<사진2. Distortion되는 경우>

 

 

 

 

 

 

 

 

<2. Architecture>

 

 

1) Reduce CNN operation

 

RCNN에서는 입력 이미지에서부터 region proposal 방식을 이용해 candidate bounding box를 선별하고 모든 candidate bounding box에 대해서 CNN 작업을해요. 만약 2000개의 candidate bounding box가 나오게 되면 2000번의 CNN과정을 수행하게 되는거죠.

 

하지만 SPP-Net은 입력이미지를 먼저 CNN 작업을 진행하고 다섯 번째 conv layer에 도달한 feature map을 기반으로 region proposal 방식을 적용해 candidate bounding box를 선별하게되요. 이렇게되면 CNN 연산은 1번이 되는데요. 즉 RCNN 2000번 -> SPP-Net 1번 의 CNN operation 절감효과가 나타나기 때문에 굉장히 시간을 빠르게 단축할 수 있게되요. 

 

<사진3>

 

<사진4>

 

 

 

 

2) Remove warping process and avoid distortion

 

먼저, SPP-Net은 warping으로 인한 distortion을 없애주고자 'spatial pyramid pooling'이라는 개념을 이용합니다. RCNN과의 차이를 보면 warping하는 부분이 없어지고 spatial pyramid pooling이 추가된것을 볼 수 있을거에요. Spatial pyramid pooling 과정이 어떻게 warping 과정을 없앨 수 있었는지 살펴보도록 하겠습니다.

 

 

[Spatial Pyramid Pooling process]

 

First step

: Conv layer 5까지 거친 feature map에 대해서 region proposal 방식(ex: selective search)을 적용하여 candidate bounding box를 선별해 줍니다. 보통 candidate bounding box를 RoI (region of interests)라고 표현하기 때문에 앞으로 candidate bounding box는 RoI라고 칭하겠습니다. 

 

 

 

Second step

: RoI영역에서 Spatial Pyramid Pooling 알고리즘을 적용합니다. 알고리즘 순서는 아래와 같습니다.

 

 

 

 

[RoI feature is pooled by Spatial bin]

- RoI feature가 13x13인 경우

- 3x3 spaital bin을 사용한다는건 pool 연산을 통해 3x3 feature map을 얻겠단 소리

- 아래의 RoI feature에서 3x3 feature map을 얻기 위해서는 window size=5, stride=4 로 설정

- 위와 같이 설정된 window (아래 작은 네모박스)는 이동하면서 max pooling 연산을 적용

 

 

 

: 그런데 보통 3x3 spatial bin을 사용하지 않고, SPP-Net은 1x1, 2x2, 4x4 spatial bin을 사용 (각각의 spatial bin을 얻기 위해서 pooling하는 window size와 stride가 다름) -> 이 과정에서 warping 작업이 필요 없게 됨 -> 왜냐하면 feature map size (RoI size)에 따라서 window size, stride만 설정할 수 있도록 계산해주면 1x1, 2x2, 4x4 spatial bin을 구할 수 있음

 

: 또한, Pooling이 resolution을 감소시킨다는 개념을 알고 있으면 위와 같은 1x1, 2x2, 4x4 spaital bin은 다양한 resolution을 갖고 있다는 뜻 -> 그래서 spatial pyramid(다양한 resolution; 다양한 spatial bin) pooling 이라고 함

 

 

Third step

: 위의 spatial pyramid pooling 알고리즘을 통해 1x1, 2x2, 4x4 spatial bin을 얻었으면 spatial bin들을 모두 flatten하게 됩니다. 그럼 총 16+4+1 = 21개의 feature가 만들어 지겠네요. 21개의 고정적인 feature들은 fc layer로 넘어가게 됩니다.

 

<사진5>

 

 

 

 

 

<3. 결과>

 

SPP-Net역시 RCNN에서 사용된 bounding box regression (BB)을 적용했어요. 그 결과 SPP-Net BB 모델이 가장 성능이 좋게 나왔어요.

 

 

 

 

 

이번글에서는 SPP Net에 대해서 알아보았어요. SPP-Net의 장점을 이야기하면 아래와 같이 요약할 수 있겠어요.

①Spatial Pyramid Pooling을 통해 RCNN에서 사용된 warping 작업을 없애 distortion을 피할 수 있었다.

②RCNN에서는 CNN연산을 2000번 한 것에 비해, SPP Net은 CNN 연산을 한 번만 하면되서 training, test 시간의 굉장히 단축시켰다.

 

 

 

 

하지만 여전히 SPP-Net을 통해서도 극복하지못한 RCNN의 단점들이 존재하고 있고, SPP-Net에서도 단점이 있었어요. 그래서 다음글 Fast RCNN을 소개하면서 여전한 RCNN의 단점과 SPP-Net의 단점을 어떻게 극복했는지 설명해드릴게요~  

 

 

 

[사진 래퍼런스]

사진1

https://woosikyang.github.io/fast-rcnn.html

사진2

http://biz.heraldcorp.com/view.php?ud=20131219000553

사진3

https://towardsdatascience.com/r-cnn-fast-r-cnn-faster-r-cnn-yolo-object-detection-algorithms-36d53571365e

사진4

https://blog.lunit.io/2017/06/01/r-cnns-tutorial/

사진5

https://m.blog.naver.com/PostView.nhn?blogId=laonple&logNo=220731472214&proxyReferer=https%3A%2F%2Fwww.google.co.kr%2F

 

'Deep Learning for Computer Vision > Object Detection (OD)' 카테고리의 다른 글

8. Faster RCNN  (1) 2020.02.06
7. Fast RCNN  (2) 2020.02.06
5. RCNN  (0) 2020.02.05
4. DPM (Deformable Part Model)  (0) 2020.02.04
3. Object Detection과 CNN의 관계  (2) 2020.02.04

+ Recent posts