Last active
November 9, 2018 17:10
-
-
Save enric1994/93908a0b7cc8e45d7af0744b0ea6c360 to your computer and use it in GitHub Desktop.
Intersection of Union (IoU). Evaluates the accuracy using the ground truth and the prediction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def eval_iou(img1,img2): | |
m_img1 = img1 > 0 | |
img1[m_img1] = 1 | |
m_img2 = img2 > 0 | |
img2[m_img2] = 1 | |
overlap = img1*img2 | |
union = img1 + img2 | |
return overlap.sum()/float(union.sum()) * 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment