반응형

Character_Region_Awareness_for_Text_Detection

https://arxiv.org/abs/1904.01941

 

Character Region Awareness for Text Detection

Scene text detection methods based on neural networks have emerged recently and have shown promising results. Previous methods trained with rigid word-level bounding boxes exhibit limitations in representing the text region in an arbitrary shape. In this p

arxiv.org

 

1. word-level -> character level

2. Weakly-Supervised Learning : character level 데이터 만들기

3. region score and the affinity score

 

 

Abstract

신경망을 기반으로 한 장면 텍스트 탐지 방법이 최근 등장했고 유망한 결과를 보여준다.

그 전의 학습 방법인 rigid word-level bounding 는 arbitrary shape 텍스트 영역을 나타네는데 학계가 있다. 

이 논문에서는  each character and affinity between characters을 탐색하여 텍스트 영역을 효과적으로 탐지하는 새로운 Text Detection 방법을 제안하였다.

개별적인 character level annotations가 적은 것을 극복하기 위하여 우리는 2가지 방법을 제안하였다.

1. 합성 이미지에 대해 주어진 characterlevel annotations

2. 학습된 interm model에 의해 획득된 real image에 대한 추정된 character-level ground-truths

character 사이에 affinity를 추정하기 위해서 , network는 새롭게 제안된 affinity에 대한 representation을 훈련해야 한다.

state-of-the-art detectors

결과에 따르면 arbitrarily-oriented, curved, or deformed texts 등에 대해 유연하게 결과를 얻을 수 있다.

 

1. Introduction

Scene text detection  computer vision 에서 많은 관심을 끌고 있다.

예 : instant translation, image retrieval, scene parsing, geo-location, and blind-navigation

위에서 말한 것들은 요즘 deep learning이 발전하면서 좋은 성능을 가지고 있다.

하지만 이런것들은 curved, deformed, or extremely long등에서  single bounding box를 dectect하는데 많은 어려운 케이스가 있다.

character-level awareness는 많은 장점을 가지고 있다. bottom-up 방식으로 연속적인 character를 연결함으로써 많은 장점이 있다.  불행하게도 , 기존의 존재한 text datesets는 characterlevel annotations는 제공하지 않아서 비용이 많이 든다.

이 논문에서 , t localizes the individual character regions and links the detected characters to a text instance. 를 하는 새로운 text detector를 제안하였다.

CRAFT for Character Region Awareness For Text detection : 

the character region score and affinity score  cnn 모델 

region score is used to localize individual characters in the image, 이미지에서 개별 character를 localize 하는데 사용

the affinity score is used to group each character into a single instance. 각각의 character를 하나의 instance로 그룹을 해줄 때 사용

 

character-level annotations : weaklysupervised 

ICDAR datasets :long, curved, and/or arbitrarily shaped texts 신뢰성을 보여주겠다고 함

 

2. Related Work

bottom-up => MSER [27] or SWT [5]– as a basic component.

deep learningbased text detectors have been proposed by adopting popular object detection/segmentation methods like SSD [20], Faster R-CNN [30], and FCN [23].

 

Regression-based text detectors:

텍스트 같은 경우 불규칙한 모양을 가지고 있기 때문에 , 이러한 문제를 해결하기 위해 TextBoxes 는 다양한 텍스트 모양을 효과적으로 캐처하기 위해 convolutional kernels and anchor boxes 를 수정했다.

DMPNet quadrilateral sliding windows을 통합하여 문제를 더욱 줄이려고 노력했다.

최근에는 Rotation-Sensitive Regression Detector (RSDD) convolutional filters 를 능동적으로 회전시키면서 회전 불변성 한 feature를 완전히 사용하는 방법이 제안되기도 했다.

However, there is a structural limitation to capturing all possible shapes that exist in the wild when using this approach. 구조적 제한이 있다.

Segmentation-based text detectors

pixel level로 text regions을 찾기 위한 방법론이다.

detect texts by estimating word bounding areas: Multi-scale FCN [7], Holistic-prediction [37], and PixelLink [4] 

SSTD는 feature level에서 배경 간섭을 줄임으로써 , text 관련 영역을 향상하는 attention mechanism을 사용하여 regression 과 segmentaition 의 장점을 가질려고 한다.

TextSnake : geometry attributes 특징과 함께 중안 선과 text영역을 예측함으로써 , text 객체를 탐지하는 것을 제안하기도 했다.

End-to-end text detectors

leveraging the recognition result    detection and recognition modules simultaneously

FOTS [21] and EAA [10] Mask TextSpotter

It is obvious that training with the recognition module helps the text detector be more robust to text-like background clutters

Character-level text detectors

Zhang et al. [39] MSER [27] 

Yao et al. 

WordSup [12] : weakly supervised framework to train the characterlevel detector.

Wordsup의 단점은 character representation이 rectangular anchors로 형성된다. 이런한 것은 varying camera viewpoints 각도에 따라서 야기되는 characters의 변형 관점에서 취약하게 된다.

backbone structure 가 제한되여있다. ( SSD )

 

3. Methodology

우리의 목표는 natural images에서 each individual character 들이 정밀하게 현지화 하는 것이다.

deep neural network a deep neural network to predict character regions and the affinity between characters.

공개  된 character-level dataset 없기 때문에 우리는 weaklysupervised 방식으로 모델을 학습하였다.

 

 

3.1. Architecture

backbone : VGG-16

VGG-16 - BN을 사용하였다.

skip connections 이 있고 decoding 부분은 U-net  in that  it aggregates low-level features과 비슷하다.

U-Net

The final output has two channels as score maps: the region score and the affinity score.

Figure 2. Schematic illustration of our network architecture.

3.2. Training

3.2.1 Ground Truth Label Generation

각 image를 학습 할때 우리는 각 characterlevel bounding boxes  region score and the affinity score 의 ground truth label를 생성한다.

Region score는 해당 픽셀이 문자(Character)의 중심일 확률을 의미.

Affinity score는 해당 픽셀이 인접한 두 문자의 중심일 확률을 의미.

 

이 점수를 기반으로 개별 문자가 하나의 단어로 그룹화될 것인지가 결정됨.

 

Ground Truth Label 생성

각 학습 이미지에서 우리는 ground truth labelcharacter-level bounding boxesregion scoreaffinity score를 생성한다.

Unlike a binary segmentation map, which labels each pixel discretely, we encode the probability of the character center with a Gaussian heatmap.=> pixel discretely, label을 지정하는 binary segmentation map과 달리 , 우리는 a Gaussian heatmap 을 사용하여 중심의 확률을 인코딩하였다.

heatmap representation 은 엄격하게 경계가 없는 ground truth regions을 처리 할 경우 높은 유연성을 가진다.

 

아래의 이미지는 synthetic image에 대한 라벨 생성 pipeline이다.

bounding box 내의 각 pixel에 대해 Gaussian distribution value을 직접 구하는 것은 시간이 많이 걸린다.

 

Figure 3. Illustration of ground truth generation procedure in our framework. We generate ground truth labels from a synthetic image that has character level annotations.

 

region score and the affinity score:

  1. 2차원 isotropic Gaussian map을 준비한다.
  2. 이미지 내의 각 문자에 대해 경계상자를 그리고 해당 경계상자에 맞춰 가우시안 맵을 변형시킨다.
  3. 변형된 가우시안 맵을 원본 이미지의 경계상자 좌표와 대응되는 위치에 해당하는 Label Map 좌표에 할당한다.

affinity score:

Affinity Score Map은 Region Score Map을 생성할 때 사용했던 Character boxes를 활용한다.

각 글자의 4개점으로 두개 사각형을 만들 수 있다.

대각선을 그엇을 때 위 아래 삼각형이 생긴다.

인접한 character box pair 에 대해 , 삼각형 중심점을 이었을 때 만들어지는 사각형이 바로 Affinity box가 된다.

Region score : Character box label

Affinity score : Affinity box label

결국 문자 단위(Character-level)의 경계상자(Bounding-Box)만 결정되면 Region Score map과 Affinity Score map을 구할 수 있게된다.

 

Figure 3box를 바탕으로 라벨을 생성하는 과정이고 , 먼저 2D Gaussian 을 생성하고 , Perspective Transform을 통과하여 , box와 같은 것을 매핑하고 마지막으로 해당한 배경을 붙인다.

결국 문자 단위(Character-level)의 경계상자(Bounding-Box)만 결정되면 Region Score mapAffinity Score map을 구할 수 있게 된다.

 

제안된 Ground-Truth  으로 정의 된 모델은 receptive fields가 작아도  충분히 길거나 큰 텍스트를 감지할 수 있다. 하는 GT 정의는 모델의 receptive fields가 작아도, 크고 긴 텍스트를 검출 가능하게 한다. (이것은 기존의 Bounding Box Regression과 같은 접근 방식이 지닌 문제점을 보완하는 데 탁월한 것으로 보인다.)

문자 단위 검출은 convolutional filter가 전체 text instance 대신, 문자내및 문자 간의 관계에만 집중할 수 있게 한다.

 

 

문제점:

   앞에서 제시된 Ground-Truth를 이미지마다 하나하나 만들기에는 너무 많은 비용이 요구된다.

기존에 공개되어 있는 대부분의 데이터 집합들은 Annotation이 문자 수준(Character-level)이 아닌 단어 수준(Word-level)으로 annotation이 제공한다.

이러한 문제를 해결하기 위해 CRAFT 연구팀에서는 기존의 Word-level Annotation이 포함된 데이터 집합을 활용하여 Character-box를 생성하는 방법을 제안했다.

이 방법에 대해서는 Ground-Truth를 활용한 학습 방법을 살펴본 이후에 소개할 것이다.

 

3.2.2 Weakly-Supervised Learning

Figure 4. Illustration of the overall training stream for the proposed method. Training is carried out using both real and synthetic images in a weakly-supervised fashion.
Figure 6. Character split procedure for achieving character-level annotation from word-level annotation: 1) crop the word-level image; 2) predict the region score; 3) apply the watershed algorithm; 4) get the character bounding boxes; 5) unwarp the character bounding boxes.

 

Fig. 6 shows the entire procedure for splitting the characters.(전체 과정)

word-level image는 원본 이미지에서 Cropped 한다.

학습 중인 모델로 crop 된 이미지를 region score를 예측한다.

Watershed algorithm을 이용해 문자 영역을 분리하여 Character box를 결정한다.

마지막으로 분리된 Character box들이 Crop되기 이전의 원본 이미지 좌표로 이동시킨다.

 

weak-supervision으로 모델을 학습하면 , 우리는 불완전한 pseudo-GTs 학습할 수 밖에 없다.

If the model is trained with inaccurate region scores, the output might be blurred within character regions => 정확하지 않은 region scores -> character regions

이 문제를 방지하기 위해서  논문에서는 텍스트 annotation과 예측한 단어의 길이로 의사 GT의 신뢰도를 평가한다.

 

pseudo-GTs 신뢰도 평가

W – training data

R(w) and l(w) be the bounding box region and the word length of the sample w

추정한 단어의 길이

 

       

샘플에 대한 신뢰도

 

 

이미지에서 pixel p 위치의 신뢰도.

픽셀 p에 대해 p가 원본 이미지에서 Word-Box의 영역에 포함된다면 해당 좌표와 대응되는 Confidence Map좌표값은 Word-BoxConfidence Score로 설정한다.

나머지 영역은 모두 1로 설정한다.

 

 

중간 모델 학습하기 Interim model

 

Loss function

pixel에 대한 Region score예측값 정답의 유클리디 거리 오차

pixel에 대한 Affine score예측값 정답의 유클리디 거리 오차

두 거리 오차의 총합을 Loss로 정의하며 , 이 함수를 최적화 하는 것이 학습의 방향

Confidence map

이렇게 만든 Confidence mapPseudo-GT 데이터 집합을 학습할 때 목적함수(Loss Function) 내에서 사용된다.

 

Character region score maps

학습하면서 신뢰도가 점점 높아진다.

초기 단계에 학습할 경우, 일반 이미지에 익숙하지 않는 텍스트에 대한 region scores상대적으로 낮다.

모델 학습할 경우에 신뢰도 점수가 0.5미만일 경우,부정적인 영향을 줄 가능성이 있기 때문에 무시해도 된다. 이런 경우에  , individual character Width가 일정하다고 가정하고 단어 영역을 단어 길이로 나누어 character-level 예측한다.

신뢰도는 학습을 위해 0.5로 설정한다.

Figure 5. Character region score maps during training.

3.3. Inference

추론 단계에서 , 마지막 결과물을 다양하게 할 수 있다.(word boxes or character boxes, and further polygons)

region scoreaffinity score map으로부터 word-level bounding boxes QuadBox를 만드는 방법을 설명한다.

 

Word-level bounding boxes QuadBox

post-processing

v이진 맵 MM 0으로 초기화

픽셀 p에 대해 Region Score(p) 혹은 Affinity Score(p)가 각각 역치값 Tr(p), Ta(p)보다 클 경우 해당 픽셀을 1로 설정

v이진 맵 M에 대해 Connected component Labeling

vLabel을 둘러싸는 최소 영역의 회전된 직사각형 찾기(OpenCV에서 제공하는 connectedComponents()minAreaRect()

 

Polygon Inference

Word-Level QuadBox를 다음과 같은 과정을 통해 문자 영역 주위에 다각형을 만들어  curved texts를 효과적으로 처리할 수 있다.

수직 방향을 따라 문자 영역의 Local maxima line(blue line)을 찾는다

최종 다각형 결과가 불균일해지는 것을 방지하기 위해 Local maxima lineQuadBox 내의 최대 길이로 통일한다.

Local maxima line의 중심점들을 연결하는 선인 Center line(yellow line)을 구한다.

문자 기울기 각도를 반영하기 위해 Local maxima lineCenter line에 수직하도록 회전한다(red line).

Local maxima line의 양 끝점은 다각형의 Control point 후보들이다.

두 개의 가장 바깥쪽으로 기울어진 Local maxima lineCenter line따라 바깥쪽으로 이동하여 최종 Control point를 결정한다.(green dots)(텍스트 영역을 완전히 커버하기 위함)

 

 

4. Experiment

 

Datasets(ICDAR2013 (IC13), ICDAR2015 (IC15), ICDAR2017 (IC17), MSRA-TD500 (TD500), TotalText (TotalText), CTW-1500 (CTW))

Training strategy

Experimental Results

Discussions

 

Figure 8. Results on the TotalText dataset. First row: each column shows the input image (top) with its respective region score map (bottom left) and affinity map (bottom right). Second row: each column only shows the input image (left) and its region score map (right).

 

5. Conclusion

이 논문에서는 CRAFT라는 문자 단위 텍스트 검출기를 제안했다.

- 다양한 모양의 텍스트를 상향식으로 검출 가능.

 - 문자에 대한 region score, affinity score

 -  weak-supervision으로 character-level annotation 이 적은 데이터에 대한 학습 방법 제안. interim model을 통해 pseudo-GT 생성

 - 대부분의 공개 데이터셋에 대해 SOTA 성능 달성. fine-tuning 없이 성능을 보여줌으로써 일반화 능력을 입증.

 - 추후 end-to-end model 학습으로 확장.

큰 이미지에서 비교적 작은 Receptive field로 하나의 문자를 감지하기에 충분하므로, 스케일이 가변적인 텍스트를 검출하는 데 있어서 견고하다.

 

학습

Character-level Annotation 데이터 집합의 부족함을 보완하기 위해 2단계의 학습을 수행한다.

1.Ground Truth Label(Region ScoreAffinity Score 생성  Gaussian map )으로 1차 학습 : Interim model 생성

2.Pseudo-Ground Truth Label으로 2차 학습 : Weakly-Supervised Learning

모델을 통해 예측한 Region ScoreAffinity Score를 이용해 최종 결과물을 도출해내는 방법

2-dimensional isotropic Gaussian map

 

한계점

각 문자가 분리되어 있지 않고 연결되는 특정 국가의 언어 혹은 필기체에 대해서는 학습이 쉽지 않다.

아쉬운 FPS

 

 

pseudo라벨: 

딥러닝 모델을 훈련시킬때는 다량의 샘플을 지닌 데이터셋이 필수적입니다. 데이터셋에는 보통 이미지들과 그에 맞는 라벨(label, 레이블로 읽어도 됨)들이 들어가 있습니다. 이미지는 비교적 쉽게 얻을 수 있지만, 라벨을 매기는 것은 상당한 시간과 노력을 요구하는 일입니다. 만약 이미지 분류(image classification) 과제라면, 이미지를 보고 그 이미지의 라벨이 무엇인지 일일이 매겨줘야 합니다. 코끼리 이미지면 코끼리라고, 기린 이미지면 기린이라고, 원숭이 이미지면 원숭이라고 라벨링해줘야 합니다. 상당한 노동력을 요구로 하는 일이죠. 따라서 내가 직접하려면 시간을 많이 써야하고, 남에게 맡기려면 돈을 많이 써야합니다.

 

 

그런데 만약 이미지 분류 모델의 성능이 매우 좋다면, top-1 에러가 1%보다 작다면, 그 모델을 통해 예측된 라벨값을 라벨로 사용해도 되지 않을까요? 완벽하게 정확하진 않겠지만, 대부분의 경우에는 맞을 것입니다. 이렇게 생성된 라벨을 의사(pseudo) 라벨로 부를 수 있습니다. 일종의 짝퉁 라벨인 것이죠. 의사 라벨에 너무 의존한다면 너무 위험할 수 있겠지만, 모델 가중치의 pre-training 과정에 사용하는 것은 충분히 가능하다고 봅니다. 실제로 의사 라벨을 이용해서 모델을 훈련시키는 것을 최근 논문들에서 종종 발견하곤 합니다[1]. 

 

https://bskyvision.com/750

https://data-newbie.tistory.com/187

 

[Review] Character Region Awareness for Text Detection - (1)

네이버 크로버에서 쓴 OCR논문이다. 요즘 OCR 관련 상위에 있는 팀이기 때문에 열심히 배워야겠다. Abstract 최근에 Scene text detection은 Neural Network를 기반으로 한 방법이 급상승하고 있다. 이전 논문

data-newbie.tistory.com

https://medium.com/@msmapark2/character-region-awareness-for-text-detection-craft-paper-%EB%B6%84%EC%84%9D-da987b32609c

 

Character Region Awareness for Text Detection — CRAFT paper 분석

딥러닝 기반 OCR 스터디 — CRAFT 논문 리뷰

medium.com

 

반응형

+ Recent posts