TreB1eN / InsightFace_Pytorch

Pytorch0.4.1 codes for InsightFace
MIT License
1.73k stars 423 forks source link

Why is the verification using l2 distance? #23

Open timost1234 opened 5 years ago

timost1234 commented 5 years ago

Why is the code for testing using l2 distance instead of cosine distance? Thank you.

        embed1_train = embeddings1[train_set]
        embed2_train = embeddings2[train_set]
        _embed_train = np.concatenate((embed1_train, embed2_train), axis=0)
        # print(_embed_train.shape)
        pca_model = PCA(n_components=pca)
        pca_model.fit(_embed_train)
        embed1 = pca_model.transform(embeddings1)
        embed2 = pca_model.transform(embeddings2)
        embed1 = sklearn.preprocessing.normalize(embed1)
        embed2 = sklearn.preprocessing.normalize(embed2)
        # print(embed1.shape, embed2.shape)
        diff = np.subtract(embed1, embed2)
        dist = np.sum(np.square(diff), 1)
sdahan12 commented 3 years ago

Hi did you got any answer to this? I was wondering the same thing