Skip to content

Commit 841f579

Browse files
committed
fix ocr when bs > 1
1 parent 5e20d50 commit 841f579

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

paddlex/inference/components/task_related/text_rec.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,9 @@ def __init__(self, character_list=None, use_space_char=True):
283283

284284
def apply(self, pred):
285285
"""apply"""
286-
preds = np.array(pred[0])
287-
preds_idx = preds.argmax(axis=2)
288-
preds_prob = preds.max(axis=2)
286+
preds = np.array(pred)
287+
preds_idx = preds.argmax(axis=-1).squeeze(axis=1)
288+
preds_prob = preds.max(axis=-1).squeeze(axis=1)
289289
text = self.decode(preds_idx, preds_prob, is_remove_duplicate=True)
290290
return [{"rec_text": t[0], "rec_score": t[1]} for t in text]
291291

0 commit comments

Comments
 (0)