question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When using GPU with CNN model, I am not getting any better results than Hog

See original GitHub issue
  • face_recognition version: 1.3.0
  • Python version:3.6.9
  • Operating System:Ubuntu 18.04

Description

I switched to CNN model from Hog and using the below code.

image1_locations = face_recognition.face_locations(image2, number_of_times_to_upsample=2, model='cnn') image2_locations = `face_recognition.face_locations(image2, number_of_times_to_upsample=2, model=‘cnn’) image1_encoding = face_recognition.face_encodings(image1, known_face_locations=image1_locations, model=‘large’, num_jitters=1)[0]

image2_encoding = face_recognition.face_encodings(image2, known_face_locations=image2_locations, model=‘large’, num_jitters=1)[0]

face_distance = face_recognition.face_distance([image1_encoding], image2_encoding)`

dlib has been compiled with cuda support as well.

dlib.DLIB_USE_CUDA return True

I am using this facial location to compare with another image to calculate facial distance, but the facial distance did not improve at all. is there something that I’m missing.

Any help would be really great @ageitgey

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:11

github_iconTop GitHub Comments

2reactions
aliizadicommented, Jun 3, 2020
* face_recognition version: 1.3.0

* Python version:3.6.9

* Operating System:Ubuntu 18.04

Description

I switched to CNN model from Hog and using the below code.

image1_locations = face_recognition.face_locations(image2, number_of_times_to_upsample=2, model='cnn') image2_locations = `face_recognition.face_locations(image2, number_of_times_to_upsample=2, model=‘cnn’) image1_encoding = face_recognition.face_encodings(image1, known_face_locations=image1_locations, model=‘large’, num_jitters=1)[0]

image2_encoding = face_recognition.face_encodings(image2, known_face_locations=image2_locations, model=‘large’, num_jitters=1)[0]

face_distance = face_recognition.face_distance([image1_encoding], image2_encoding)`

dlib has been compiled with cuda support as well.

dlib.DLIB_USE_CUDA return True

I am using this facial location to compare with another image to calculate facial distance, but the facial distance did not improve at all. is there something that I’m missing.

Any help would be really great @ageitgey

Hi @abhianand7, CNN method is used for face location(face detection) in Dlib, not for face encoding. As you can see in the API after finding the face location by each of CNN or hog you call face_encodings which uses deep metric learning to create face embeddings. So in your case, both hog or CNN methods find the same face location and that’s why you see the same face encodings for both. In summary, the CNN method gives you a better result in finding face locations, not face encoding. Here is a good description of differences between hog and CNN. Here is also a good description for deep metric learning.

1reaction
petar-vargacommented, May 22, 2020

@abhianand7 That sounds good. Maybe try and find discrepancies between face_recognition calls to dlib and direct usage of dlib. It is my understanding that CNN should provide speed improvement in training/detecting and better accuracy compared to the HOG model.

Let us know if you manage to find the reason for this behavior.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What should I do when my neural network doesn't learn?
If your model is unable to overfit a few data points, then either it's too small (which is unlikely in today's age),or something...
Read more >
How fast is my model? - Machine, Think!
It's possible for each GPU thread to compute multiple output pixels instead of just one, allowing it to re-use some of the input...
Read more >
CNN based face detector from dlib - Towards Data Science
Exploring the CNN based face detector that comes with dlib and comparing it with dlib's widely used HOG+SVM based frontal face detector.
Read more >
Review of deep learning: concepts, CNN architectures ...
It has been shown that a suitable data representation provides an improved performance when compared to a poor data representation. Thus, a ...
Read more >
Face detection with dlib (HOG and CNN) - PyImageSearch
Best of all, the MMOD face detector can run on an NVIDIA GPU, making it super fast! To learn how to use dlib's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found