TrainingTesseract 4.00 Finetune 迁移学习
参考文档: https://github.com/tesseract-ocr/tesseract/wiki/TrainingTesseract-4.00---Finetune
依赖项准备
在终端键入以下命令,准备训练依赖项:
- git clone https://github.com/tesseract-ocr/tesseract.git
- git clone https://github.com/tesseract-ocr/langdata.git
- git clone https://github.com/tesseract-ocr/tessdata.git
- cp ./tessdata/eng.traineddata ./tesseract/tessdata
- cp ./tessdata/chi_sim.traineddata ./tesseract/tessdata
开始训练
- 进入tesseract项目目录: cd ./tesseract
- 键入训练命令:
training/tesstrain.sh --fonts_dir /usr/share/fonts --training_text ../training_data/part.txt --langdata_dir ../langdata --tessdata_dir ./tessdata --lang chi_sim --linedata_only --noextract_font_properties --exposures "0" --fontlist "SIMSUN" --output_dir ~/tesstutorial/chitest
- mkdir -p ~/tesstutorial/chituned_from_chisim
- combine_tessdata -e ../tessdata/chi_sim.traineddata ~/tesstutorial/chituned_from_chisim/chi_sim.lstm
- lstm训练
lstmtraining --model_output ~/tesstutorial/chituned_from_chisim/chituned --continue_from ~/tesstutorial/chituned_from_chisim/chi_sim.lstm --train_listfile ~/tesstutorial/chitest/chi_sim.training_files.txt --eval_listfile ~/tesstutorial/chitest/chi_sim.training_files.txt --target_error_rate 0.01
lstmtraining --model_output ~/tesstutorial/chituned_from_chisim/chituned.lstm \
--continue_from ~/tesstutorial/chituned_from_chisim/chituned_checkpoint \
--stop_training
combine_tessdata -o ./tessdata/chi_sim.traineddata \
~/tesstutorial/chituned_from_chisim/chituned.lstm \
~/tesstutorial/chitest/chi_sim.lstm-number-dawg \
~/tesstutorial/chitest/chi_sim.lstm-punc-dawg \
~/tesstutorial/chitest/chi_sim.lstm-word-dawg
测试
training/lstmeval --model ~/tesstutorial/chituned_from_chisim/chi_sim.lstm \
--eval_listfile ~/tesstutorial/chitest/chi_sim.training_files.txt
training/lstmeval --model ~/tesstutorial/chituned_from_chisim/chituned_checkpoint \
--eval_listfile ~/tesstutorial/chitest/chi_sim.training_files.txt
training/lstmeval --model ~/tesstutorial/chituned_from_chisim/chituned.lstm \
--eval_listfile ~/tesstutorial/chitest/chi_sim.training_files.txt
tesseract ../training_data/00.jpg ../training_data/output -l chi_sim -psm 7
cp ../tessdata/chi_sim* ./tessdata
TrainingTesseract 4.00 Replacing Top Layer 迁移学习
training/tesstrain.sh --fonts_dir /usr/share/fonts --lang chi_sim \
--training_text ../training_data/part.txt \
--linedata_only --noextract_font_properties \
--langdata_dir ../langdata --tessdata_dir ./tessdata \
--output_dir ~/tesstutorial/chisim
training/tesstrain.sh --fonts_dir /usr/share/fonts --lang nor \
--linedata_only --noextract_font_properties \
--langdata_dir ../langdata --tessdata_dir ./tessdata \
--fontlist "SIMSUN" \
--output_dir ~/tesstutorial/chisimeval
mkdir -p ~/tesstutorial/chisim_layer
combine_tessdata -e ../tessdata/chi_sim.traineddata \
~/tesstutorial/nor_layer/chisim.lstm
lstmtraining -U ~/tesstutorial/chisim/chisim.unicharset \
--script_dir ../langdata --debug_interval 0 \
--continue_from ~/tesstutorial/chisim_layer/chisim.lstm \
--append_index 5 --net_spec '[Lfx256 O1c105]' \
--model_output ~/tesstutorial/chisim_layer/chisimlayer \
--train_listfile ~/tesstutorial/chisim/chisim.training_files.txt \
--eval_listfile ~/tesstutorial/chisimeval/chisim.training_files.txt \
--max_iterations 5000
lstmtraining --model_output ~/tesstutorial/chisim_layer/chisimlayer.lstm \
--continue_from ~/tesstutorial/chisim_layer/chisimlayer_checkpoint \
--stop_training
cp ../tessdata/chi_sim.traineddata ./tessdata
combine_tessdata -o ./tessdata/chi_sim.traineddata \
~/tesstutorial/chisim_layer/chisimlayer.lstm \
~/tesstutorial/chisim/chisim.lstm-number-dawg \
~/tesstutorial/chisim/chisim.lstm-punc-dawg \
~/tesstutorial/chisim/chisim.lstm-word-dawg
网友评论
lstmtraining --model_output ~/tesstutorial/chituned_from_chisim/chituned --continue_from ~/tesstutorial/chituned_from_chisim/chi_sim.lstm --train_listfile ~/tesstutorial/chitest/chi_sim.training_files.txt --eval_listfile ~/tesstutorial/chitest/chi_sim.training_files.txt --target_error_rate 0.01
文中提到这个命令看起来是在训练一种新的中文字体吧? 请问训练需要大概多少时间,几小时?还是几天