1. 程式人生 > >論文閱讀:You Only Look Once: Unified, Real-Time Object Detection

論文閱讀:You Only Look Once: Unified, Real-Time Object Detection

Preface

注:這篇今年 CVPR 2016 年的檢測文章 YOLO,我之前寫過這篇文章的解讀。但因為不小心在 Markdown 編輯器中編輯時刪除了。幸好同組的夥伴轉載了我的,我就直接考過來了,重新發一下。以後得給自己的博文留個備份。


abstract

這篇文章提出了一個新的物體檢測的方法:You Only Look Once(YOLO)。

之前的物體檢測方法通常都轉變為了一個分類問題,如 R-CNN、Fast R-CNN 等等。另外,關於對 R-CNN、Fast R-CNN、Faster R-CNN 這一系列方法,知乎上有個特別好的帖子:如何評價rcnn、fast-rcnn和faster-rcnn這一系列方法?

而這篇文章將檢測變為一個 regression problem,YOLO 從輸入的影象,僅僅經過一個 neural network,直接得到 bounding boxes 以及每個 bounding box 所屬類別的概率。正因為整個的檢測過程僅僅有一個網路,所以它可以直接 end-to-end 的優化。

YOLO 結構十分的快,標準的 YOLO 版本每秒可以實時地處理 45 幀影象。一個較小版本:Fast YOLO,可以每秒處理 155 幀影象,它的 mAP(mean Average Precision) 依然可以達到其他實時檢測演算法的兩倍。

同時相比較於其他的 state-of-art detection systems。儘管 YOLO 的定位更容易出錯,這裡的 定位出錯

,即是指 coordinate errors

但是 YOLO 有更少的 false-positive,文章這裡提到了一個詞:background errors背景誤差。這裡所謂的 背景誤差 即是指 False Positive。在這篇 Paper 的Assigned Reviewer 裡,有 Reviewer 提到了這個問題:

On overall, the paper reads well, even if some terms such as IOU (I guess it’s the abbreviation of intersection over union but it would be better to say it as it’s not a standard abbreviation) or “background errors” (I’m not really sure of the meaning of this expression. Are they False Positive? If yes, it should be better to use False Positive instead).


這裡寫圖片描述

最後,YOLO 可以學習到物體的更加泛化的特徵,在將 YOLO 用到其他領域的影象時(如 artwork 的影象上),其檢測效果要優於 DPMR-CNN 這類方法。

Introduction

現在的 detection systems 將物體檢測問題,最後會轉變成一個分類問題。在檢測中,detection systems 採用一個 classifier 去評估一張影象中,各個位置一定區域的 window 或 bounding box 內,是否包含一個物體?包含了哪種物體?

一些 detection systems,如 Deformable Parts Models(DPM),採用的是 sliding window 的方式去檢測。

最近的 R-CNNFast R-CNN 則採用的是 region proposals 的方法,先生成一些可能包含待檢測物體的 potential bounding box,再通過一個 classifier 去判斷每個 bounding box 裡是否包含有物體,以及物體所屬類別的 probability 或者 confidence。這種方法的 pipeline 需要經過好幾個獨立的部分,所以檢測速度很慢,也難以去優化,因為每個獨立的部分都需要單獨訓練。

本文將 object detection 的框架設計為一個 regression problem。直接從影象畫素到 bounding box 以及 probabilities。這個 YOLO 系統如圖看了一眼影象就能 predict 是否存在物體,他們在哪個位置,所以也才叫 You Only Look Once。

YOLO 的 idea 十分簡單,如 Figure 1:
將影象輸入單獨的一個 CNN 網路,就會 predict 出 bounding boxes,以及這些 bounding boxes 所屬類別的概率。YOLO 用一整幅影象來訓練,同時可以直接優化 detection performance。

這裡寫圖片描述

這樣的統一的架構,對比之前如 R-CNNFast R-CNN 的 pipeline,有以下幾點好處:

(1)YOLO 檢測系統非常非常的快。受益於將 detection 架構設計成一個 regression problem,以及簡單的 pipeline。在 Titan X 上,不需要經過批處理,標準版本的 YOLO 系統可以每秒處理 45 張影象;YOLO 的極速版本可以處理 150 幀影象。這就意味著 YOLO 可以以小於 25 毫秒延遲的處理速度,實時地處理視訊。同時,YOLO 實時檢測的mean Average Precision(mAP) 是其他實時檢測系統的兩倍。

(2)YOLO 在做 predict 的時候,YOLO 使用的是全域性影象。與 sliding window 和 region proposals 這類方法不同,YOLO 一次“看”一整張影象,所以它可以將物體的整體(contextual)的 class information 以及 appearance information 進行 encoding。目前最快最好的Fast R-CNN ,較容易誤將影象中的 background patches 看成是物體,因為它看的範圍比較小。YOLO 的 background errors 比 Fast R-CNN 少一半多。

(3)YOLO 學到物體更泛化的特徵表示。當在自然場景影象上訓練 YOLO,再在 artwork 影象上去測試 YOLO 時,YOLO 的表現甩 DPM、R-CNN 好幾條街。YOLO 模型更能適應新的 domain。

Unified Detection

YOLO 檢測系統,先將輸入影象分成 S×S 個 grid(柵格),如果一個物體的中心掉落在一個 grid cell 內,那麼這個 grid cell 就負責檢測這個物體。

每一個 grid cell 預測 B 個 bounding boxes,以及這些 bounding boxes 的得分:score。這個 score 反應了模型對於這個 grid cell 中預測是否含有物體,以及是這個物體的可能性是多少。正式的公式:Pr(Object)IOUtruthpred。如果這個 cell 中不存在一個 object,則 score 應該為 0;否則的話,score 則為 predicted box 與 ground truth 之間的 IoU(intersection over union)

本文中的每一個 bounding box 包含了 5 個 predictions:x,y,w,h,confidence,座標(x,y) 代表了 bounding box 的中心與 grid cell 邊界的相對值。width、height 則是相對於整幅影象的預測值。confidence 就是 IoU 值。

每一個 grid cell 還要預測 C 個 conditional class probability(條件類別概率):Pr(Classi|Object)。這個C 基於 gird cell 包含了哪個物體(所以為 conditional probabilities)。不管 grid cell 中包含的 boxes 有多少 B,每個 grid cell 只 predict 每個類別的 conditional probabilities。

在測試階段,將每個 grid cell 的 conditional class probabilities 與每個 bounding box 的 confidence 相乘:

Pr(Classi|Object)Pr(Object)IOUtruthpred=Pr(Classi)IOUtruthpred
上面得到每個 bounding box 的具體類別的 confidence score。這樣就把 bounding box 中預測的 class 的 probability,以及 bounding box 與 object 契合的有多好,都進行了 encoding。

將 YOLO 用於 PASCAL VOC 資料集時:

  • 本文使用的 S=7,即將一張影象分為7×7=49 個 grid cells
  • 每一個 grid cell 預測 B=2 個 boxes(每個 box 是 (x,y,w,h,confidence)5 個數值)
  • 同時,PASCAL 資料集中有 20 個類別,則,上面的 C=20

因此,最後的 prediction 是 7×7×30tensor

這裡寫圖片描述

Network Design

YOLO 仍是 CNN 的經典形式,開始是 convolutional layers 提取特徵,再是 fully connected layers 進行 predict 結果:probabilities 以及 coordinates

YOLO 的 CNN 結構取自兩篇論文:GoogLeNetNetwork in Network. YOLO 有24 個卷積層,隨後就是全連線層。不像 GoogLeNet 中使用的 inception modules,YOLO 採用了 Network in Network 中的結構,在3×3 卷積層之後,跟著一個 1×1 的層。如下圖 Figure 3 所示:

這裡寫圖片描述

網路結構,更詳細的如下表所示:

Layers     Parameters
Input Data     Images Size: 448×448
Convolution     num_filters: 64, kernel size: 7×7, stride: 2
Max Pooling     kernel size: 2×2, stride: 2
Convolution     num_filters: 192, kernel size: 3×3, stride: 1
Max Pooling     kernel size: 2×2, stride: 2
Convolution     num_filters: 128, kernel size: 1×1, stride: 1
Convolution     num_filters: 256, kernel size: 3×3, stride: 1
Convolution     num_filters: 256, kernel size: 1×1, stride: 1
Convolution     num_filters: 512, kernel size: 3×3, stride: 1
Max Pooling     kernel size: 2×2, stride: 2
Convolution     num_filters: 256, kernel size: 1×1, stride: 1
Convolution     num_filters: 512, kernel size: 3×3, stride: 1
Convolution     num_filters: 256, kernel size: 1×1, stride: 1
Convolution     num_filters: 512, kernel size: 3×3, stride: 1
Convolution     num_filters: 256, kernel size: 1×1, stride: 1
Convolution     num_filters: 512, kernel size: 3×3