tesseract-OCR windows LSTM finetuning 학습
환경 : windows 10, tesseract 4.x
1. jTessBoxEditor를 사용해서 .tif파일과 .box파일 생성
Tesseract-OCR 폴더에 위 두파일을 복사
2. lstmf 파일 생성
.\tesseract eng.arial.exp0.tif eng.arial.exp0 -l eng --psm 6 lstm.train
3. lstm 파일 생성
.\combine_tessdata -e tessdata/eng.traineddata eng.lstm
4. lstm training(fine tune)
.\lstmtraining --model_output .\model_output/output --continue_from eng.lstm --train_listfile text.training_file.txt --traineddata tessdata/eng.traineddata --debug_interval -1 --max_iterations 400
--traineddata : Path to the starter traineddata file that contains the unicharset, recoder and optional language model.
--model_output : Base path of output model files/checkpoints.
--continue_from : Path to previous checkpoint from which to continue training or fine tune.
--train_listfile : Filename of a file listing training data files.
--debug_interval : If non-zero, show visual debugging every this many iterations.
--max_iterations : Stop training after this many iterations.
- model_output 폴더
* Compute CTC targets failed for eng.arial.exp0.lstmf! 에러가 나면 jTessBoxEditor로 .tif만들때 글자수를 줄여보자
너무 길거나 많으면 error가 나는듯 하다.
4-1. 이어서 학습하기
.\lstmtraining --model_output .\model_output/output --continue_from .\model_output/output_0.361000_12_400.checkpoint --train_listfile text.training_file.txt --traineddata tessdata/eng.traineddata --debug_interval -1 --max_iterations 1000
--continue_from : 이어서 학습시작할 checkpoint 파일 경로
--max_iterations : 이전보다 더 늘려준다
5. new_eng.traineddata 생성
.\lstmtraining --stop_training --continue_from .\model_output/output_0.361000_12_400.checkpoint --traineddata tessdata/eng.traineddata --model_output .\model_output/new_eng.traineddata
5-1. new_eng.traineddata 생성(integer model)
.\lstmtraining --stop_training --continue_from .\model_output/output_0.361000_12_400.checkpoint --traineddata tessdata/eng.traineddata --model_output .\model_output/new_eng.traineddata --convert_to_int True
명령어 뒤에 --convert_to_int True 를 추가한다.
15M -> 5M로 줄어든 모습
참고
https://tesseract-ocr.github.io/tessdoc/tess4/TrainingTesseract-4.00.html