insightface icon indicating copy to clipboard operation
insightface copied to clipboard

Doubt of can i compare two faces

Open pausiete7 opened this issue 2 years ago • 6 comments

Hi, I have some doubts about how to compare two faces and tell if they are the same person or not. In the documentation I have not found the way to do it but on the web there is a demo that does it, I would like to know how to do it. I would be very grateful if you could solve this doubt for me.

pausiete7 avatar Dec 18 '22 11:12 pausiete7

Same problem

HaithemH avatar Dec 20 '22 09:12 HaithemH

you can simply calculate the cosine similarity of two vectors

Johnqxy avatar Jan 06 '23 00:01 Johnqxy

Hi, adding to @Johnqxy answer.

The comparison of two faces is done by following:

  1. L-2 normalize two embeddings (vectors). In case of ArcFace, shape of embedding is (512,1)
  2. Calculate cosine similarity of these two embeddings by cos_sim=np.dot(emb1, emb2) (this is the cosine similarity, aka cosine of angle between two vectors)
  3. BONUS, if you are interested in cosine distance, just do this 1-cos_sim

beybars1 avatar Jan 12 '23 06:01 beybars1

Thanks, I will try it

pausiete7 avatar Jan 12 '23 22:01 pausiete7

What would be the accuracy if comparing untrained faces?

chhkg avatar Feb 07 '23 10:02 chhkg

What would be the accuracy if comparing untrained faces?

If you use an already trained model, then the accuracy should be high, provided that you use the same preprocessing technique as in the training data, namely image rectification via facial landmarks.

filonenkoa avatar May 06 '23 16:05 filonenkoa