insightface
insightface copied to clipboard
Doubt of can i compare two faces
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.
Same problem
you can simply calculate the cosine similarity of two vectors
Hi, adding to @Johnqxy answer.
The comparison of two faces is done by following:
- L-2 normalize two embeddings (vectors). In case of ArcFace, shape of embedding is (512,1)
- 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) - BONUS, if you are interested in cosine distance, just do this
1-cos_sim
Thanks, I will try it
What would be the accuracy if comparing untrained faces?
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.