Google Attention OCR을 기반으로 한글이 포함된 이미지를 인식할 수 있도록 학습.
CRAFT + deep text recognition 처럼 detection + recognition 두 모델이 함께 사용되며, 두 모델에 대해서 각각 학습이 이뤄집니다.
end-to-end의 attention 구조를 사용한 모델입니다.
자세한 내용은 논문을 참조하세요
"Attention-based Extraction of Structured Information from Street View Imagery"
Attention OCR Chinese Version을 함께 참조했습니다.
환경은 Ubuntu 18.04환경에서 python 3.6에서 모델을 실행
가장 쉽게 실행해 볼 수 있는 예제는 License Plates(자동차 번호판)를 예를 들면,
1) object detection 모델을 사용해서 License plates를 detection하고,
2) detection된 bounding box를 입력으로 attention ocr을 실행해서 recognition 진행
1. 환경 구성
pip install --upgrade tensorflow-gpu=1.15
2. 한글, 숫자 및 특수 문자를 포함하는 200개 내외의 dictionary 생성 (확장은 추후 예정)
dictionary 파일은 dic.txt를 만들고, 사용되는 숫자, 특수 문자 및 한글을 다음과 같은 포맷에 맞춰서 저장
0 \t A
1 \t 가
2 \t 나
3 \t 다
4 \t 라
5 \t ?
...
index tab 문자(한글, 숫자, 영문자, 특수 문자)
3. 글자를 포함하는 이미지 준비 (dict.txt에 추가된 문자)
학습을 위한 이미지
예)
1.jpg [학습 이미지]
1.txt [label 파일]
123가4568 [번호판]
4. FSNS format의 한글 custom dataset으로 tfrecord를 만듦
FSNS format의 tfrecord를 생성하는 코드는 해당 사이트를 참조.
https://github.com/A-bone1/FSNS-tfrecord-generate
한국어 OCR를 위한 tfrecord 생성 (FSNS-tfrecord-generate) (tistory.com)
5. 한글 데이터셋을 포함하는 tfrecord로 학습 진행
python train.py --dataset_name=newtextdataset
6. 학습된 모델 evaluation
python eval.py
7. 학습된 모델 사용
python demo_inference.py --batch_size=16 --checkpoint=model.ckpt-300000
--image_path_pattern=./datasets/data/test_%02d.png
자세한 내용은 계속해서 업데이트 예정
'Deep Learning' 카테고리의 다른 글
annotation tool roLabelImg 설치 (pyqt5) (0) | 2021.01.08 |
---|---|
한국어 OCR를 위한 tfrecord 생성 (FSNS-tfrecord-generate) (2) | 2021.01.04 |
Data Augmentation(데이터 증강)을 위한 Image Processing(영상처리) (0) | 2020.10.12 |
Jupyter notebook 원격으로 사용하기 (0) | 2020.10.07 |
미분 계산기 (Derivative Calculator) (0) | 2019.07.02 |