Created
May 19, 2018 12:43
-
-
Save syshen/2bb6cac2116a9390144f027938791050 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
nonMaxSuppression: function(scores, boxes) { | |
const self = this | |
let zipped = [] | |
for (let i = 0; i < scores.length; i++) { | |
zipped.push([ | |
scores[i], [boxes[4*i], boxes[4*i + 1], boxes[4*i + 2], boxes[4*i + 3]], i | |
]) | |
} | |
// sort by score | |
const sorted = zipped.sort((a, b) => b[0] - a[0]) | |
const selected = [] | |
sorted.forEach(box => { | |
let toAdd = true | |
for (let i = 0; i < selected.length; i++) { | |
const iou = self.box_iou(box[1], selected[i][1]) | |
if (iou > 0.5) { | |
toAdd = false | |
} | |
} | |
if (toAdd) { | |
selected.push(box) | |
} | |
}) | |
return selected | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very good example!