tesseract 4 box files format

314 views
Skip to first unread message

thebigwasp

unread,
Feb 4, 2019, 6:15:09 AM2/4/19
to tesseract-ocr
Hello, after reading article about training Tesseract 4 (https://github.com/tesseract-ocr/tesseract/wiki/TrainingTesseract-4.00) I found it very confusing.

My goal is to train existing model with new tiff/box pairs. After hours of googling how to generate box files I found all this:
1) https://github.com/tesseract-ocr/tesseract/wiki/Making-Box-Files---4.0 - Tesseract 4 wiki article about box files. States that "boxes only need to cover a textline instead of individual characters", but in the example of box file just below we can see that boxes covers individual characters.
2) https://groups.google.com/d/msg/tesseract-ocr/6lL4j-4Qnd4/Aj1lX7PzHQAJ - guy stating that "lstm training using box/tiff files is NOT supported".
3) https://groups.google.com/d/msg/tesseract-ocr/22ynsbXqFsw/2k32tGwSGAAJ - same guy stating that it's possible to "use the bounding box for the whole line for every character on a line".

^ All this combined confuses me.

My questions is:
1) Is it possible to fine tune existing model using tiff/box pairs ?
2) If yes, what format should I use to generate box files ? Please provide an example of box file in English with multiple lines and multiple words in each line.

Please guide the lost soul.
Thank you.

thebigwasp

unread,
Feb 4, 2019, 6:32:32 AM2/4/19
to tesseract-ocr
Also, what if there are huge gaps between words in line on picture? If I set bounding box for the whole line, can Tesseract learn on that ?

thebigwasp

unread,
Feb 9, 2019, 7:16:42 AM2/9/19
to tesseract-ocr
Ok, I managed to fine tune existing model using tiff/box pairs. In box files i used so called WordStr format that is described here: https://github.com/tesseract-ocr/tesseract/blob/3ac33d59aeb93fc9dab13874a64ab0b73690d5eb/src/ccmain/applybox.cpp#L36. I think this description is totally right, except for this part:

 * word -> #w o r d
 * multi word line -> #m u l t i w o r d l i n e

After training with this format ^, the network put each character in separate word.
The right description for WordStr format should be:

 * word -> #word
 
* multi word line -> #multi word line

When used this format ^, I got desired results.

Also I have a guess why the above format is actually right. See this discussion: https://github.com/tesseract-ocr/tesseract/issues/1276


Example of right WordStr format is in the attached files.
text.box
text.jpg

Shree Devi Kumar

unread,
Feb 9, 2019, 1:08:30 PM2/9/19
to tesser...@googlegroups.com
This is good to know.

What languages did you test this for?


--
You received this message because you are subscribed to the Google Groups "tesseract-ocr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tesseract-oc...@googlegroups.com.
To post to this group, send email to tesser...@googlegroups.com.
Visit this group at https://groups.google.com/group/tesseract-ocr.
To view this discussion on the web visit https://groups.google.com/d/msgid/tesseract-ocr/131a5055-8a69-48ce-bed0-89a79dd75d3e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

____________________________________________________________
भजन - कीर्तन - आरती @ http://bhajans.ramparivar.com

thebigwasp

unread,
Feb 9, 2019, 3:02:26 PM2/9/19
to tesseract-ocr
I tested it for russian language.

Shree Devi Kumar

unread,
Feb 10, 2019, 1:27:42 PM2/10/19
to tesser...@googlegroups.com
Thank you! I tested today for both English and Hindi and your suggested format worked perfectly.

I had tested earlier for Hindi language with the WordStr format as described in the code and that had not worked well.

I will test further with RTL and CJK languages and also make a PR to create WordStr box files from images.

On Sun, Feb 10, 2019 at 1:32 AM thebigwasp <thebi...@gmail.com> wrote:
I tested it for russian language.

--
You received this message because you are subscribed to the Google Groups "tesseract-ocr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tesseract-oc...@googlegroups.com.
To post to this group, send email to tesser...@googlegroups.com.
Visit this group at https://groups.google.com/group/tesseract-ocr.

For more options, visit https://groups.google.com/d/optout.

shree

unread,
Feb 28, 2019, 6:27:58 AM2/28/19
to tesseract-ocr
https://github.com/tesseract-ocr/tesseract/pull/2231 implements the Wordstr box file option.

These box files are for each textline and can be easily edited for non-RTL languages. 

example usage to create box files for english language images p001.png to p015.png

 
for i in $(seq -f "%03g" 1 15) ; do
     tesseract
/path/to/myimages/p$i.png \
       
/path/to/myimages/p$i -l eng --psm 6 wordstrbox
 
done



 
Reply all
Reply to author
Forward
0 new messages