diff --git a/hub_module/modules/image/text_recognition/chinese_ocr_db_crnn_mobile/module.py b/hub_module/modules/image/text_recognition/chinese_ocr_db_crnn_mobile/module.py index 9d8f2d49672ed0e719f0c679cfafa436d3c64a4d..490bba80765e5c15099001ce5abe65f8e504ab1a 100644 --- a/hub_module/modules/image/text_recognition/chinese_ocr_db_crnn_mobile/module.py +++ b/hub_module/modules/image/text_recognition/chinese_ocr_db_crnn_mobile/module.py @@ -25,7 +25,7 @@ from chinese_ocr_db_crnn_mobile.utils import base64_to_cv2, draw_ocr, get_image_ @moduleinfo( name="chinese_ocr_db_crnn_mobile", - version="1.0.2", + version="1.0.3", summary= "The module can recognize the chinese texts in an image. Firstly, it will detect the text box positions based on the differentiable_binarization_chn module. Then it recognizes the chinese texts. ", author="paddle-dev", @@ -308,6 +308,8 @@ class ChineseOCRDBCRNN(hub.Module): ind = np.argmax(probs, axis=1) blank = probs.shape[1] valid_ind = np.where(ind != (blank - 1))[0] + if len(valid_ind) == 0: + continue score = np.mean(probs[valid_ind, ind[valid_ind]]) rec_res.append([preds_text, score]) diff --git a/hub_module/modules/image/text_recognition/chinese_ocr_db_crnn_server/module.py b/hub_module/modules/image/text_recognition/chinese_ocr_db_crnn_server/module.py index d638763b2481d779c15073e301b9f6346cc5251f..2c82cdba4976209b1726a17df8687ed875e9b830 100644 --- a/hub_module/modules/image/text_recognition/chinese_ocr_db_crnn_server/module.py +++ b/hub_module/modules/image/text_recognition/chinese_ocr_db_crnn_server/module.py @@ -25,7 +25,7 @@ from chinese_ocr_db_crnn_server.utils import base64_to_cv2, draw_ocr, get_image_ @moduleinfo( name="chinese_ocr_db_crnn_server", - version="1.0.1", + version="1.0.2", summary= "The module can recognize the chinese texts in an image. Firstly, it will detect the text box positions based on the differentiable_binarization_chn module. Then it recognizes the chinese texts. ", author="paddle-dev", @@ -308,6 +308,8 @@ class ChineseOCRDBCRNNServer(hub.Module): ind = np.argmax(probs, axis=1) blank = probs.shape[1] valid_ind = np.where(ind != (blank - 1))[0] + if len(valid_ind) == 0: + continue score = np.mean(probs[valid_ind, ind[valid_ind]]) rec_res.append([preds_text, score])