deepinsight / insightface

State-of-the-art 2D and 3D Face Analysis Project
https://insightface.ai
22.76k stars 5.34k forks source link

distance / similarity calculation version 0.5 #1786

Open MyraBaba opened 2 years ago

MyraBaba commented 2 years ago

Hi ,

I am trying to calc distance in new insightface (onnx insightface latest 0.5) as below code . but got strance result.

what is the correct way to calculate dist / sim.?

def distance(f1,f2):

     diff = np.subtract(f1, f2)
     dist = np.sum(np.square(diff), 1)
    return dist

app = FaceAnalysis()
app.prepare(ctx_id=0, det_size=(640, 640))
img = ins_get_image('/Users/tulpar/Projects/person1')
img2 = ins_get_image("/Users/tulpar/Projects/person2")
faces1 = app.get(img)
faces2 = app.get(img2)

dis1 = distance(faces1[0].embedding , faces2[0].embedding)

distance gives high numbers : like 700 , 50 etc

nttstar commented 2 years ago

Use normed_embedding instead

beybars1 commented 9 months ago

Hi, check this https://github.com/deepinsight/insightface/issues/2199#issuecomment-1379880149