Search code examples
opencvtensorflowface-detectionface-recognitiondlib

Do we have a way to implement face detection and recognition offline on browser?


I need to find a way to implement face detection and recognition completely offline using a browser. Trained model specific to each user maybe loaded initially. We only need to recognize one face per device. What is the best way to implement this?

I tried tracking.js to implement face detection. It works. But couldn't get a solution to implement recognition. I tried face-recognition.js. But it needs a node server.


Solution

  • Take a look at: face-api.js it can both detect and recognize faces in realtime completely in the browser! It's made by Vincent Mühler, the same creator of face-recognition.js.

    (Face-api.js Github)

    Thing to note:

    • It's realtime, my machine gets ~50ms (using MTCNN model)
    • It's JavaScript but uses WebGL GPU acceleration under the hood which is why it performs so well
    • It can also work on mobile! (tested on my S8+)
    • I recommend looking at the included examples as well, these helped me a lot

    I have used the package to create a working project, it was surprisingly easier than I thought and this is coming from a student that just started web development. (used it in a ReactJs App)

    Just like you I was searching and trying things such as tracking.js but to be honest they didn't work well.