Layer 3: Recognition
Face recognition using InsightFace ArcFace embeddings
The Recognition Layer performs face identification using AI-powered face recognition. The system uses InsightFace with the buffalo_l model, which includes SCRFD for detection and ArcFace for recognition.
Overview
- Purpose: Identify persons from face images
- Technology: InsightFace (buffalo_l model)
- Detection: SCRFD
- Recognition: ArcFace embeddings
- Output: Person ID with confidence score
InsightFace
InsightFace is a comprehensive face analysis library that provides state-of-the-art face detection and recognition models.
Model Selection
| Model | Accuracy | Speed | Size | Use Case |
|---|---|---|---|---|
| buffalo_l | Highest | Medium | ~400MB | Production (recommended) |
| buffalo_m | High | Fast | ~200MB | Balanced |
| buffalo_s | Good | Fastest | ~100MB | Real-time/edge |
Recognition Pipeline
Step 1: Face Detection
SCRFD detects faces with landmarks. Each face contains: bounding box, detection score, embedding, and landmarks.
Step 2: Quality Filtering
Filter low-quality detections based on:
- Minimum face size (50 pixels)
- Detection confidence (0.5 threshold)
Step 3: Embedding Extraction
Each face is converted to a 512-dimensional vector using ArcFace.
Step 4: Similarity Matching
Compare the query embedding against all enrolled embeddings using cosine similarity.
Step 5: Threshold Decision
Accept match if similarity score meets the threshold; otherwise mark as unknown.
Configuration
Recognition Settings
| Setting | Description | Default |
|---|---|---|
| Model Name | InsightFace model | buffalo_l |
| Detection Size | Input size for detection | 640x640 |
| GPU Support | Enable CUDA | Off |
| Similarity Threshold | Match acceptance | 0.45 |
| Min Face Size | Minimum face pixels | 50 |
| Quality Threshold | Detection confidence | 0.5 |
Threshold Guidelines
| Threshold | Security | False Positives | False Negatives |
|---|---|---|---|
| 0.35 | Low | Higher | Lower |
| 0.45 | Medium | Balanced | Balanced |
| 0.55 | High | Lower | Higher |
| 0.65 | Very High | Minimal | More |
GPU Acceleration
Enable CUDA for faster processing.
Performance Comparison
| Hardware | Frames/sec | Notes |
|---|---|---|
| CPU (i7) | ~5-10 FPS | Adequate for small scale |
| GPU (RTX 3060) | ~30-50 FPS | Recommended for real-time |
| GPU (RTX 4090) | ~100+ FPS | High-throughput scenarios |
Embedding Storage
Embeddings are stored in the face database for quick lookup during recognition. The database maps person names to their 512-dimensional embedding vectors.
Best Practices
Enrollment
- Use 3-5 images per person
- Include varied angles and lighting
- Average multiple embeddings for stability
- Normalize the averaged embedding
Recognition
- Filter faces by minimum size
- Check detection confidence
- Use appropriate threshold for use case
- Handle "Unknown" cases gracefully
Performance
- Use GPU for real-time applications
- Skip frames for video processing
- Batch process when possible
- Pre-load models at startup
.png)