XiangBai——【CVPR2017】Detecting Oriented Text in Natural Images by link Segments
目錄
- 作者和相關鏈接
- 方法概括
- 方法細節
- 實驗結果
- 方法的局限性
- 總結與收獲點
作者和相關鏈接
- 作者
方法概括
-
文章簡述:
- 方法名字:SegLink
- 改進版的SSD用來解決多方向的文字檢測問題
-
方法的性能
- ICDAR15 Incidental: 0.75(f)
- MSRATD500: 0.77(f), 8.9FPS (112 ms/per image)
- ICDAR2013: 85.3(f), 20.6FPS (50 ms/per image)
-
算法的pipeline
- 整個檢測過程分兩步
- Step 1: 圖像輸入到ssd網絡,同時輸出兩類信息
- 第一類信息是text的box信息,有兩點需要注意,一是這個box是多方向的,也就是帶角度信息的;另一點是box不是整個文本行(或者單詞)的box,而是文本行(或者單詞)的一個部分,稱為segment,可能是一個字符,或者一個單詞,或者幾個字符,比如圖fig 1中的每個黃色框即為一個segment。
- 第二類信息是不同box的link信息,因為segment是類似於字符級或者單詞級的,但最后目標是要輸出整個文本行(或者單詞),所以如果按以前傳統方法,是要后處理把這些segment連接成文本行(或者單詞)的,文章的高明之處在於把這個link也弄到網絡中去自動學習了,網絡自動學習出哪些segment屬於同一個文本行(或者單詞),比如圖fig 1中連接兩個黃框的綠色線即為一個link。
- Step 2: 有了segment的box信息和link信息,用一個融合算法得到最后的文本行(或者單詞)的box(也是帶方向的, x, y, w, h, θ)
- Step 1: 圖像輸入到ssd網絡,同時輸出兩類信息
- 整個檢測過程分兩步
Figure 1. Illustration of SegLink. The first row shows an image with two words of different scales and orientations. (a) Segments (yellow oriented boxes) detected on the image. (b) Links (green lines) detected between pairs of adjacent segments. (c) Segments connected by links are combined into whole words. (d-f) The SegLink strategy is able to detect text in arbitrary orientation and long lines of text in non-Latin scripts.
-
改進的SSD的地方:
-
- 原版SSD只輸出rectangle bounding box(x, y, w, h四個參數)→加入角度信息,輸出的是oriented bounding box(x, y, w, h, θ), θ表示矩形的角度(與水平方向,按順時針為正,逆時針為負)
- 每個feature map的每個位置上有多個不同aspect ratio的default box →每個位置上只有1個default box(加速的原因之一)
- 每層的feature map決定的default box的scale不再人工定義(10-90,平均分5次)→scale由感受野大小來決定
- 最大的亮點:網絡不但學習了segment的box,也學習了segment的link關系,來表示是否屬於同一個單詞(或者同一文本線)
- 訓練用的groundTruth除了因為多方向所以用的是旋轉后的groundTruth,還要有一個link的groundTruth
- 損失函數加入了link的損失項
-
方法的優勢
- 多方向,多語言,速度快,精度高,易訓練,可檢測任意長度(單詞或者文本行)
方法細節
-
word, segment, link的定義(看不是很懂?那就往下看...)
- segment: A segment is a bounding box that covers a part of a word (for clarity we use “word” here and later, but segments also can be applied to a “text line” that contains multiple words)
- link: A link connects a pair of adjacent segments, indicating that they belong to the same word. Links are not only necessary for combining segments into whole words, but also helpful for separating two adjacent words, between which the link should be predicted as negative.
- Word: Each word is composed of a number of segments with the links between all the adjacent pairs
-
CNN modelCombining segments with links
-
網絡結構
-
Figure 2. The architecture of the proposed detection network. The network consists of convolutional feature layers (shown as gray blocks) and convolutional predictors (thin gray arrows). Convolutional filters between the feature layers (some have one more convolutional layer between them) are represented in the format of “(#filters),k(kernel size)s(stride)”. Segments (yellow boxes) and links (not displayed) are detected by the predictors on multiple feature layers (indexed by l), then combined into whole words by combining algorithm.
-
-
- 若只考慮segment的box預測部分(segment detection),網絡結構上和原來的ssd相似,不同的地方在於
- ssd最后一個pool層變成了conv11
- 每個feature map的每個位置上只用了一個aspect ratio = 1(不是原來的1, 2, 3, 1/2, 1/3)
- 輸出從(x, y, w, h)變成了(x, y, w, h, θ),論文中提到的公式1~6實際上和ssd是一樣的,換湯不換葯
-
- 原圖大小為
,第l層的feature map大小為
-
default box 的中心位置(這個懷疑公式是不是寫錯了? 應該是xa=(x+0.5)/wL*wi...?)
- 原圖大小為
- 若只考慮segment的box預測部分(segment detection),網絡結構上和原來的ssd相似,不同的地方在於
-
-
-
-
-
- default box 的scale設置不再是人工設置,而是與感受野大小相關
- 原來的ssd的scale: ar表示default box的長寬比,sk表示第k層的default box的scale。smin=0.2, smax=0.9, m = 6。
- default box 的scale設置不再是人工設置,而是與感受野大小相關
-
-
-
-
-
-
-
-
- 現在的ssd的scale: 分子wI表示輸入的原圖大小,分母wl表示第l層的feature map的大小,所以wI/wl可以表示該層的神經元的感受野。比如原圖8*8,現在feature map只剩4*4了,說明,現在的每個像素對應原來的(8/4)×(8/4)= 2*2的區域,所以default box的大小設置應該與這個感受野成正比。
-
-
-
-
-
-
-
-
- 預測的offsets里除了Δx, Δy, Δw, Δh, 多了一個Δθ
-
-
-
-
-
within-layer link and cross-layer link detection
- within-layer link:在同一個feature map層(conv 4_3, conv7, conv8_2, conv9_2, conv10_2, conv11這六層后面接3*3的filters進行prediction),每個segment與它周圍的8連通的8個鄰居的segment的連接情況,每個link有兩個分數,一個用是正分,一個是負分,正分用來表示二者是否屬於同一個單詞,是否應該連接;負分表示二者是否屬於不同單詞,是否應該斷開連接。所以,每個segment的link應該是8*2=16維的向量。neighbor的規范化定義如公式(9)。如圖Fig 3中的(a)圖,黃色框的鄰居為兩個藍色框,他們之間有link(綠色的線),表示屬於同一個單詞。
- within-layer link:在同一個feature map層(conv 4_3, conv7, conv8_2, conv9_2, conv10_2, conv11這六層后面接3*3的filters進行prediction),每個segment與它周圍的8連通的8個鄰居的segment的連接情況,每個link有兩個分數,一個用是正分,一個是負分,正分用來表示二者是否屬於同一個單詞,是否應該連接;負分表示二者是否屬於不同單詞,是否應該斷開連接。所以,每個segment的link應該是8*2=16維的向量。neighbor的規范化定義如公式(9)。如圖Fig 3中的(a)圖,黃色框的鄰居為兩個藍色框,他們之間有link(綠色的線),表示屬於同一個單詞。
-
Figure 3. Within-Layer and Cross-Layer Links. (a) A location on conv8˙2 (yellow square), its 8-connected neighbors (blue squares). Two within-layer links (green lines) connect a segment (yellow box) and its two neighboring segments (blue boxes) on the same layer. (b) Two cross-layer links connect a segment on conv9 2 (yellow) and two segments on conv8 2.
-
-
-
cross-layer link: 因為同一個單詞可能在不同層上都檢測到了,只不過segment的大小有所不同。所以為了解決這種重復檢測的冗余問題,引入了這個跨層鏈接。在相鄰兩層的feature map上,后面那層的segment的鄰居除了自己本層的鄰居外,在前一層也有它的鄰居(注意只是前一層是后一層的鄰居,但后一層不是前一層的鄰居,所以,只有conv7, conv8_2, conv9_2, conv10_2, conv11這5層有前鄰居,conv4_3無前鄰居)。它的鄰居是指前一層那些更小的segment。由於conv 4_3, conv7, conv8_2, conv9_2, conv10_2, conv11這幾層中,后一層的feature map都是是前一層的feature map大小的一半(conv4_3后有一個2*2的pool, conv8_2~conv10_2后分別有一個3*3,步長為2的卷積,所以都是大小減半, 但是conv7到conv8_2之間沒有pool或步長為2的conv啊?),所以實際上是后一層的每個segment的前鄰居就是前一層的feature map對應位置的2*2=4個小segment。另外,這種策略要求所有的feature map大小是偶數的,所以, 輸入圖像要求是128的倍數(怎么算的?)。cross-layer的link的規范化定義如公式10。 如圖Figure 3所示,黃色框是下一層的segment,藍色框是上一層的更加細,更加小的框,黃色框與上一層的兩個籃框有連接,說明屬於同一個單詞,后面會根據這個信息把這三個框融合起來。
-
-
-
-
output of convolutional predictor,每一層的輸出參數個數
- 如下圖,第l層的feature map大小為
,每個位置上都有2+5+16+8=31維的輸出。2表示是或不是字的二類分類分數,5表示位置信息x, y, w, h, θ,16表示8個同層的neighbor的連接或者不連接2種情況,8表示前一層的4個neighbor的連接與不連接情況。當然,conv4_3層沒有cross-layer link,所以只有2+5+16=23維輸出。
- 如下圖,第l層的feature map大小為
-
Figure 4. Outputs of a convolutional predictor. Cross-layer link scores are not predicted on conv4 3.
-
Training
-
GroundTruth of segments and links
- 如何判斷一個default box為正樣本?如何確定一個default box和哪個groundTruth的word進行link?
-
(1) 如果圖上只有1個word(原始groundTruth),則一個default box判斷為正樣本且和該word有link的條件
-
-
-
-
- default box的中心在word里面(如圖Figure 5.(1)中所示)
- default box的高度和word的高度比小於1.5,即
-
-
-
(2) 如果圖上有多個word(原始groundTruth),則一個default box判斷為正樣本且和某word有link的條件
-
-
-
- default box和任何word都不滿足(1)中的條件,則標記為負樣本,與所有word都不link。否則,標記為正樣本,且與大小和該default box最接近的那個word有link。
-
-
-
-
- 由原始的groundTruth如何得到訓練要用的可以用來選擇segment的groundTruth segment?
- 如圖Figure 5,先把原始的groundTruth——黃色的word bounding box繞default box的中心逆時針旋轉θ(實際上這個圖里的θ是負數的,所以我們看到的是順時針旋轉),把不在default box的左右兩邊部分裁掉,再繞default box的中心順時針旋轉θ,轉回原來的word bounding box所在的位置,這樣得到的那個裁切過后的矩形(也帶角度)為所謂的groundTruth segment。可以看出,最終的效果實際上就是把原來的word bounding box裁到和default box寬度一樣,以此來作為訓練要用的groundTruth segment。之所以要這么做,是因為現在的網絡目標是要找到segment,而不是要整個word。最后網絡要學的offset的時候就是如圖Figure 5.(4)中的藍色default box和黃色groundTruth segment之間的offset(包括中心點的x, y, w, h, θ) (要學習的寬度的offset,Δw不是應該始終為0?)
- 由原始的groundTruth如何得到訓練要用的可以用來選擇segment的groundTruth segment?
-
Figure 5. The steps of calculating a groundtruth segment given a default box and a word bounding box.
-
-
optimization
- 目標函數:由三個部分構成,是否是text的二類分類的softmax損失,box的smooth L1 regression損失,是否link的二類的softmax損失。λ1和λ2控制權重,最后都設為1.
-
-
-
Online Hard Negative Mining和Data Augmentation的使用與SSD一樣
-
-
Combining算法
- ssd網絡的輸出用閾值過濾一部分,α和β分別表示segment和link的閾值(這兩個值用網格搜索找到最優)
- 把每個segment看做node, link當做edge,建立圖模型,再用DFS(depth first search)找到連通分量,每個連通分量即為一個單詞,用下面的Algorithm1進行融合輸出單詞的box
- Algorithm1 實際上就是一個平均的過程。先求所有segment的平均θ作為word的θ,再以得到的θ為已知條件,求出最可能過每個segment的直線(線段),以線段中點作為word的中心點(x, y),最后用線段長度加上首尾segment的平均寬度作為word的寬度,用所有segment的高度的平均作為word的高度。
實驗結果
-
實驗細節
- pretrain
- VGG的SynthText dataset
- learning rate = 10^-3 for first 60k iterations, decayed to 10^-4 for the rest 30k iterations
- fine tune
- real data
- learning rate = 10^-4 for 5-10k iterations
- SGD+moment = 0.9
- training image size = 384*384
- batch size = 32
- grid search step = 0.1
- TensorFlow framework
-
Xeon 8-core CPU (2.8 GHz), 4 Titan X Graphics Card, and 64GB RAM. The training process runs on 4 GPUs in parallel, with each GPU processing 8 out of the 32 images in a batch at a time.
-
The whole training process takes less than a day. Testing is performed on one GPU
- pretrain
-
評價工具
- 多方向:ICDAR15的官方提交的評價服務器,實際上和MSRATD500的評價標准很相似,具體可以看這篇論文介紹
- 水平:Detval
-
ICDAR2015 Incidental庫的結果
-
MSRA-TD500庫的結果
-
ICDAR2013庫的結果
-
檢測結果樣例
方法的局限性
- α和β這兩個閾值設置需要人工,雖然用了網格搜索求得
- 不能檢測間隔很大的文本行
- 不能檢測形變或者曲線的文本
總結與收獲點
- 多方向是個熱點,今年的多篇文章都是做多方向的
- 這篇文章主要是兩點創新,第一加入方向信息把ssd改造成多方向的,第二把link融合到網絡一起學習。方法不但性能好,速度真的是相當快,都快達到實時的要求了...