This commit is contained in:
LDOUBLEV 2020-07-01 13:30:03 +08:00
parent ed454d1423
commit 6f456775b0
2 changed files with 2 additions and 2 deletions

View File

@ -122,7 +122,7 @@ class TextRecognizer(object):
blank = probs.shape[1] blank = probs.shape[1]
valid_ind = np.where(ind != (blank - 1))[0] valid_ind = np.where(ind != (blank - 1))[0]
score = np.mean(probs[valid_ind, ind[valid_ind]]) score = np.mean(probs[valid_ind, ind[valid_ind]])
if not valid_ind: if len(valid_ind) == 0:
continue continue
# rec_res.append([preds_text, score]) # rec_res.append([preds_text, score])
rec_res[indices[beg_img_no + rno]] = [preds_text, score] rec_res[indices[beg_img_no + rno]] = [preds_text, score]

View File

@ -99,7 +99,7 @@ def main():
ind = np.argmax(probs, axis=1) ind = np.argmax(probs, axis=1)
blank = probs.shape[1] blank = probs.shape[1]
valid_ind = np.where(ind != (blank - 1))[0] valid_ind = np.where(ind != (blank - 1))[0]
if not valid_ind: if len(valid_ind) == 0:
continue continue
score = np.mean(probs[valid_ind, ind[valid_ind]]) score = np.mean(probs[valid_ind, ind[valid_ind]])
elif loss_type == "attention": elif loss_type == "attention":