justadudewhohacks / face-recognition.js

Simple Node.js package for robust face detection and face recognition. JavaScript and TypeScript API.
MIT License
1.91k stars 278 forks source link

using faceLandmark5Model as the default for FaceDetector #65

Open ksachdeva opened 6 years ago

ksachdeva commented 6 years ago

Hi Vincent,

Trust you are doing well.

Was reading DavisKings blog (http://blog.dlib.net/2017/09/fast-multiclass-object-detection-in.html) and saw this -

Unlike the 68-point landmarking model included with dlib, this model is over 10x smaller at 8.8MB compared to the 68-point model's 96MB. It also runs faster, and even more importantly, works with the state-of-the-art CNN face detector in dlib as well as the older HOG face detector in dlib. The central use-case of the 5-point model is to perform 2D face alignment for applications like face recognition. In any of the dlib code that does face alignment, the new 5-point model is a drop-in replacement for the 68-point model and in fact is the new recommended model to use with dlib's face recognition tooling.

The example that he has also uses 5-point model. https://github.com/davisking/dlib/blob/master/examples/dnn_face_recognition_ex.cpp

At present, you are pre-creating the FaceDetector object in index.js https://github.com/justadudewhohacks/face-recognition.js/blob/master/lib/index.js#L13 with 68-point model.

Based on what I have seen, there is nothing that prevents me to create the detectors in my app code (since you have properly parameterized the lower layers i.e. FaceDetector/index.js does take the model as an input) however based on Davis King's blog do you think it makes sense to

Regards & thanks Kapil

justadudewhohacks commented 6 years ago

Hi Kapil,

Now that's interesting, thanks for pointing that out! I think at the least minimum we should provide an option to use the FaceDetector with the 5 point face landmark model, by passing a flag maybe.

According to DavisKing there should not be much of a difference in terms of results, but it should be faster and it's smaller:

The results should in general be the same, but it's faster and smaller. The alignment should actually be slightly more accurate in general, but not by a lot. The real benefit is speed, size, and ability to use it with the CNN face detector in addition to the HOG detector.

Yes, you can just replace the old shape model with the new model in any face recognition code that used the old one and it will work. I specifically made this new model to be a replacement for the old one. It will create the same kind of alignment as the old model and work with the previously trained face recognition model.

I think if that's the case (will make some experiences first) it should be safe to make this the default model.

justadudewhohacks commented 6 years ago

I made the 5 point face landmark model the default now as I didn't find the models to make any difference for face alignment. It is possible to still use the 68 point model by creating the FaceRecognizer by passing a flag FaceRecognizer(true).