Skip to content

Using embeddings for Face Recognition task #8

Description

@mrapplexz

Hello! I'm getting face embeddings with these steps:

from torchvision.transforms import functional as VF

cut = cv2.resize(cut, (112, 112), interpolation=cv2.INTER_AREA) # resize image to 112x112 px
cut = VF.to_tensor(cut).to(self.device).unsqueeze(0) # convert ndarray to torch.Tensor, send it to GPU and add batch dimension
cut = VF.normalize(cut, [0., 0., 0.], [1., 1., 1.]) # normalize image as in inference/gen_feat.py
embed = self.model(cut) # do forward pass
embed = F.normalize(embed, p=2, dim=1) # L2-normalize embedding vector
embed = embed.squeeze(0).cpu().numpy() # remove batch dimension and convert embedding vector back to ndarray

For face recognition I'm using cosine similarity between two images.
It works pretty good if I look straight into camera and I get 0.7-1.0 similarity, but if I rotate my face left or right, I get something between 0.1-0.3.
Weights used: https://drive.google.com/file/d/1Bd87admxOZvbIOAyTkGEntsEz3fyMt7H/view
Am I doing something wrong? Maybe I should use another metric or not normalize embedding vectors?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions