-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to Compare two faces? #11
Comments
yes there is, you can look at the following function and find out your two image distance with print diff = embs.unsqueeze(-1) - target_embs.transpose(1, 0).unsqueeze(0)
dist = torch.sum(torch.pow(diff, 2), dim=1)
print(dist) # it returns the distance between new face with all faces in your bank it's in def compare2faces(self, conf, faces, tta=False)
"""faces : list of PIL Image (your faces for comparing) """
faces = faces_preprocessing(faces, conf.device)
if tta:
faces_emb = self.model(faces)
hflip_emb = self.model(faces.flip(-1)) # image horizontal flip
embs = l2_norm((faces_emb + hflip_emb)/2) # take mean
else:
embs = self.model(faces)
diff = embs[0] - embs[1]
dist = torch.sum(torch.pow(diff, 2), dim=1)
return dist and run it like this: from facelib import FaceRecognizer, get_config
recognizer = FaceRecognizer(get_config())
recognizer.model.eval()
img1 = PIL.Image.open('')
img2 = PIL.Image.open('')
recognizer.compare2faces(self.conf, faces=[img1, img2], tta=self.tta) |
and you can also see the embeddings at ( |
sure I will let you know, Thank you |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, Thank you for your great work
Is there any way to compare two detected faces and return a percentage of similarity?
In other words, is there any way to get face encodings ?
The text was updated successfully, but these errors were encountered: