简体   繁体   English

Python EasyOCR 刚开始用的时间太长,它显示一些进度百分比 Alo

[英]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.我正在 python 中构建一个桌面应用程序,它允许用户截取屏幕截图并阅读图像中的文本。 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.为此,我正在使用 EasyOCR,但问题是,每当我将图像传递给 EasyOCR 时,我的闲置/终端会显示一些下载进度,这需要非常长的时间并导致我的程序冻结。

The download progress I get is given below:我得到的下载进度如下:

选择文字识别图片后的下载进度

The code I have written related to EasyOCR is given below:下面是我写的与EasyOCR相关的代码:

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.值得一提的是,我没有 GPU,当我下载 pytorch 时,我选择了仅支持 CPU 的稳定版本。

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.此外,我知道当 verbose 属性设置为 False 时,下载进度会消失,但我的程序仍然需要一分多钟才能读取图像中的文本并显示它。

How do I make it faster that it takes about 10 seconds at most to process the image and return the text?如何使处理图像和返回文本最多需要大约 10 秒的时间变得更快?

Thanks.谢谢。

You cannot make it faster.你不能让它更快。 OCRing is a computing extensive process. OCRing 是一个计算广泛的过程。 Only better systems can increase the speed.只有更好的系统才能提高速度。

You can make it faster by not loading the model every time you want to perform inference.您可以通过不在每次要执行推理时加载 model 来使其更快。 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.您还可以增加 batch_size 以提高性能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM