Skip to content

Commit

Permalink
[Fix] Fix the overflow error in calculating kappa (#1788)
Browse files Browse the repository at this point in the history
  • Loading branch information
juncaipeng authored Mar 2, 2022
1 parent e88279d commit f665b18
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions paddleseg/utils/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f665b18

Please sign in to comment.