ageitgey / face_recognition

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

Is there a way to use incremental learning for cnn face recognition model? #524

Open Jakubeeee opened 6 years ago

Jakubeeee commented 6 years ago

What I'm trying to do is to use incremental learning to dynamically train the existing model dlib_face_recognition_resnet_model_v1.dat with addidtional faces. Or if this is not possible, can I just remove it and use another one? If so, how can this be achieved and how can I create this .dat file containing my model? Thanks.

ageitgey commented 6 years ago

I guess it might be possible to fine tune the model if you know what you are doing, but it's an exercise beyond the scope of a github comment. You'd have to write custom code to do it and I'm not sure what kind of accuracy improvement you'd get (if any) with a small amount of training data. I'm not familiar enough with the details of the dlib CNN C++ api to know if it supports things like easily freezing certain layers during training, etc. But I'm sure it's possible with some work.

You can definitely just remove the included model here and train your own. In that case, you might just want to use dlib directly though since this library is really meant to make it easy to get started with a pre-trained model as easily possible. Check out this for a little more detail: https://github.com/ageitgey/face_recognition/wiki/Face-Recognition-Accuracy-Problems#question-can-i-re-train-the-face-encoding-model-to-make-it-more-accurate-for-my-images

The short answer though is that training a new face encoding model from scratch requires a huge data set and enough familiarity with CNNs that you could look at the dlib metric learning example here and figure out how to do it.

Jakubeeee commented 6 years ago

Thank you for your answer! Do you maybe know any other pre-trained models that are compatible with face_recognition and can be used instead of dlib_face_recognition_resnet_model_v1.dat?

nyck33 commented 5 years ago

Train a classifier on top like this: https://github.com/ageitgey/face_recognition/blob/master/examples/face_recognition_knn.py