ocropus-archive / DUP-ocropy

Python-based tools for document analysis and OCR
Apache License 2.0
3.41k stars 590 forks source link

Implemented computation of probability matrix #279

Open BingqingQu opened 6 years ago

BingqingQu commented 6 years ago

This is intended to be an extension of the --probabilities. Instead of just printing the probabilities for the recognised characters, --probmat will compute the complete probability matrix.

At each "timestep" the probability for each character is computed. This can/could be used as input to a language model for example where one would have access to the probabilities of other characters as well.

zuphilip commented 6 years ago

Is your code complete? It looks that the variables out and timestamp are not used further...

Can you give more information about the output format? I see that the files have always 156 lines with several probalities, but none of these values seem to be equal the ones which are outputed with --probabilities.

amitdo commented 6 years ago

https://github.com/tmbdev/ocropy/wiki/OCRopus-File-Formats#lattice-files This format was used in ocropy 0.6.

zuphilip commented 6 years ago

@amitdo The outputed files look differently. Here is an example:

010001.pm.txt 010001.prob.txt

amitdo commented 6 years ago

His patch just outputs the raw result of the prediction.

What you see with the current (without this parch) text/prob. options is the 'best' path that translate_back() found for you.

The format in my link is more human readable. I was not very clear in my previous comment, sorry about that.

amitdo commented 6 years ago

Related: #25

amitdo commented 6 years ago

The number of lines (156) is the size of the codec (chars) in the model you use.

zuphilip commented 6 years ago

Okay, I don't think that this matrix is then enough interesting for an option to ocropus-rpred. One can use ocrolib as a library for such computations. More advanced lattice/alternative calculations could be interesting as outlined in #186.

zuphilip commented 6 years ago

There is also the --save and --show option for a visual debug info about these matrix.