///
Search
Duplicate
🎭

YOLO v4: Optimal Speed and Accuracy of Object Detection

Created
2021/07/04 06:42
발표일자
2021/02/15
발표자
곽도영
Tags
YOLOv4
ObjectDetection
COCO
✅main
포스팅 종류
논문리뷰
23 Apr 2020
Alexey Bochkovskiy, Chien-Yao Wang, Hong-Yuan Mark Liao
→ 후속연구: Scaled-YOLOv4: Scaling Cross Stage Partial Network (Chien-Yao Wang, Alexey Bochkovskiy, Hong-Yuan Mark Liao, 16 Nov 2020)
→ 후속개발: YOLOv5: https://github.com/ultralytics/yolov5

요약

YOLO v3 성능을 유지하면서 훨씬 빠른(1 GPU에서 동작하는) 방법 제안
학계의 다양한 성능향상 기법 적용 및 몇가지 커스텀한 기법 적용

목차

Introduction
History of YOLO
Related work
Methodology
Experiments
Conclusion
관련 후속 연구, 모델 소개

Introduction

CNN에서 정확도를 올리는 다양한 방법들 적용
학계에 알려진 여러가지 방법을 적용하여 일반적으로 사용하는 1 GPU에서 사용가능한 모델을 제안 (MS COCO 데이터셋에서 APAP는 43.5%(AP50AP_{50}은 65.7%), Tasla V100에서 ~65 FPS 달성)
사용된 방법들로는: WRC, CSP, CmBN, SAT, Mish activation, Mosaic data augmentation, DropBlock regularization, CIoU loss.
YOLO의 아버지인 조셉이 Vision 연구를 더이상 하지 않겠다고 했다고 함.
Plain Text
YOLOv4
CNN-based object detector들은 추천 시스템에서만 사용됨 → 주차장에 빈 공간을 찾아준다던가 하는 느린고 정확한 모델 사용 → 자동차 충돌 감지 알림 용도에는 빠르고 부정확한 모델이 사용됨
Plain Text

YOLO History

YOLO (YOLOv1): You Only Look Once: Unified, Real-Time Object Detection

한번에 bounding box와 classification 정보를 추론
Author: Joseph Redmon, Santosh Divvala, Ross Girshick, Ali Farhadi
source: PR-249 이호성님 YOLOv4 자료

YOLO9000 (YOLOv2): Better, Faster, Stronger

YOLOv1에 여러가지 알고리즘 적용하여 빠르고 정확한 모델 달성
Author: Joseph Redmon, Ali Farhadi
source: PR-249 이호성님 YOLOv4 자료

YOLOv3: An Incremental Improvement

성능을 끌어올리자!
Author: Joseph Redmon, Ali Farhadi
source: PR-249 이호성님 YOLOv4 자료

문제구성

정의한 문제 요약:
빠르고 정확한 object detection model을 제안
→ 1080 Ti, 2080 Ti에서 사용할 수 있도록
학계에 제안됐던 다양한 기법들로 (Bag of freebiesBag of specials으로) 성능 개선
추가로 개선하여 1 GPU 학습에 적합하게 만듦 (CBN, PAN, SAM, etc.)

Related work

Object detection models

backbone으로 여러가지 Image classifier 모델을 사용 가능
여기서 고려한 모델은 CSPRexNext50, CSPDarknet53, EfficientNet-B3
neck은 backbone에서 나온 featuremap을 정제하고 재구성함.
Backbone에 상단에는 정보가 많이 담겨 있지만, 하단에는 정보가 많이 없음. 상단에 정보를 하단으로 보내주기 위해 neck을 사용.
head는 크게 one-stage model과 two-stage model로 나뉨
one-stage
dense prediction에서 localizaton과 classification 결과를 한번에 준다
YOLO, SSD, RetinaNet 등이 있다
two-stage
sparse prediction 부분이 추가된다. detection 결과에대해 classificiation을 수행하여 2단계에 걸쳐서 수행한다
보통 속도가 더 느리다.
R-CNN, fast R-CNN, faster R-CNN, R-FCN, Libar R CNN 등이 있다
픽셀단위(혹은 그리드 단위)로 결과가 나오므로 dense prediction이라 부르고, 한번 걸러진 뒤 특정 영역에대해서 결과를 내므로 sparse prediction이라 부름

Bag of freebies

: inference 비용 증가 없이 성능 개선 가능한 방법
data augmentation
random erase, CutOut, hide-and-seek, grid mask,
DropOut, DropConnect, DropBlock
MixUp, CutMix, style transfer GAN,
solving semantic distribution bias (data imbalance between different classes)
two-stage method: hard negative example mining, online hard example mining
Focal loss
label smoothing
objective function of Bounding Box(BBox) regression
MSE loss
GIoU loss: to include the shape and orientation of object in addition to the coverage area (커버리지 영역에서 오브젝트의 shape과 orientation을 포함함)
DIoU loss: it additionally considers the distance of the center of an object (추가적으로 오브젝트의 중앙점 거리를 고려함)
CIoU loss: on the other hand simultaneously considers the overlapping area, the distance between center points, and the aspect ratio (동시에 겹친 영역과 중앙점간의 거리, 비율을 동시에 고려함)

Bag of specials

약간의 inference 비용 증가만으로 성능 개선을 대폭 만드는 방법(plugin modes, post-processing methods)
enhance receptive field
SPP, ASPP, RFB
attention module
SE (Squeeze-and-Excitation) — ImageNet에서 2% 추가비용으로 1% top-1 acc 개선, 한 GPU에서는 10% inference time 상승.
SAM (Spatial Attention Module) — ImageNet에서 0.1% 추가 비용만으로 0.5% top-1 acc 개선 (ResNet50-SE). GPU에서 inference speed에는 영향 X
feature integration
skip connection, hyper-column — 낮은수준의 물리 피처(physical feature)를 높은수준의 의미론적 피처(semantic feature)로 통합하기 위한 용도
SFAM, ASFF, BiFPN
activation function
ReLU, LReLU, PReLU, ReLU6, Scaled Exponential Linear Unit(SELU), Swish, hard-Swish, Mish
post-processing method
commonly used NMS — filter those BBoxes that badly predict the same ob- ject. 하지만 context information 고려가 안됨
greedy NMS — classification confidence score 추가하여 높은 점수 순서로 찾음 (R-CNN)
soft MNS — it considers the problem that the occlusion of an object may cause the degradation of confidence score in greedy NMS with IoU score
DIoU NMS — add the information of the center point distance to the BBox screening process on the basis of soft NMS

Methodology

YOLO v4 정리

구성
Backbone: CSPDarknet53
Neck: SPP, PAN
Head: YOLOv3
backbone
Bag of Freebies (BoF): CutMix and Mosaic data augmentation, DropBlock regularization, Class label smoothing
Bag of Specials (BoS): Mish activation, Cross-stage partial connections (CSP), Multi-input weighted residual connections (MiWRC)
detector
Bag of Freebies (BoF): CIoU-loss, CmBN, DropBlock regularization, Mosaic data augmentation, Self-Adversarial Training, Eliminate grid sensitivity, Using multiple anchors for a single ground truth, Cosine annealing scheduler, Optimal hyper-parameters, Random training shapes
Bag of Specials (BoS): Mish activation, SPP-block, SAM-block, PAN path-aggregation block, DIoU-NMS

Mosiac data augmentation

CutMix는 2개 이미지만 커버하지만 Mosiac은 4개 이미지 커버함
1 이미지에 4개의 이미지를 넣기 때문에 batch-size가 커지는 효과
작은 object에대해 잘 찾는 효과
4개의 context가 합쳐지는 효과 (보통 버스 아래에 사람이 없지만, Mosiac은 가능)

Backbone

Higher input network size (resolution) – for detecting multiple small-sized objects
More layers – for a higher receptive field to cover the increased size of input network
More parameters – for greater capacity of a model to detect multiple objects of different sizes in a single image

CSPDarknet53

Dense layer마다 conv 결과를 붙여서 쌓아가는데, CSPNet은 절반만 conv하고 붙여나가고 나머지 절반은 바로 transition layer에 붙여서 네트워크 구성하면 계산 병목 감소, 메모리 비용이 줄어듦
CSPNet: A New Backbone that can Enhance Learning Capability of CNN (LPCVC in CVPR 2020)

SPP (Spatial Piramid Pooling)

backbone에서 나온 featuremap을 pooling해서 나온 결과를 concat하여 사용
DC-SPP-YOLO: Dense Connection and Spatial Pyramid Pooling Based YOLO for Object Detection

Modified PAN (Path Aggregation Network)

왼편에 쌓여있는 레이어는 여러 레이어의 집합이므로 정보 전달이 어려움
→ 초록색 점선 흐름과같이 shortcut path를 만들어 정보를 쉽게 올리도록 구성
PAN에서 약간 수정을 했던 부분은 FPN의 중간결과를 bottom-up path augmentation에서 합칠때 addition 연산이 아닌 concatenation 연산을 수행함
PANet: Path Aggregation Network for Instance Segmentation (CVPR 2018)

Modified SAM (Spatial Attention Module)

CBAM: Convolutional Block Attention Module (ECCV 2018)에서 제안된 방법
CBAM에서는 Channel Attention Module과 Spatial Attention Module을 제안함
YOLOv4에서는 수정된 SAM(Spatial Attention Module)를 사용
→ CAM은 "무엇을(what)" attention할지 찾아주고, SAM은 "어디를(where)" attention할지 찾아줌
→ 기존 방법: featuremap → pooling → conv → 합치기
→ spatial-wise attention을 point-wise attention으로 변형하여 사용
→ pooling을 하지 않고 conv → 합치기

SAT (Self Adversarial Training)

stage를 두단계로 나눠서 학습을 하는 것 같은데 정확한 설명과 비교 실험이 없습니다

CmBN

CBN(Cross Batch Normalization)은 한 batch마다 normalization을 하는게 아니라 이전 4개 batch들의 값들을 고려하여 batch normalization을 수행

Experiments

Influence of different features on Classifier training

정확도 개선이 된 방법들: CutMix, Mosaic, Label Smoothing, Mish
Mish는 다른 BoF에비해 월등히 높은 성능 개선에 기여 (+1.0%)
같은 조건으로, CSPResNeXt50이 79.8%, CSPDarknet53이 78.7% 달성 (top-1)

Influence of different backbones and pre-trained weightings on Detector training

S: Eliminate grid sensitivity
M: Mosaic
IT: IoU threshold
GA: Genetic algorithms
LS: Class label smoothing
CBN: CmBN(Cross mini Batch Normalization)
CA: Cosine annealing scheduler
DM: Dynamic mini-batch size
OA:OptimizedAnchors

detector의 BoS 실험

다른 backbone으로 BoF 적용, Mish 적용 비교 실험

위 ImageNet 실험에서는 CSPResNeXt50이 79.8%, CSPDarknet53이 78.7% 달성(top-1)했지만 COCO detection 실험에서는 CSPDarkNet53이 더 높은 AP 달성

BoF 적용 여부와 batch-size 관계 실험

Mosaic data augmentation 덕분인지 mini-batch 4와 mini-batch 8의 큰 차이가 없음

Conclusion

be trained and used on a conventional GPU with 8-16 GB-VRAM
We have verified a large number of features, and selected for use such of them for improving the accuracy of both the classifier and the detector.
width=608 height=608 in cfg: 65.7% mAP@0.5 (43.5% AP@0.5:0.95) - 34(R) FPS / 62(V) FPS - 128.5 BFlops
width=512 height=512 in cfg: 64.9% mAP@0.5 (43.0% AP@0.5:0.95) - 45(R) FPS / 83(V) FPS - 91.1 BFlops
width=416 height=416 in cfg: 62.8% mAP@0.5 (41.2% AP@0.5:0.95) - 55(R) FPS / 96(V) FPS - 60.1 BFlops
width=320 height=320 in cfg: 60% mAP@0.5 ( 38% AP@0.5:0.95) - 63(R) FPS / 123(V) FPS - 35.5 BFlops

참고

self-advarsarial training
dropblock
→ dropout대용. 랜덤하게 feature를 드랍하지 않고 블락 단위로 드랍함
label smoothing
giou, diou, ciou 비교 및 수식 정리
panet: path aggregation network
fpn: feature piramid network

후속연구

Scaled-YOLOv4

20년 12월 출간
Scaled-YOLOv4

YOLOv5

20년 5월 공개 (논문은 없음)
YOLOv3 파이토치 버전 만든 저자가 만든 저장소
YOLOv4에비해 성능이 더 낮다는 실험이 있음