Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python EasyOCR Is Taking Too Long To Just Get Started And It Shows Some Progress Percentages Alo

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.

like image 412
Syed_Hamza_Akbar_Ali Avatar asked Oct 18 '25 11:10

Syed_Hamza_Akbar_Ali


1 Answers

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.

like image 58
Hùng Nguyễn Avatar answered Oct 20 '25 23:10

Hùng Nguyễn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!