Machine Learning

How do I implement real-time facial recognition on an edge device like Raspberry Pi 4?

CH Asked by Christopher Lee · 20-01-2024
▲ 0 upvotes 15,914 views 0 comments
The question

I am building a smart doorbell that needs to recognize family members. I tried using a standard ResNet model, but it's way too slow for real-time processing on the Pi. I need something that can run at at least 10-15 FPS without overheating the CPU. Is MediaPipe the way to go, or should I look into quantized models using OpenVINO or TensorFlow Lite? 

3 answers

▲ 0
LI
Answered on 28-02-2024

For a Raspberry Pi 4, you absolutely need to use quantization. I recommend converting your model to TensorFlow Lite with 8-bit integer quantization (INT8). This can speed up inference by 4x. MediaPipe is excellent for face detection (finding the face), but for the actual recognition (matching the ID), you’ll want a lightweight model like MobileFaceNet. If you have the budget, adding an Intel Movidius Neural Compute Stick 2 and using the OpenVINO toolkit will give you the 15+ FPS you’re looking for with much higher stability.

▲ 0
TH
Answered on 05-03-2024

What is the lighting condition at your front door? Most edge-based recognition models struggle with backlighting or shadows, which are very common for outdoor doorbell cameras.

CH 10-03-2024

Thomas, it's mostly shaded but gets bright in the afternoon. To handle that, I'm thinking of using a basic exposure adjustment in OpenCV before feeding the frame to the model. Linda, I will definitely try the INT8 quantization route. I didn't realize the performance jump was that significant on ARM-based processors. I'll check out MobileFaceNet today!

▲ 0
BA
Answered on 25-03-2024

Try the 'Face_recognition' library by Adam Geitge. It’s built on dlib and is incredibly easy to set up, though you might still need to overclock your Pi to get decent speed.

LI 30-03-2024

Good suggestion, Barbara. However, for a doorbell, I'd still lean toward TFLite. Dlib can be quite heavy on the Pi 4 unless you are only processing small frames like 320x240.

Share your thoughts

Your email address will not be published. Required fields are marked (*)

Still have questions? Schedule a free counselling session

Our experts are ready to help you with any questions about courses, admissions, or career paths. Get personalized guidance from industry professionals.

Book Free Session

Book Free Session