Skip to content

Instantly share code, notes, and snippets.

@enric1994
Last active November 9, 2018 17:10
Show Gist options
  • Save enric1994/93908a0b7cc8e45d7af0744b0ea6c360 to your computer and use it in GitHub Desktop.
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
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