ageitgey / face_recognition

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

K_NN Example takes a long time for recognition #332

Open JasonLukose opened 6 years ago

JasonLukose commented 6 years ago

Description

Trying to do real-time recognition with this library to scale up to almost 4000 people.

What I Did

I've tried to run the knn example, but it seems to pretty slow and takes almost 1 second for any image. This is not ideal because I want to be able to recognize faces coming in from a webcam in real time, like the other examples.

Is this an issue with KNN or how the example was set up?

Any advice for this problem? SVMs? Simple nparrays?

MLDSBigGuy commented 6 years ago

Dont load images all the time. Train your dataset of 4000 people first. save the knn classified model. when a real time image comes, compare by loading trained model. Current ball_tree classification has o(logn) complexity. So it should be very fast(in ms) if you give just one image for comparision. Even if you want to compare multiple images, then also it can be made fast by giving each request to one core.

If none of this works, change KNN to Approximate Nearest Neighbours algorithm