davidsandberg / facenet

Face recognition using Tensorflow
MIT License
13.71k stars 4.8k forks source link

except KNN classifier, any others classifier are better than KNN? #791

Open rain2008204 opened 6 years ago

rain2008204 commented 6 years ago

When I use KNN as the last classifier, I make 12 classes, each class contain 15 pictures, and the result is not good, performance is not good ,so anybody have some idea about others classifier?

heiwushi commented 6 years ago

What is the input feature of your KNN?

rain2008204 commented 6 years ago

@heiwushi 128 embedding output from facenet, from model of inception-Resnet v1, so? what kind of classifier have you used?

hetul-patel commented 6 years ago

You can use linearSVC which is support vector classifier. Implementation is provided by sklearn like one shown here,

svm = LinearSVC() clf = CalibratedClassifierCV(svm) clf.fit(arr_embeddings, arr_labels) y_proba = clf.predict_proba( arr_unknown_embeddings )

CalibratedClassifierCV is used here to output probability of each class used for training. So, class with the highest probability can be considered as prediction.

Note that KNN supports online learning where new face embeddings can be added to existing training set on the go. But in case of SVC you have to train everything again if new face embeddings are added later. To achieve online learning with similar performance of SVC, you can use stochastic gradient descent algorithm to minimize the objective of hinge loss of SVM.

rain2008204 commented 6 years ago

@hetul-patel thanks for your instant response. I try it

samy-soliman commented 5 years ago

hi ! late for the party i also tried KNN and looking for other solutions i was advised to use SVM can you help , with any info !

hetul-patel commented 5 years ago

@sami-soliman I have already proposed a solution for using SVM for face matching at https://github.com/davidsandberg/facenet/issues/791#issuecomment-397163176.

Other than svm, I would suggest calculating Euclidean distance between unknown embedding against know embeddings. The one with the lowest Euclidean distance from known embeddings set would be the prediction. This approach is very useful when you want to add new persons to your database. Unlike SVM you would not be required to retrain model on newly added embeddings.

Other than Euclidean distance, cosine distance is also good distance measure. Mathematically cosine distance is total squared error between two embeddings.

timiil commented 3 years ago

@sami-soliman I have already proposed a solution for using SVM for face matching at #791 (comment).

Other than svm, I would suggest calculating Euclidean distance between unknown embedding against know embeddings. The one with the lowest Euclidean distance from known embeddings set would be the prediction. This approach is very useful when you want to add new persons to your database. Unlike SVM you would not be required to retrain model on newly added embeddings.

Other than Euclidean distance, cosine distance is also good distance measure. Mathematically cosine distance is total squared error between two embeddings.

Hi, do you mean that "Euclidean distance between unknown embedding against know embeddings" is strongest method than 'SVM' or 'KNN' to slove unknow face classfily problem ?

Furthor more, i had created a database which have about 500 persons, one person one picture, use FACENET or DLIB to embeddings faces; and then i try to check a package which contain 1500 face pictures which are REALLY owing by above 500 people, but when we use Euclidean distance to predict , the result is NOT GOOD :(, neither FACENET nor DLIB is good.

What is the problem , in your option ? thanks you very much for any help

samy-soliman commented 3 years ago

Try using more images one photo for each person is not enough On 12 Nov 2020 9:49 a.m., "timiil" notifications@github.com wrote:

@sami-soliman https://github.com/sami-soliman I have already proposed a solution for using SVM for face matching at #791 (comment) https://github.com/davidsandberg/facenet/issues/791#issuecomment-397163176 .

Other than svm, I would suggest calculating Euclidean distance between unknown embedding against know embeddings. The one with the lowest Euclidean distance from known embeddings set would be the prediction. This approach is very useful when you want to add new persons to your database. Unlike SVM you would not be required to retrain model on newly added embeddings.

Other than Euclidean distance, cosine distance is also good distance measure. Mathematically cosine distance is total squared error between two embeddings.

Hi, do you mean that "Euclidean distance between unknown embedding against know embeddings" is strongest method than 'SVM' or 'KNN' to slove unknow face classfily problem ?

Furthor more, i had created a database which have about 500 persons, one person one picture, use FACENET or DLIB to embeddings faces; and then i try to check a package which contain 1500 face pictures which are REALLY owing by above 500 people, but when we use Euclidean distance to predict , the result is NOT GOOD :(, neither FACENET nor DLIB is good.

What is the problem , in your option ? thanks you very much for any help

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/davidsandberg/facenet/issues/791#issuecomment-725903754, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKER5GMQQT4WIO3GTBTLNWLSPOHRXANCNFSM4FEV6MFQ .

timiil commented 3 years ago

Try using more images one photo for each person is not enough On 12 Nov 2020 9:49 a.m., "timiil" @.***> wrote: @sami-soliman https://github.com/sami-soliman I have already proposed a solution for using SVM for face matching at #791 (comment) <#791 (comment)> . Other than svm, I would suggest calculating Euclidean distance between unknown embedding against know embeddings. The one with the lowest Euclidean distance from known embeddings set would be the prediction. This approach is very useful when you want to add new persons to your database. Unlike SVM you would not be required to retrain model on newly added embeddings. Other than Euclidean distance, cosine distance is also good distance measure. Mathematically cosine distance is total squared error between two embeddings. Hi, do you mean that "Euclidean distance between unknown embedding against know embeddings" is strongest method than 'SVM' or 'KNN' to slove unknow face classfily problem ? Furthor more, i had created a database which have about 500 persons, one person one picture, use FACENET or DLIB to embeddings faces; and then i try to check a package which contain 1500 face pictures which are REALLY owing by above 500 people, but when we use Euclidean distance to predict , the result is NOT GOOD :(, neither FACENET nor DLIB is good. What is the problem , in your option ? thanks you very much for any help — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#791 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKER5GMQQT4WIO3GTBTLNWLSPOHRXANCNFSM4FEV6MFQ .

let's say we have an 'entrance' , every day the CERTAIN 500 person will cross the entrance and photo by camera into about 1500 pics; if i collect enough days pics , for example after 10 days , i have 1500*10 pics;

Is there a 'UnSupervise' way to train a Model that i can get about 500 classfily classes ?