Created
June 6, 2018 08:15
-
-
Save arthurdouillard/f74efcac217c3b0e836de3cf91adbf4f to your computer and use it in GitHub Desktop.
This file contains 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 jaccard(box_a, box_b): | |
"""box_X is a tuple of the shape (x1, y1, x2, y2).""" | |
side1 = max(0, min(a[2], b[2]) - max(a[0], b[0])) | |
side2 = max(0, min(a[3], b[3]) - max(a[1], b[1])) | |
inter = side1 * side2 | |
area_a = (a[2] - a[0]) * (a[3] - a[1]) | |
area_b = (b[2] - b[0]) * (b[3] - b[1]) | |
union = area_a + area_b - inter | |
return inter / union | |
def is_valid(box_pred, box_true, threshold=0.3): | |
return jaccard(box_red, box_true) >= threshold | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks like
should be