[英]I am trying to run inference on a single GPU with easyocr. I have tried running below codes:
def EasyOcrTextbatch(self):
batchsize=16
reader = easyocr.Reader(['en'],cudnn_benchmark=True)
# reader = easyocr.Reader(['en'],gpu=False)
# dummy = np.zeros([8,512,384,3], dtype=np.uint8)
# paragraph=reader.readtext_batched(dummy)
paragraph=reader.readtext_batched(self.imglist,batch_size=batchsize)
#paragraph = reader.readtext(self.imglist, batch_size=batchsize, paragraph=True,
detail=0)
del reader
gc.collect()
torch.cuda.empty_cache()
return paragraph
The above code does not speed up and to my surprise running it sequentially was faster.Below code is faster than the above one.上面的代码并没有加速,令我惊讶的是顺序运行它更快。下面的代码比上面的代码快。
def EasyOcrTextSequence(self,):
reader = easyocr.Reader(['en'])
#reader = easyocr.Reader(['en'],cudnn_benchmark=False)
# dummy = np.zeros([32, 256, 256, 1], dtype=np.uint8)
k=[cv2.cvtColor(cv2.imread(i), cv2.COLOR_BGR2GRAY) for i in self.imglist]
self.arr = np.array(k)
j=[reader.readtext(i,paragraph=True,detail=0,batch_size=16) for i in self.arr]
del reader
return j
The average time for single images comes at.34 seconds and I want to reduce it a lot.Things I have tried:单个图像的平均时间为 34 秒,我想减少很多。我尝试过的事情:
Please help me out if you have any suggestion for using easyocr in inference so that the latency should be lowest (Need to process as many images possible within a second).Also I am open for trying different open-source ocr,my only constraint is it should be very fast with good accuracy.如果您对在推理中使用 easyocr 有任何建议,请帮助我,以便延迟应该最低(需要在一秒钟内处理尽可能多的图像)。我也愿意尝试不同的开源 ocr,我唯一的限制是它应该非常快且准确度很高。
List comprehensions are normally a good performance increaser.列表推导通常是一个很好的性能提升器。 They can implemented like this
他们可以这样实现
def EasyOcrTextSequence(self,):
reader = easyocr.Reader(['en'])
images = (cv2.imread(img) for img in self.imglist)
images_grayscaled = (cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) for img in images)
self.arr = np.array(images_grayscaled)
return (reader.readtext(i,paragraph=True,detail=0,batch_size=16) for i in self.arr)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.