3

I'm building a desktop app in python which allows the user to take screenshots of the screen and read text in the image. I'm using EasyOCR for that, but the problem is that whenever I pass the image to EasyOCR, my idle/terminal shows some download progress which takes extremely long and causes my program to freeze.

The download progress I get is given below:

The Download Progress After I Choose The Image for Text Recognition

The code I have written related to EasyOCR is given below:

def processImg():
    global chosenImgFile
    isImgChosen = chosenImgFile.find(".png") or chosenImgFile.find(".jpeg")
    if isImgChosen != -1:
        chosenImgFile = cv2.imread(chosenImgFile)
        imageReader = ocr.Reader(["en"], gpu=False, verbose=False)
        readTxt = imageReader.readtext(chosenImgFile)

It is worth mentioning that I don't have a GPU and when I downloaded pytorch I chose the stable version with CPU support ONLY.

Also, I know that when the verbose property is set to False, the download progress goes away, BUT my program is still taking more than a minute to just read the text in the image and show it.

How do I make it faster that it takes about 10 seconds at most to process the image and return the text?

Thanks.

2 Answers2

3

You can make it faster by not loading the model every time you want to perform inference. By doing so

reader = easyocr.Reader(['en'], detector='dbnet18')
for img in imagesPIL:
    result =  reader.readtext(img , batch_size=5) 

You can also increase batch_size to improve performance.

0

You cannot make it faster. OCRing is a computing extensive process. Only better systems can increase the speed.

Arnav Mehta
  • 67
  • 1
  • 7