ocrmypdf / OCRmyPDF

OCRmyPDF adds an OCR text layer to scanned PDF files, allowing them to be searched
http://ocrmypdf.readthedocs.io/
Mozilla Public License 2.0
13.78k stars 1k forks source link

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

Open abclution opened 3 months ago

abclution commented 3 months ago

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.

hcoona commented 3 months ago

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

hcoona commented 3 months ago

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

hcoona commented 3 months ago

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

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