All problems
Soft-NMS Gaussian Weights
Problem
Compute the Gaussian soft-NMS decay weights of candidate boxes relative to a kept box.
Each weight is exp(-IoU^2 / sigma), so overlapping neighbors keep a shrunken score instead of being deleted. Return the weights in order rounded to 4 decimal places; a non-positive sigma gives 0.0.
Test cases
case 1
in: [[0,0,2,2],[[0,0,2,2],[0,0,4,4],[10,0,12,2]],0.5]
expected: [0.1353,0.8825,1]
case 2
in: [[0,0,2,2],[[1,1,3,3],[0,0,1,1]],1]
expected: [0.9798,0.9394]
case 3
in: [[0,0,2,2],[],0.5]
expected: []
case 4
in: [[0,0,2,2],[[0,0,2,2]],0]
expected: [0]
Starter codePython
def soft_nms_gaussian_weights(box, boxes, sigma):
# Your code here
pass4 test cases · run your code against them in the editor