How to train Tesseract From Scratch?

Viewed 18

I want to train tesseract from scratch, so, I refer to the documentation of tesseract4 and tesseract5. As follows : tesseract5 tesseract4 I followed the steps and got no errors, but the results were terrible . After training, the synthesized .traineddata file, I use it to try to test, all errors, almost none of them are correct .

Here are my steps First, I created a new text named num.txt, this is its content : 0123456789

Yes , I just want to train a .traineddata with only numbers from scratch .

Next, I generated a unicharset file from num.txt : unicharset_extractor --norm_mode 3 --output_unicharset .\num.lstm-unicharset num.txt

Generate starter traineddata file (langdata_lstm-main is the unzipped folder of langdata downloaded from github): combine_lang_model --input_unicharset num.lstm-unicharset --lang chi_sim --script_dir .\langdata_lstm-main --output_dir .\ --version_str "num:20220908[1,48,0,1Ct3,3,16Mp3,3Lfys64Lfx96Lrx96Lfx512O1c1]" --pass_through_recoder true

Next, prepare the pictures and box files required for training. The text2image command I used directly here generates .tif and .box files. View .tif and corresponding .box files through jTessBoxEditorFX .box file content

Generate .lstmf file tesseract train.tif train -l chi_sim --psm 7 lstm.train

Create a new text train_listfile.txt . Write the path where the lstmf file is located

trained lstmtraining --traineddata .\chi_sim\chi_sim.traineddata --net_spec "[1,48,0,1 Ct3,3,16 Mp3,3 Lfys64 Lfx96 Lrx96 Lfx512 O1c13]" --model_output .\output\output --train_listfile train_listfile.txt --max_iterations 0 --target_error_rate 0.01 --debug_interval 0

Wait for a while, and after training, generate a runnable model lstmtraining --stop_training --continue_from .\output\output_checkpoint --traineddata .\chi_sim\chi_sim.traineddata --model_output .\output\num.traineddata

About 5000 pieces of data were trained, and the following are the appalling test results Test results, the left is the correct answer, the right is the tesseract test result .

I have checked the tesseract documentation many times, but I still don't know the reason . Please help me, almighty netizens

0 Answers
Related