OCRmyPDF icon indicating copy to clipboard operation
OCRmyPDF copied to clipboard

[Feature]: Alternative AI OCR "surya" as opposed to EasyOCR, Just found it today and it dominated the accuracy and speed of Tesseract & EasyOCR

Open abclution opened this issue 1 year ago • 3 comments

Describe the proposed feature

@jbarlow83 First off, thanks for this excellent software.

I wanted to share this amazing AI OCR I came across today, surya https://github.com/VikParuchuri/surya

Its accuracy and speed were miles ahead of both Tesseract and EasyOCR.

I tried to use the EasyOCR plugin, but I had similar issues as reported on the plugin issues page as other users and was in the end unable to use it as part of the OCRmyPDF integrated workflow. This may be due to non Nvidia hardware, but I was able to use EasyOCR outside of OCRmyPDF.

First off, surya has the same problem as EasyOCR, no hOCR output built in for easy plug in play alignment of detected text. It does however export some clearly and simply defined json that I believe a surya json output to hOCR converter would be enough.

Installation of surya is painless enough. As well as it includes a streamlit demo gui to test it quickly. I will put some images here that I was unable to get Tesseract to find any text (red text on pink background, lol) even after pre-processing.

Scaled version of the image sent to surya image

Detected text overlay as image image

Surya Detected Reading Order image

With EasyOCR I encountered errors in the first line of text detected

([[531, 46], [1359, 46], [1359, 90], [531, 90]], 'GENERAL INEQRMATION EQR TAXPAYERS (cont )', 0.4053220359982469)

and the rest of the output continued similarly.

Due to how surya detects the text correctly and the reading order correctly text can indexed for search and in databases more correctly.

Anyways, just thought I would share what I found.

abclution avatar Jun 11 '24 20:06 abclution

Watching. Marker has adopt Surya-OCR and do have a better result.

hcoona avatar Jun 27 '24 02:06 hcoona

It would be better if we can make the OCR engine pluggable and maybe we can add Azure OCR etc.

hcoona avatar Jun 27 '24 02:06 hcoona

I submit an issue to Surya to see if they can support hOCR format.

https://github.com/VikParuchuri/surya/issues/139

hcoona avatar Jun 27 '24 02:06 hcoona

As much as this could be great for performance, I would heed the license of Surya. GPL 3.0 is a strong copyleft license which will require OCRmyPDF to change license too. This in turn will restrict commercial usage of OCRmyPDF.

iiLaurens avatar Oct 29 '24 11:10 iiLaurens

What about a plugin?

drtrigon avatar Nov 10 '24 20:11 drtrigon

As a plugin it would be fine. The plugin should be GPL 3.0 licensed as well. A user of the OCRmyPDF-Surya combination would be bound under GPL 3.0, but the OCRmyPDF project itself would not need to change its license simply because that combination exists.

https://www.gnu.org/licenses/gpl-faq.html#GPLPlugins

jbarlow83 avatar Nov 10 '24 21:11 jbarlow83