Face Embedding with MobileFaceNet ONNX
A lightweight face embedding and verification experiment using MobileFaceNet and ONNX Runtime.
Overview
This project demonstrates a basic face embedding pipeline:
Image
β Preprocessing
β 112 Γ 112 RGB Input
β MobileFaceNet
β 128-D Face Embedding
β L2 Normalization
β Cosine Similarity
Model Input
- Input shape:
[1, 3, 112, 112] - Data type:
float32 - Image size:
112 Γ 112
Model Output
- Output shape:
[1, 128] - Produces a 128-dimensional face embedding.
Current Experiment
Initial test:
- Identical image comparison:
1.0cosine similarity - Different-person example:
0.6479911cosine similarity
These values are experimental results and should NOT be treated as a production verification threshold.
Preprocessing
The current experiment performs:
- Load image using OpenCV
- Convert BGR to RGB
- Resize to 112 Γ 112
- Convert to float32
- Normalize pixel values
- Convert HWC to CHW
- Add batch dimension
Current Status
This is an early experimental version.
Planned improvements:
- Face detection
- Face cropping
- Facial landmark detection
- Face alignment
- Genuine/impostor pair evaluation
- ROC curve
- FAR and FRR
- EER calculation
- Threshold evaluation
- Hugging Face Space demo
Privacy
Face images and face embeddings are biometric data. Test images used during development are not included in this repository.
Use biometric systems only with appropriate consent, security, and privacy safeguards.
Limitations
The current implementation directly resizes input images before embedding extraction.
A production face-verification system should use appropriate face detection and alignment and should be evaluated on representative datasets before choosing a verification threshold.