tesseract-ocr / tesseract

Tesseract Open Source OCR Engine (main repository)
https://tesseract-ocr.github.io/
Apache License 2.0
61.85k stars 9.47k forks source link

Arabic training data has room for improvement #2047

Open mustafa0x opened 5 years ago

mustafa0x commented 5 years ago

I just installed Tesseteract 4.0.0 (see: Environment), OCR'ed a sample document using ara and arab-script, and found that the ara-amiri-3000 training data (created by @Shreeshrii) continues to be superior, which is consistent to my more rigorous testing in the beta 1 days (see: https://github.com/tesseract-ocr/tessdata_best/issues/11#issuecomment-400550328).

I also noticed that the Arabic comma is still not recognized (it is by ara-amiri-3000), and nor are the Indic numerals (most of the time). I created an issue to add these to the Arabic langdata, but haven't yet received a response (https://github.com/tesseract-ocr/langdata/issues/131).

Related: It's possible that using the Scheherazade font for training will give better results, as it's very similar to Lotus Light — the font used by most printed Arabic books.

Thanks!


Environment

~# lsb_release -a
Description: Ubuntu 18.04.1 LTS
~# add-apt-repository ppa:alex-p/tesseract-ocr
~# apt update
~# apt install tesseract-ocr tesseract-ocr-ara tesseract-ocr-script-arab
~# tesseract --version
tesseract 4.0.0
 leptonica-1.76.0
  libgif 5.1.4 : libjpeg 8d (libjpeg-turbo 1.5.2) : libpng 1.6.34 : libtiff 4.0.9 : zlib 1.2.11 : libwebp 0.6.1 : libopenjp2 2.3.0
AndreAhmed commented 5 years ago

@mustafa0x Can you upload the amiri dataset ?

amitdo commented 5 years ago

https://github.com/tesseract-ocr/tessdata_best/issues/11 https://github.com/Shreeshrii/tessdata_shreetest/tree/72294b8476b9

Shreeshrii commented 5 years ago

It seems like I messed up and overwrote the files in that repository in a way that lost the old files.

If someone has a copy of the traineddata, please attach to this thread and I will upload again. thanks.

On Thu, 22 Nov 2018, 11:34 Amit D. <notifications@github.com wrote:

tesseract-ocr/tessdata_best#11 https://github.com/tesseract-ocr/tessdata_best/issues/11 https://github.com/Shreeshrii/tessdata_shreetest/tree/72294b8476b9

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tesseract-ocr/tesseract/issues/2047#issuecomment-441079561, or mute the thread https://github.com/notifications/unsubscribe-auth/AE2_o8UVQeCKZ0ZyN_K9AjLweOxwQyMbks5uxtH9gaJpZM4YWcRb .

mustafa0x commented 5 years ago

@Shreeshrii: @amitdo was able to very-impressively pull it up.

Shreeshrii commented 5 years ago

Thnaks @amitdo. I have now re-uploaded (there might have been a git way to do so, but it was easier for me to download and then upload).

Glad that the finetuned traineddata files are helpful for people.

On Thu, Nov 22, 2018 at 2:14 PM mustafa0x notifications@github.com wrote:

@Shreeshrii https://github.com/Shreeshrii: @amitdo https://github.com/amitdo was able to very-impressively pull it up.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tesseract-ocr/tesseract/issues/2047#issuecomment-441106498, or mute the thread https://github.com/notifications/unsubscribe-auth/AE2_o_eJNmJSvSms91Xp7ckwWKTA-edKks5uxvezgaJpZM4YWcRb .

--


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

AndreAhmed commented 5 years ago

Your dataset doesn't work with number and arabic text combined together

Shreeshrii commented 5 years ago

Please send a small sample Arabic text with proper usage of digits, text and other punctuation and I can try to fine-tune with it.

On Fri, 23 Nov 2018, 11:51 andreahmed <notifications@github.com wrote:

Your dataset doesn't work with number and arabic text combined together

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tesseract-ocr/tesseract/issues/2047#issuecomment-441285293, or mute the thread https://github.com/notifications/unsubscribe-auth/AE2_o80fd27GjZls3uuZUVB6XiXKVKBmks5uyCeegaJpZM4YWcRb .

AndreAhmed commented 5 years ago

@amitdo do you have a dataset with arabic numbers and arabic text that @Shreeshrii can use ? I need that urgently.

mustafa0x commented 5 years ago

@Shreeshrii This is nearly 8k characters, 100 of which are Arabic numerals.

sample-arabic.txt

amitdo commented 5 years ago

No, I don't have such a dataset.

AndreAhmed commented 5 years ago

@Shreeshrii do you have any success ? I think it's very complicated, arabic text with numbers doesn't work in that engine

AndreAhmed commented 5 years ago

@Shreeshrii any progress?

mustafa0x commented 5 years ago

@AndreAhmed It's the weekend, it's the holidays, and this is open source work. Please wait until Shreeshrii has some free time to spend on this.

jaddoughman commented 5 years ago

@AndreAhmed @Shreeshrii I happen to have a large dataset of Arabic text, with Arabic numbers and text. I'm having issues fine tuning the original _best model. I will attach the dataset below (composed of ~4000 lines). If you can attempt to fine tune using them, that would be great. train.zip

The generated .box files might be an issue.

AndreAhmed commented 5 years ago

@Shreeshrii @jaddoughman I think there is a major problem with arabic text with numbers including, I'm not sure it's a fine tuning issue, or recognize problem from the OCR itself.

Shreeshrii commented 5 years ago

That is my suspicion also. However we can not know for sure until @theraysmith responds.

From what I understand, while Arabic is written as RTL, Arabic numbers are written as LTR.

The training works by treating all text regard less of language direction as LTR. There is supposed to be a higher level function which changes the language direction. It is possible that there is some problem with that, specially when a number is written with punctuation.

The above is pure speculation on my part.

It is also possible that the problem exists only in github tesseract and not in Google's version.

It will help if someone can create a 2-3 lines minimal test case and test with all varieties of traineddata, with --oem 1 and --oem 0, and also with 3.05 version with cube to see whether problem exists in all cases.

Then it will be easier for @jbredien to check whether same test case works in Google's tesseract.

AndreAhmed commented 5 years ago

I did test with a lot of trained data for simple 3 lines text, it never work at all, there is no recognition of the numbers at all @Shreeshrii

AndreAhmed commented 5 years ago

I debugged it, it can detect numbers at all, that's one problem. Another problem is the combination of arabic letters with numbers, the engine ignores the numbers and it doesn't detect it. Because at first it doesn't recognize the numbers. @Shreeshrii @theraysmith

MariamHijazi commented 5 years ago

I'm trying to generate dataset for Arabic text with Arabic-Indian Numbers with JessEditor, but I guess jTessBoxEditor does not support Arabic-Indian Numbers which is (۰ - ۱ - ۲ - ۳ - ٤ - ٥ - ٦ - ٧ - ۸ - ۹) with Unicode (U+0660 -> U+0669) is there any dataset support Arabic text with Arabic- Indian numbers ? can you add Arabic Indian numbers to JessEditor? Any suggestion for this issue? @Shreeshrii Kind Regards.

jagdishgg commented 5 years ago

I have tried ara.traineddata, ara-amiri-3000.traineddata and Arabic.traineddata on tesseract v4.0.0.20181030 Windows platform. My data has Arabic plus English and English Numericals. All the traineddata giving incorrect results and if I OCred 5 images ( ID cards )of same format, I am getting the results in different formats, Example 4 images giving Name of person on line 9 but 5th one giving on line 10, how do we control that Commands used tesseract "F:\Temp\3\1.jpeg" "F:\Temp\3\out1.txt" -l eng -c tessedit_char_whitelist=01234ABCDE --oem 1 --psm 11 tesseract "F:\Temp\3\1.jpeg" "F:\Temp\3\out1.txt" -l script/arabic --psm 6 tesseract "F:\Temp\3\2.jpeg" "F:\Temp\3\out2.txt" -l script/arabic --psm 11

Shreeshrii commented 5 years ago

Please see tesseract-ocr/tesseract#2263 (comment) and test if the traineddata files linked there add all the required characters.