Skip to content
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 2 ArcFace features? #903

Closed
pango99 opened this issue Sep 16, 2019 · 8 comments
Closed

How to compare 2 ArcFace features? #903

pango99 opened this issue Sep 16, 2019 · 8 comments

Comments

@pango99
Copy link

pango99 commented Sep 16, 2019

I use cosine similarity to calculate 2 features similarity,but I am not sure whether it is the best way, so whether cosine similarity is suite for arcface's feature comparing? Is there any other ways to do the feature comparing?

@cyrojyro
Copy link

you can use sum of squared error
np.sum(np.square(f1 - f2))
(from deploy/test.py)

@pango99
Copy link
Author

pango99 commented Sep 20, 2019

you can use sum of squared error
np.sum(np.square(f1 - f2))
(from deploy/test.py)

thank you, how accurate is it ? the formuler looks like euler distance

@Walstruzz
Copy link

Walstruzz commented Sep 22, 2019

U can also use Cosine Similarity.

# if embedding_1.shape is (1, emb_size,), use:
embedding_1, embedding_2 = normalize(embedding_1), normalize(embedding_2)
sim = embedding_1 @ embedding_2.T

-1 <= sim <= 1.

@pango99
Copy link
Author

pango99 commented Sep 22, 2019

U can also use Cosine Similarity.

# if embedding_1.shape is (1, emb_size,), use:
embedding_1, embedding_2 = normalize(embedding_1), normalize(embedding_2)
sim = embedding_1 @ embedding_2.T

-1 <= sim <= 1.

thank you,but I am a c language programmer,I'm using mxnet c api to use ArcFace model,and I'm a python language starter,so I cant understand the meaning of below line code:
sim = embedding_1 @ embedding_2.T

what's the meaning of "@" symbol?

@Walstruzz
Copy link

Sorry, @ equals to dot in numpy.
For mxnet NDArray, use nd.dot(embedding_1, embedding_2.T). :-)

@yuanbit
Copy link

yuanbit commented Oct 4, 2019

@pango99: how do you extract ArcFace feature vectors using your own dataset and the pretrained models?

@pango99
Copy link
Author

pango99 commented Oct 4, 2019

@pango99: how do you extract ArcFace feature vectors using your own dataset and the pretrained models?

use MXNet C API

@lebionick
Copy link

@pango99
same question, it's not obvious from the formula of loss, but these guys just use cosine dist
https://www.groundai.com/project/arcface-additive-angular-margin-loss-for-deep-face-recognition/1

During testing, the score is computed by the Cosine Distance of two feature vectors. Nearest neighbour and threshold comparison are used for face identification and verification tasks.

@nttstar nttstar closed this as completed Jun 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants