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 | |
}, |
I would suspect that box_iou is related to calculating the overlap, you can use a library like this: https://www.npmjs.com/package/rectangle-overlap
Very good example!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi syshen,
In your file, you have self.box_iou(), but you haven't instantiated this part.
Do you have in you possession the following please ?