Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-204

DeepSORT Cosine Gate

Problem

Gate appearance features by cosine similarity (DeepSORT style).

Return the gallery indices whose cosine similarity with feature is at least threshold, ordered by descending similarity, breaking ties by smaller index. Zero vectors have similarity 0.0.

Test cases

case 1
in: [[1,0],[[1,0],[0,1],[-1,0]],0.5]
expected: [0]
case 2
in: [[1,0],[[1,0],[0,1],[-1,0]],-0.5]
expected: [0,1]
case 3
in: [[1,0],[[0.6,0.8]],0.5]
expected: [0]
case 4
in: [[1,0],[[0,1]],0.5]
expected: []
Starter codePython
def cosine_gate(feature, gallery, threshold):
    # Your code here
    pass

4 test cases · run your code against them in the editor