Face_recognition: How to scale face_recognition?

Created on 20 Mar 2017  路  2Comments  路  Source: ageitgey/face_recognition

  • face_recognition version: latest
  • Python version: 2.7
  • Operating System: MacOS

This is a great repo!

Installed face_recognition and tried all examples (except webcam). So far works great.

While trying to do this on 10 unknown images and one known images:

face_recognition ./known_people/ ./unknown_pictures/

it takes around 15-20 seconds. Is there a way to do image comparison of one unknown image to large number of known images in ~2-3 seconds. Also, will this code run on GPU instance and will it reduce latency?

Most helpful comment

If you compile dlib manually with CUDA support (after having installed CUDA and cuDNN), it will use the GPU for generating the face embeddings. So that's a bit faster. However the part that still isn't GPU-accelerated is finding the locations of the faces in each image.

Also the face_recognition script isn't caching anything, so it's rescanning all the known_images each time you run the program which is slower than it needs to be.

One way to speed things up a little bit would be to change the script to pre-cache the face embeddings for each known image and save them somewhere:

  1. Cache the results of running face_recognition.face_encodings(unknown_image)[0] on each known image. You only need to do that once.
  2. When you want to test an unknown picture, load those cached results into an array called cached_known_faces or something and pass that to face_recognition.compare_faces([cached_known_faces], unknown_face_encoding).

I want to work on improving performance in general, but I haven't had a chance yet.

All 2 comments

If you compile dlib manually with CUDA support (after having installed CUDA and cuDNN), it will use the GPU for generating the face embeddings. So that's a bit faster. However the part that still isn't GPU-accelerated is finding the locations of the faces in each image.

Also the face_recognition script isn't caching anything, so it's rescanning all the known_images each time you run the program which is slower than it needs to be.

One way to speed things up a little bit would be to change the script to pre-cache the face embeddings for each known image and save them somewhere:

  1. Cache the results of running face_recognition.face_encodings(unknown_image)[0] on each known image. You only need to do that once.
  2. When you want to test an unknown picture, load those cached results into an array called cached_known_faces or something and pass that to face_recognition.compare_faces([cached_known_faces], unknown_face_encoding).

I want to work on improving performance in general, but I haven't had a chance yet.

Thanks @ageitgey for the clarification.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

carlhung picture carlhung  路  6Comments

dickyj picture dickyj  路  3Comments

safaad picture safaad  路  4Comments

dharam1890 picture dharam1890  路  3Comments

mrhydra-np picture mrhydra-np  路  3Comments