This example demonstrates Face Detection / Recognition utilizing off-the-shelf YoloV8n-Face + FaceNet models co-mapped and running on MemryX accelerator. It implements a face recognition pipeline where:
- Face boxes and keypoints are detected an image.
- Faces are extracted from the image using bounding boxes and keypoints.
- Extracted faces are embedded using the face recognition model.
The implementation includes MXFace, which emulates a Queue structure, making it easily integrable into a realtime application. The following demo code utilizes MXFace to distinguish the identity between two images.
|
|
| Property | Details |
|---|---|
| Model | YoloV8n-Face, FaceNet |
| Model Type | Face Detection + Recognition |
| Framework | Onnx + Keras |
| Model Source | YoloV8n-Face, FaceNet |
| Pre-compiled DFP | Download here |
| Output | Face bounding box + keypoints + embedding |
| OS | Linux |
| License | GPL |
Before running the application, ensure that OpenCV and Kagglehub re installed. You can install them using the following commands:
pip install -r requirements.txtTo download and unzip the precompiled DFPs, use the following commands:
wget https://developer.memryx.com/example_files/2p2/face_recognition.zip
mkdir -p models
unzip face_recognition.zip -d models(Optional) Download and compile the model yourself
If you prefer, you can download and compile the models rather than using the precompiled model. Download the pre-trained yolov8n and FaceNet models:wget https://developer.memryx.com/example_files/face_recognition_original.zip
unzip face_recognition_original.zip -d modelsYou can now use the MemryX Neural Compiler to compile the models and generate the DFP file required by the accelerator:
cd models/
mx_nc -v -m Facenet.h5 yolov8n-face_crop.onnx --dfp_fname yolov8n_facenet.dfp With the compiled model, you can now use the MXA to perform face recognition. Run the following script to see face recognition in action:
cd src/
python3 run.py By default, the script will download a sample dataset of images from hit comedy T.V. series Friends and compare two sample images. Additionally, you can specify two images to distinguish:
python3 run.py --image_path path1 path2This project uses third-party software, models, and libraries. Below are the details of the licenses for these dependencies:
- Models: Yolov8n-face Model exported from Yolov8-Face Github Repository 🔗
- License: GNU General Public License v3.0 🔗
- Models: FaceNet Model exported from the DeepFace Github Repository 🔗
- License: MIT License 🔗
This example impelments a Face Detection + Recognition pipeline, utilizing off-the shelf yolov8 + facenet models.

