ageitgey / face_recognition

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

How to use face_recognition in Python so that it can make use of all CPUs ?? #443

Open 1warpengine opened 6 years ago

1warpengine commented 6 years ago

Description

Running the example I noticed it use only 1 CPU, I'm not talinking about the command line face:recognition but using the lib in python.

MLDSBigGuy commented 6 years ago

By Multithreading/pools. I think u are asking this

cftang0827 commented 6 years ago

It seems like the pool can do face comparing in multiprocessing way. However, the bottleneck of the face recognition computing is face encoding. So is there any way to do face encoding in multi-core way?

THANKs :)

MLDSBigGuy commented 6 years ago

yes. Create a ML model with n_cpus = -1 parameter. Give this model all set of encodings u have. n_cpus = -1 makes use of all the cpus u have to train the encodings.

cftang0827 commented 6 years ago

Excuse me, do you mean creating a model in dlib from scratch? Or is there any ways to do transfer learning to modify dlib’s face recognition model?

Thank you for your reply :)

cftang0827 commented 6 years ago

Actually I think the original issue is about “inference time” but did you mean “traning time”?

If there’s any misunderstanding, please judge me. Thanks

MLDSBigGuy commented 6 years ago

Yes, i understood as training time.

I mean at this step, https://github.com/ageitgey/face_recognition/blob/master/examples/face_recognition_knn.py#L100, add n_jobs = -1 Ref: http://scikit-learn.org/stable/modules/generated/sklearn.neighbors.KNeighborsClassifier.html

Well, even to do inference, the same concept could be used if you dont have a solution to do incremental learning.

what do u think ?