Optimize ocr (#5297)

### What problem does this PR solve?

Introduced OCR.recognize_batch

### Type of change

- [x] Performance Improvement
This commit is contained in:
Zhichang Yu
2025-02-24 16:21:55 +08:00
committed by GitHub
parent df3d0f61bd
commit db42d0e0ae
3 changed files with 67 additions and 20 deletions

View File

@ -620,6 +620,16 @@ class OCR(object):
return ""
return text
def recognize_batch(self, img_list):
rec_res, elapse = self.text_recognizer(img_list)
texts = []
for i in range(len(rec_res)):
text, score = rec_res[i]
if score < self.drop_score:
text = ""
texts.append(text)
return texts
def __call__(self, img, cls=True):
time_dict = {'det': 0, 'rec': 0, 'cls': 0, 'all': 0}