From cd8d52d74616d81fb9b02c70f536c1c0f905b739 Mon Sep 17 00:00:00 2001 From: cc <52520497+juncaipeng@users.noreply.github.com> Date: Wed, 2 Mar 2022 20:37:37 +0800 Subject: [PATCH] [Fix] Fix the overflow error in calculating kappa (#1788) --- paddleseg/utils/metrics.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/paddleseg/utils/metrics.py b/paddleseg/utils/metrics.py index cbc4aec592..fb0ca49919 100644 --- a/paddleseg/utils/metrics.py +++ b/paddleseg/utils/metrics.py @@ -200,9 +200,9 @@ def kappa(intersect_area, pred_area, label_area): Returns: float: kappa coefficient. """ - intersect_area = intersect_area.numpy() - pred_area = pred_area.numpy() - label_area = label_area.numpy() + intersect_area = intersect_area.numpy().astype(np.float64) + pred_area = pred_area.numpy().astype(np.float64) + label_area = label_area.numpy().astype(np.float64) total_area = np.sum(label_area) po = np.sum(intersect_area) / total_area pe = np.sum(pred_area * label_area) / (total_area * total_area)