ageitgey / face_recognition

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

face encoding takes too much time in EC2 #910

Open demoV opened 5 years ago

demoV commented 5 years ago

Description

Hi, I am trying to get face encoding in ec2 machine. But it is talking around ~7 sec. Image has only one person.

What I Did

Spin up ec2 instance c5.2xlarge. run face_encodings = face_recognition.face_encodings(image, {face_locations}, 100) in python console.

Please help me to understand why it is too slow in ec2.

khadrawy commented 5 years ago

Have you tried it on some other machine other than ec2? Is it faster on your local machine? this method is single threaded (python nature) and you're asking for 100 iteration which definitely will take time. I tried this lib on DigitalOcean standard vCPU on image from this library and it took around 1 second to encode one image with only 1 iteration. Having multiprocessors will not help you encode the image faster as, again, it is single threaded operation. However, multiprocessors could help you process more images at the same time using python's multiprocessing module to execute that method in parallel processes for different images.

demoV commented 5 years ago

Hi @khadrawy, We are processing the live stream, which is getting processed in EC2. As we do not get the batch of images to run in multiprocessing. Same piece of code runs much faster in local with 100 iterations. Not able to figure out the exact problem with EC2.

khadrawy commented 5 years ago

How much faster does it run locally? which type of cpu do you have locally? what is the average size of the image?

timiil commented 4 years ago

we are too slow too... we are using a 4 core arm64 processor which named rockchip rk3328, running in ubuntu 16.04, give a face.jpg to execute face_encodings method, need about 3-4 seconds. any idea to speed up this method?

BTW, the compare_faces method is also very SLOW :(

please give some help, thanks!