A high-accuracy face recognition system using ArcFace for access control applications with an emphasis on security, reliability, and ease of use.
- State-of-the-art facial recognition using ArcFace model (99.82% accuracy on LFW benchmark)
- Real-time processing optimized for access control applications
- Modular architecture with separate components for detection, embedding, and verification
- Comprehensive database management tools for adding, removing, and updating identities
- Multiple database options including standard storage and FAISS for high-scale deployments
- Detailed logging and access records for security auditing
- Extensive configuration options to balance security and convenience
- Simple command-line interface for all operations
- System Requirements
- Installation
- Quick Start
- Configuration Options
- Database Management
- Technical Architecture
- Recognition Performance
- Troubleshooting
- Contributing
- License
- Acknowledgments
- Python 3.7+
- 4GB RAM
- Intel/AMD x86-64 CPU (2 cores+)
- 500MB disk space
- Webcam (for live recognition)
- Python 3.8+
- 8GB RAM
- Modern Intel/AMD CPU (4+ cores)
- NVIDIA GPU with CUDA support
- 1GB+ disk space
- HD webcam or IP camera
- Windows 10/11
- Ubuntu 20.04/22.04
- macOS 11+
# Clone the repository
git clone https://github.com/yourusername/face-recognition-system.git
cd face-recognition-system
# Create and activate virtual environment (optional but recommended)
python -m venv venv
source venv/bin/activate # Linux/Mac
# or
venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt# Install GPU versions of libraries for better performance
pip install onnxruntime-gpu faiss-gpuFirst, organize your face images into folders named after each person:
face_data/
βββ John_Smith/
β βββ image1.jpg
β βββ image2.jpg
β βββ ...
βββ Jane_Doe/
β βββ image1.jpg
β βββ ...
βββ ...
Then, create the database:
python main.py create-db --root face_dataTest with a single image:
python main.py test --image path/to/test.jpgpython main.py livePress 'q' to quit, 's' to take a screenshot.
Configuration settings are located in config/settings.py. Key parameters:
| Parameter | Default | Description |
|---|---|---|
DETECTION_THRESHOLD |
0.6 |
Face detection confidence threshold |
RECOGNITION_THRESHOLD |
0.5 |
Similarity threshold for recognition |
USE_FAISS |
False |
Whether to use FAISS for database |
MODEL_NAME |
buffalo_l |
InsightFace model name |
DET_SIZE |
(640, 640) |
Detection size |
CTX_ID |
0 |
CUDA device ID (0 for first GPU, -1 for CPU) |
You can override configuration options directly from the command line:
# Adjust recognition threshold for stricter matching
python main.py live --recognition-threshold 0.65
# Use FAISS for larger databases
python main.py live --use-faiss
# Use CPU for detection (when no GPU available)
python main.py live --ctx-id -1The system includes comprehensive tools for managing face databases:
# List all identities
python tools/manage_database.py list
# Add a new person from multiple images
python tools/manage_database.py add --name "John Smith" --folder path/to/john_photos
# Remove a person
python tools/manage_database.py remove --name "John Smith"
# Update an existing person's face data
python tools/manage_database.py update --name "Jane Doe" --folder path/to/new_photos
# Backup the database
python tools/manage_database.py backup- Use 5-10 high-quality images per person from different angles
- Update embeddings when a person's appearance changes significantly
- Create regular backups, especially before major updates
- Test recognition accuracy periodically with known samples
- For large databases (500+ identities), switch to FAISS
The system follows a modular design with clear separation of concerns:
face_recognition_system/
βββ config/ # Configuration settings
βββ src/ # Source code modules
β βββ database/ # Database operations
β βββ face/ # Face detection and embedding
β βββ utils/ # Utility functions
β βββ access_control/ # Access verification
βββ tools/ # Command-line tools
βββ main.py # Main entry point
- Face Detection: Using RetinaFace from InsightFace
- Face Alignment: Based on detected facial landmarks
- Embedding Generation: Using ArcFace (ResNet-50) generating 512D embeddings
- Embedding Comparison: Using cosine similarity for matching
- Access Decision: Based on similarity threshold
-
Standard Database: Pickle-based storage for small to medium deployments
- Fast for databases with up to ~500 identities
- Simple backup and restore
-
FAISS Database: For large-scale deployments
- Optimized for databases with 500+ identities
- Significant performance advantage for large databases
- More complex backup and restore processes
The system uses ArcFace with the following specifications:
- Model: InsightFace's
buffalo_l(ResNet-50 backbone) - Embedding Size: 512-dimensional vector
- Comparison Method: Cosine similarity with normalization
- LFW Benchmark: 99.82% accuracy
| Threshold | False Accepts | False Rejects | Typical Use Case |
|---|---|---|---|
| 0.3-0.4 | Higher | Lower | Convenience-focused |
| 0.5 | Balanced | Balanced | General usage |
| 0.6-0.7 | Lower | Higher | Security-focused |
For high-security applications, increase the recognition threshold to 0.65 or higher.
| Database Size | Standard DB | FAISS DB |
|---|---|---|
| 10 identities | 2ms | 5ms |
| 100 identities | 15ms | 7ms |
| 1000 identities | 130ms | 10ms |
Measured on Intel i7 CPU with 16GB RAM. GPU acceleration improves times by 40-60%.
Error: The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support.
Solution: Install OpenCV with GUI support:
pip uninstall opencv-python
pip install opencv-contrib-pythonIf faces aren't being detected properly:
- Check lighting conditions - ensure even, bright lighting
- Adjust
DETECTION_THRESHOLDin settings (lower for better detection) - Verify camera is working correctly
- Test with different
DET_SIZEvalues
If recognition results are unreliable:
- Add more varied training images for the person
- Ensure face is clearly visible in the training images
- Check for database quality issues (use
tools/manage_database.py test) - Adjust
RECOGNITION_THRESHOLDbased on your needs
If you encounter issues:
- Check the logs in the
logs/directory - Open an issue on GitHub with detailed information
- Include log files and system information
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- InsightFace for the ArcFace implementation
- OpenCV for computer vision utilities
- FAISS for efficient similarity search
- All contributors who have helped improve this system
Developed with β€οΈ for advanced, ethical face recognition

