ageitgey / face_recognition

The world's simplest facial recognition api for Python and the command line
MIT License
52.91k stars 13.44k forks source link

How to Combine classifiers ??? And also how to train KNN classifier with GPU ? #787

Open xSNYPSx opened 5 years ago

xSNYPSx commented 5 years ago

I read instruction from here and train classifier to recognize my dataset. https://github.com/ageitgey/face_recognition/wiki/Face-Recognition-Accuracy-Problems https://github.com/ageitgey/face_recognition/blob/master/examples/face_recognition_knn.py

I have question - if we have a way to combine classifiers from different pc ? I collecting dataset on different computers and automatically train classifier, so for example pc#1 train classifier for 100 womans pc#2 train classifier for 100 mans I need combine this two to get 1 that recognize 100 womans and 100 mans I trained on different pc before

And also how to train KNN classifier with GPU ? I have dataset up to 1 million photos and my cpu tells me this is much for him, my 2*1080ti idle.....

And my third question - trained_knn_model.clf rewriting every time I retrain my classifier. How to learn it without rewriting, just updating ?

xSNYPSx commented 5 years ago

I think I solve my third problem with updating trained_knn_model.clf file You need to change line 105
with open(model_save_path, 'wb') as f: to this with open(model_save_path, 'ab') as f:

So now train function will not rewriting, but will add information to the end of file trained_knn_model.clf

I hope it will help people who wants to retrain their models, but do not want to lose pretrained information 👍

leonardofmed commented 5 years ago

This does not seem to work. From what I've observed the 'predict' function continues to use only the first part of what has been trained and ignores the next trainings.

What I did to test this:

Probably in the first time that the .clf file is created a beginning and an end is defined. When the file is updated it should only insert new elements after this 'end', making these new elements useless.