Learning Shape-Aware Embedding for Scene Text Detection

Inc Lomin's avatar
Aug 06, 2019
Learning Shape-Aware Embedding for Scene Text Detection
arbitrary shape의 scene text를 인식하기 위한 여러 방법 중 Segmentation을 기반으로 Text 영역을 검출하고 embedding을 통해 Text instance를 분리하는 방식을 이용한 Detection 방식입니다.

Introduction

 
EAST와 같이 distance regression로 Text box를 표현하는 방식은 학습하는 crop size에 제한을 받고 긴 instance를 학습하기 어렵습니다. 아래 표처럼 Regression을 사용하지 않은 경우 더 높은 성능을 보이고 있습니다.
이런 이유에서 regression을 사용하지 않는 solution을 찾고자 합니다.
notion image
regression을 사용하지 않는 solution에는 주로 segmentation framework가 기반이 됩니다. 해당 알고리즘들은 텍스트의 영역과 텍스트가 아닌 영역을 분리합니다. 하지만 scene text에 등장하는 텍스트들 간의 좁은 거리로 인해 분리하는데 실패하는 문제로 인한 성능 문제가 있었습니다.
 
위의 문제를 해결하기 위해서 그림과 같이 embedding space에 pixel을 mapping하고 같은 text instance끼리 인접하도록 하였습니다. interval이나 확실하지 않은 boundary로 구분하는 대신 Embedding feature로 본질적인 representation을 학습할 수 있습니다.
notion image
 

Contribution

1) 인접한 instance를 분리하기 위한 Shape-Aware Loss를 제안했습니다.
2) arbitrary shape의 text instance를 인식하기 위한 새로운 pipeline을 제안합니다.
3) 제안하는 방식으로 대표적인 3개의 Scene text dataset에서 경쟁력있는 성능을 보였습니다.
 

Proposed Method

1. Network Structure

제안하는 방식은 segementation기반의 framework로 embedding clustering을 통해서 prediction을 합니다. input 이미지가 주어지면 embedding feature와 text foreground mask를 만들어냅니다. 대칭의 FPN을 사용하였고 기본적인 backbone은 ResNet50을 사용했습니다. 그리고 upsampling과 pixel-wise addition을 통해서 서로 다른 레이어의 feature를 결합합니다.
notion image
EAST, FOTS, Inception-text 등과 다르게 single module이 아닌 독립적인 두 개의 branch로 분리했습니다. 하나는 text instance 구분을 위한 8-channel의 embedding을 생성하고 다른 하나는 test foreground maks를 생성합니다. 두 개의 branch로 weight를 분리하면서 embedding과 segmentation을 수행하는 single stage network로 만들 수 있습니다.
 

2. Shape-Aware Embedding

Design
embedding branch는 feature merging module로 부터 feature와 x, y좌표를 의미하는2channel position을 입력받습니다. 이 입력은 각각 channel이 32, 16,8인 세 개의 3x3 convolution layer를 통과하고 최종 output은 각 pixel에 대한 8 channel embedding이 됩니다.
 
Loss function
주어진 text instance의 set과 각 text region의 embedding feature에 대한 Shape-Aware Loss(SA loss)를 제안합니다.
 
notion image
  • L_var: 같은 instance에 포함된 pixel의 embedding을 모으기 위한 variance loss
  • L_dist: 다른 instance들의 embedding을 밀어내기 위한 distance loss
  • µ_j, µ_k: text Instance I_j,I_k의 embedding average
  • xi: pixel i의 embedding
  • N_i: I_j의 pixel 수
  • η, γ: variance loss와 distance loss의 margin, 0.5~1.5로 설정
 
notion image
  • Balance weight인 W_scale, W_dist를 통해서 다양한 크기를 수용하게 함.
  • max(h, w): input이미지의 긴 변의 길이
  • max side(j): quadrangle text에서 긴 변의 길이, curved text(polygon)의 경우 vertex간의 거리가 가장 긴 변의 길이
  • min(Distance_j,k): I_j와 I_k간의 가장 짧은 거리
  • 한쪽이 dominant하지 않도록 구한 실험적인 weight의 범위는 WScale(j) (1,1.65), WDist는 y (0.63, 1)
WScale(j)은 I_j의 scale에 propotional합니다. WDist는 두개의 instance가 가까워질수록 커집니다.
 
N개의 text instance에 대한 SA loss는 다음과 같습니다.
notion image
Analysis
두개의 weight를 추가하면서 text embedding을 밀어내고 모을 수 있었습니다. Figure3각각 다른 loss로 학습된 embedding을 visualize한 결과를 볼 수 있습니다. Visualization은 8D의 embedding을 2d space에 Principal component analysis(PCA)를 사용하였습니다.
 
notion image
 

3. Segmentation mask

 
Design
segmentation branch는 두개의 1channel segmentation mask를 생성합니다. 각각은 Full Map과 Center Map이라는 이름을 붙였습니다. 이전의 module(feature merging module)에 두개의 분리된 3x3 convolution layer를 붙였습니다. Full Map은 text의 전체적인 위치와 분포를 의미합니다. Center Map은 text의 중심 영역만을 표현해서 pixel 기반의 clustering에 도움이 됩니다.
 
Loss Function
Full map과 Center map은 모두 Dice loss를 최소화 하도록 학습되었습니다.
notion image
  • P, Q: 각각 prediction과 Ground Truth를 의미
  • D(,): Dice coefficient
 
Formula of dice coefficient
Formula of dice coefficient
Segmentation branch의 loss는 두개의 map의 weight combination으로 계산됩니다. 실험에서 λ는 0.5로 두개의 segmentation map에 균등하게 할당했습니다. Center map은 Full Map으로부터 r만큼 축소된 영역입니다. r은 0.7로 EAST와 같은 값을 사용했습니다.
notion image
 

4. Overall Loss fucntion

 
notion image
  • L_SA: embedding branch loss
  • L_seg: segmentation branch loss
 

5. Cluster processing

위의 과정을 거치면 model은 3개의 map(Embedding map, Full map, Center Map)을 가지게 됩니다. clustering을 위해서는 위의 3개의 map을 사용하게 됩니다.
 
1) DBSCAN으로 full map과 center map의 cluster를 계산.
2) full map에 속하나 center_map에는 속하지 않는 pixel을 embedding을 통해서 cluster를 할당
3) pixel을 embedding distance가 가장 작고 threshold보다 작은 cluster에 할당(threshold보다 큰 경우는 무시)
4) 3)에서 C_F의 cluster가 할당되면 C_C에만 속한 pixel에 clustering
notion image
 

Experiment

1. Datasets

  • SynthText
  • ICDAR15
  • MSRA-TD500: Chinese, English annotated by line.
  • CTW500: curved text dataset
 

2. Implementation detail

Training
  • Imagenet pretrained ResNet50
  • 각 블록은 128 channel로 고정
  • random rescale(640-2560), random rotation, transpose, flip 등이 사용
  • Adam optimizer를 사용
  • batch normalization 사용
  • OHEM를 positive:negative 1:3으로 사용
  • SynthText에 1e-4로 pretrain
 
Inference
  • σ : 1.0, τ : 0.7 embedding distance hyperparameter
  • δ nms threshold: 0.5
 

3. Comparison with State-of-the-Arts

Quadrangular Text
notion image
 
notion image
 
Curved Text
CTW에서는 state of the art를 달성.
CTW에서는 state of the art를 달성.
 

4. Ablation Study

Effectiveness of Shape-Aware Loss
SA Loss의 효과를 검증하기 위해서 SA Loss와 Discriminative(Disc) Loss를 비교하였습니다.
ICDAR15에서는 SA Loss는 H-mean: 82.2 precision: 84.9 recall: 79.6
Disc Loss는 H-mean: 78.0 precision: 81.0 recall: 75.2를 보였습니다. 다음 표4는 TD500에 대한 비교결과 입니다.
notion image
 
Effectiveness of Cluster Processing
1) Why not directly cluster on embedding?
직접 embedding으로 clustering을 하는 것보다 나은 이유를 설명합니다. 먼저 foreground mask만을 가지고 clustering을 할 경우 경계의 noise를 피하기 어렵습니다. 따라서 2D space와 embedding space의 bridge를 만들어 post-processing을 합니다. 또한 full map을 통해서 search spce를 줄여줍니다.
 
notion image
Embedding map에 바로 clustering을 한 정확도와 mask segmentation을 결합한 pipeline과 비교.
Embedding map에 바로 clustering을 한 정확도와 mask segmentation을 결합한 pipeline과 비교.
 
위의 비교를 시각화
위의 비교를 시각화
 
2) Why not directly dilate center areas?
Center map의 영역을 확대하지 않고 Full map을 사용한 이유를 설명합니다.
Figure 8과 같이 크거나 얇은 text instance에서 center area는 두개로 분리될 수 있습니다. 이에 따라 성능이 떨어지는 문제가 생깁니다. 제안하는 pipeline에서는 embedding clustering으로 해결이 됩니다. clustering의 false prediction은 nms를 통해서 제거됩니다.
Center map의 크기를 확대를 하는 경우는 정확하게 ground truth가 되지 못하는 점도 문제가 됩니다. 공정한 비교로 Table1, Table2의 W/O는 center area를 확대해서 사용한 결과입니다.
notion image
Importance of Full Map and Center Map.
Full map으로 text/non-text영역을 얻어내어 computing cost를 낮추고 Center map은 post-processing시 embedding clustering의 정확도를 높여줍니다.
 
Effectiveness of Dual-Branch Network
Dual branch를 사용하지 않는 경우는 parameter의 공정성을 위해서 기존 channel 128의 두배인 256으로 설정하였습니다. 해당의 case에서 ICDAR15에 대해 H-mean: 79.2 precision: 81.4 recall: 77.2를 달성했습니다. (기존은 H-mean: 85.0 precision: 88.3, recall:86.6)
 

Conclusions

Limitation

  • Clustering을 두번 해야하는 문제로 720P 이미지에 대해 NVIDIA TITAN X Pascal GPU를 사용했을 때 평균 3fps를 달성했습니다. 또한 다음과 같은 failure case가 있었습니다.
notion image
 
Share article