π Awesome OCR multiple programing languages toolkits based on ONNX Runtime, OpenVINO, MNN, PaddlePaddle, TensorRT and PyTorch.
fix(python): Modify the way CTCLabelDecode calculates confidence (#179)
Dolen41a23c031c67
diff --git a/python/rapidocr_onnxruntime/ch_ppocr_v3_rec/utils.py b/python/rapidocr_onnxruntime/ch_ppocr_v3_rec/utils.pyindex 8173787..6e63a87 100644--- a/python/rapidocr_onnxruntime/ch_ppocr_v3_rec/utils.py+++ b/python/rapidocr_onnxruntime/ch_ppocr_v3_rec/utils.py@@ -69,5 +69,5 @@ class CTCLabelDecode:else:conf_list.append(1)text = "".join(char_list)- result_list.append((text, np.mean(conf_list + [1e-50])))+ result_list.append((text, np.mean(conf_list if any(conf_list) else [0])))return result_listdiff --git a/python/rapidocr_openvino/ch_ppocr_v3_rec/utils.py b/python/rapidocr_openvino/ch_ppocr_v3_rec/utils.pyindex 9587af3..f26c369 100644--- a/python/rapidocr_openvino/ch_ppocr_v3_rec/utils.py+++ b/python/rapidocr_openvino/ch_ppocr_v3_rec/utils.py@@ -67,5 +67,5 @@ class CTCLabelDecode:else:conf_list.append(1)text = "".join(char_list)- result_list.append((text, np.mean(conf_list + [1e-50])))+ result_list.append((text, np.mean(conf_list if any(conf_list) else [0])))return result_listdiff --git a/python/rapidocr_paddle/ch_ppocr_v3_rec/utils.py b/python/rapidocr_paddle/ch_ppocr_v3_rec/utils.pyindex 1cde519..b590f5d 100644--- a/python/rapidocr_paddle/ch_ppocr_v3_rec/utils.py+++ b/python/rapidocr_paddle/ch_ppocr_v3_rec/utils.py@@ -71,5 +71,5 @@ class CTCLabelDecode:else:conf_list.append(1)text = "".join(char_list)- result_list.append((text, np.mean(conf_list + [1e-50])))+ result_list.append((text, np.mean(conf_list if any(conf_list) else [0])))return result_list