Skip to content

Tesseract Training Steps

Tesseract Training Steps

SETUP / DOWNLOADS

PROCEDURE

  • Train Tesseract using scanned image(s)
  • Filename format: [language].[font name].exp[num]
  • input file (sample): eng2.FontName001.exp0.tiff
  • language: eng2
  • font: FontName001
  • Deskew image (auto rotate)
> deskew.exe -b FFFFFF -o eng2.FontName001.exp0.deskew.tiff eng2.FontName001.exp0.tiff
> move /Y eng2.FontName001.exp0.tiff eng2.FontName001.exp0.tiff.original
> move /Y eng2.FontName001.exp0.deskew.tiff eng2.FontName001.exp0.tiff
  • Create box file - contains exact locations of each found characters / shapes
    > tesseract.exe eng2.FontName001.exp0.tiff eng2.FontName001.exp0 batch.nochop makebox 
    
  • In batch, the following can be used: tesseract.exe %1 %~n1 batch.nochop makebox
  • this process will create box file: eng2.FontName001.exp0.box

Start qt-box-editor-1.08.exe and fix invalid mappings. Save fixed box file.

Run the following command to start training

> tesseract eng2.FontName001.exp0.tiff eng2.FontName001.exp0 nobatch box.train

Detect the Character set used in your box files (can pass *.box for all box files):

> unicharset_extractor eng2.FontName001.exp0.box
Create a font_properties file or add to the existing one
# font name <italic> <bold> <fixed> <serif> <fraktur> 
> echo FontName001 0 0 0 0 0 > font_properties 

  • you may add more lines for each of the types, Ex. for bold: FontName001 0 1 0 0 0 Execute shape clustering routine based on the font properties
    > shapeclustering -F font_properties -U unicharset eng2.FontName001.exp0.tr
    

Run Training using MF and CN training executables

> mftraining -F font_properties -U unicharset -O eng2.unicharset eng2.FontName001.exp0.tr
> cntraining eng2.FontName001.exp0.tr
Prefix relevant files with language code
> move /Y inttemp eng2.inttemp
> move /Y normproto eng2.normproto
> move /Y pffmtable eng2.pffmtable
> move /Y shapetable eng2.shapetable

Combine data into tessdata format (dot at the ned is important)

> combine_tessdata eng2.

Copy newly generated trained data file into the tessdata folder

> copy eng2.traineddata .\tessdata

Now you can run tesseract to get text into trained-output.txt file

> tesseract eng2.FontName001.exp0.tiff trained-output.txt -l eng2