Face recognition first call very slow on Jetpack 4.6

Hi - I am trying to use my Nano as much as OOB as possible
Its just been re-created using jetpack 4.6

I have been adapting one of the JetsonHacks ideas to my own code involving facial recognition from video with Face_recognition.
I applied the one line code fix to dlib as outlined in
[issues with dlib library - #16 by AastaLLL]
Build a Hardware-based Face Recognition System for $150 with the Nvidia Jetson Nano and Python | by Adam Geitgey | Medium
these relate to dlib 19.16 and 19.17 but it seems to still apply to 19.22
That got face_recognition to use the GPU when model=“cnn” was used

However I am finding the startup time to be horrible
the first call to face_recognition.face_locations(imageRGB ,model="cnn" ) takes 22 to 25 seconds.
subsequent calls take about 0.3 sec to 0.9 sec for larger images
for the 1st call it doesn’t matter what size the image is

If the model is changed to model="hog" then the first call to face_recognition.face_locations, and each subsequent takes about 0.6 sec

Similar results for the calls to face_recognition.face_encodings
Model=‘cnn’ initial 2.69 sec then .04sec again size doesn’t seem to affect it too much
Model=‘hog’ initial from 5.5 to 10 sec then .04sec

Over 20 seconds just feels like a timeout issue, probably between face_recognition and dlib, but that just me using ‘the force’

Does anybody have any ideas how to make all these bits play nicely together?

dlib.DLIB_USE_CUDA = True
dlib version = 19.22.0
dlib compiled = Nov 14 2021 16:36:45
face_recognition.__version__ = 1.2.3
cv2.__version__ = 4.1.1
camera = Raspberry V2



Have you checked this issue with the face_recognition or dlib team?

In general, the first launch may have some initialization work.

For example, they may need to convert the model into TensorRT.
In this case, you can serialize the engine file and deploy it directly next time.


it is now cross posted to both face_recognition and dlib in github

Hi all,
Any update on this? I am using Jetpack 4.6 on Jetson Nano. dlib version is 19.22.0.

I used version 19.21 and now I am getting 15 fps. I have posted how to down version it. If required I can dig it up and post it here.

1 Like

I tried falling back to 19.21 as you suggested and
a) the 1st call to face_recognition.face_locations has dropped to 14 or 15 sec for model=cnn
b) it did NOT need the workaround code fix

So half a solution at least. I will post this update back on dlib site as it seems something that was fixed has now been broken again.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.