From 6f456775b0998c9fdd9c03c1105359c16c2fb624 Mon Sep 17 00:00:00 2001 From: LDOUBLEV Date: Wed, 1 Jul 2020 13:30:03 +0800 Subject: [PATCH] fix bug --- tools/infer/predict_rec.py | 2 +- tools/infer_rec.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/infer/predict_rec.py b/tools/infer/predict_rec.py index b1538938..9761ddba 100755 --- a/tools/infer/predict_rec.py +++ b/tools/infer/predict_rec.py @@ -122,7 +122,7 @@ class TextRecognizer(object): blank = probs.shape[1] valid_ind = np.where(ind != (blank - 1))[0] score = np.mean(probs[valid_ind, ind[valid_ind]]) - if not valid_ind: + if len(valid_ind) == 0: continue # rec_res.append([preds_text, score]) rec_res[indices[beg_img_no + rno]] = [preds_text, score] diff --git a/tools/infer_rec.py b/tools/infer_rec.py index 6086e499..9abbf076 100755 --- a/tools/infer_rec.py +++ b/tools/infer_rec.py @@ -99,7 +99,7 @@ def main(): ind = np.argmax(probs, axis=1) blank = probs.shape[1] valid_ind = np.where(ind != (blank - 1))[0] - if not valid_ind: + if len(valid_ind) == 0: continue score = np.mean(probs[valid_ind, ind[valid_ind]]) elif loss_type == "attention": -- GitLab