Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

save "known people" face detection to local db or similar #982

Open
Sparviero-Sughero opened this issue Nov 20, 2019 · 9 comments
Open

save "known people" face detection to local db or similar #982

Sparviero-Sughero opened this issue Nov 20, 2019 · 9 comments

Comments

@Sparviero-Sughero
Copy link

@Sparviero-Sughero Sparviero-Sughero commented Nov 20, 2019

  • face_recognition version: 1.2.3
  • Python version: 3.7
  • Operating System: Debian 10.1

Description

face_detection need to scan "known_people" directory every time.
in "known_people" directory I've 20 people and face_detection need a lot of time to "learn" before search known peoples inside new photos (unknown_pictures directory contain 2 photos).
it's possible to cache "learn" analisys to emprove performances?

What I Did

# time face_recognition --cpus 4 ./known_people/ ./unknown_pictures/
WARNING: More than one face found in ./known_people/fenice_felce.jpg. Only considering the first face.
./unknown_pictures/01.jpg,formica_coriandolo
./unknown_pictures/01.jpg,formica_coriandolo
./unknown_pictures/01.jpg,iora_lenticchia
./unknown_pictures/02.jpg,unknown_person
./unknown_pictures/02.jpg,unknown_person
./unknown_pictures/02.jpg,cervo_volante_ginepro
./unknown_pictures/02.jpg,formica_coriandolo
./unknown_pictures/02.jpg,iora_lenticchia
./unknown_pictures/02.jpg,unknown_person
./unknown_pictures/02.jpg,formichiere_carota

real    0m48,144s
user    0m41,635s
sys     0m2,683s
@Sparviero-Sughero Sparviero-Sughero changed the title save "know people" face detection to local db or similar save "known people" face detection to local db or similar Nov 20, 2019
@ziadkadry99
Copy link

@ziadkadry99 ziadkadry99 commented Nov 23, 2019

I'm having the same issue mostly focusing on an efficient way to save the face encodings. What i did though is use the pickle library to dump out a list of face encodings to a file and load it rather than encoding them again every time you start it. The only thing i'm not sure about with this is if it would scale up well or not since i'm not entirely sure if i have a huge list of encodings saved out to a file would loading it through pickle be slow or efficient

Good luck, I'll update you with my results

@Sparviero-Sughero
Copy link
Author

@Sparviero-Sughero Sparviero-Sughero commented Nov 23, 2019

tnx for answer ziadkadry99
I've downloaded py code from https://www.pyimagesearch.com/2018/09/24/opencv-face-recognition/
I'm not a py developer but the code it's simple and maybe it's possible to remove Xserver's stuff and reach our objective.

@ziadkadry99
Copy link

@ziadkadry99 ziadkadry99 commented Nov 24, 2019

I consulted the stackoverflow community with my ideas here's a link to the answer i got:

https://stackoverflow.com/questions/59004129/storing-a-list-of-face-encodings-in-python-for-face-identification/59005229#59005229

The pickle module would indeed be a good simple solution as well as MongoDB

@Sparviero-Sughero
Copy link
Author

@Sparviero-Sughero Sparviero-Sughero commented Nov 27, 2019

I'm using recognize.py from https://www.pyimagesearch.com/2018/09/24/opencv-face-recognition/
I've modified the py code after proba = preds[j] with this

name = le.classes_[j]
text = "{} ({:.2f}%)".format(name, proba * 100)
print "[FOUND]",text,"(",args["image"],")"
cv2.waitKey(0)
@HananAhmadHunain
Copy link

@HananAhmadHunain HananAhmadHunain commented Nov 28, 2019

I'm having the same issue mostly focusing on an efficient way to save the face encodings. What i did though is use the pickle library to dump out a list of face encodings to a file and load it rather than encoding them again every time you start it. The only thing i'm not sure about with this is if it would scale up well or not since i'm not entirely sure if i have a huge list of encodings saved out to a file would loading it through pickle be slow or efficient

Good luck, I'll update you with my results

I liked your @ziadkadry99 idea of saving encoding to a file.
What happens when you need to load a new face would it encode all faces again? or can i append in the previous file?
Can you share your code which writes encoding to a file?

@Lmovadia
Copy link

@Lmovadia Lmovadia commented Dec 22, 2019

It is an interesting topic .will keep my eyes on .

@alessiosavi
Copy link

@alessiosavi alessiosavi commented Jan 11, 2020

Another approach can be let a neural network "study" the face encodings. I've used this approach in PyRecognizer. The time to predict the face is instant (few milliseconds) with a dataset of 311 people (celebrities), and a total of 5425 photos.

@r3x07
Copy link

@r3x07 r3x07 commented Jan 14, 2020

@HAKANMAZI anyways to make it save from a live webcam ? i mean when it sees my face it saved in a file that it saw my face

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants
You can’t perform that action at this time.