exadel-inc / CompreFace

Leading free and open-source face recognition system
https://exadel.com/accelerator-showcase/compreface/
Apache License 2.0
5.7k stars 775 forks source link

How do you find similarity percentage from euclidean distance of the embeddings #1091

Closed Code-beep12 closed 1 year ago

Code-beep12 commented 1 year ago

Two images which showed a 98.838% similarity has a euclidean distance of 0.7619. How would i go about finding the similarity percentage. My aim is to store embeddings and later find the similarity of faces rather than calling the verify api of compreface repeatedly

pospielov commented 1 year ago

You can find the formula that we use to calculate the similarity from Euclidean distance here: https://github.com/exadel-inc/CompreFace/blob/d10cf2f1d8d6f4a55ba918f391509a402e5b59eb/java/api/src/main/java/com/exadel/frs/core/trainservice/component/classifiers/EuclideanDistanceClassifier.java#L142 And coefficients here: https://github.com/exadel-inc/CompreFace/blob/d10cf2f1d8d6f4a55ba918f391509a402e5b59eb/embedding-calculator/src/services/facescan/plugins/facenet/facenet.py#L141 https://github.com/exadel-inc/CompreFace/blob/d10cf2f1d8d6f4a55ba918f391509a402e5b59eb/embedding-calculator/src/services/facescan/plugins/insightface/insightface.py#L136 However, if you don't need to compare similarities with CompreFace, you can just use distance and choose the threshold based on it. We created similarity just to simplify understanding of choosing threshold.

Code-beep12 commented 1 year ago

Thank you so much