Real-time Face Recognition System | DEMO
A Python-based real-time face recognition system that combines YOLO face detection with ArcFace embeddings for accurate face recognition. The system processes webcam feed in real-time, detecting faces and matching them against a stored database of known faces.
Features
- Real-time face detection using YOLO
- Face recognition using ArcFace embeddings
- Persistent storage of face embeddings
- Interactive interface for adding new faces to the database
- Configurable confidence thresholds for detection and recognition
- Live display of recognition results with bounding boxes and names
Prerequisites
- Python 3.8 or higher
- Webcam or camera device
Installation
- Clone this repository:
git clone https://github.com/Warlord-K/InterIIT-facerecognition.git
cd InterIIT-facerecognition
- Install required packages:
pip install -r requirements.txt
- Download the Arcface model: Click this link and put it in the same folder as the script
Usage
- Run the main script:
python face_recognition_system.py
- Controls:
- Press 'q' to quit the application
- Press 'a' to add a new face to the database
- When prompted, enter the name for the face
- The current frame will be used to generate embeddings
Configuration
You can modify the following parameters in the FaceRecognitionSystem
class initialization:
face_system = FaceRecognitionSystem(
database_path="face_database.pkl",
confidence_threshold=0.5,
similarity_threshold=0.6
)
System Architecture
The system consists of three main components:
-
Face Detection (YOLO)
- Uses YOLO model optimized for face detection
- Processes each frame to locate faces
- Applies confidence threshold to filter detections
-
Face Recognition (ArcFace)
- Generates embeddings for detected faces
- Compares embeddings with stored database
- Returns closest match based on similarity threshold
-
Database Management
- Stores face embeddings with associated names
- Supports adding new faces during runtime
- Persists data between sessions using pickle
Performance Considerations
- Processing speed depends on:
- Hardware capabilities (CPU/GPU)
- Image resolution
- Number of faces in the database
- Adjust confidence and similarity thresholds for optimal balance between accuracy and speed
Troubleshooting
Common issues and solutions:
-
No camera access:
- Check if camera is properly connected
- Verify camera permissions
- Try changing camera index in
cv2.VideoCapture(0)
-
Poor recognition accuracy:
- Adjust
similarity_threshold
for stricter/looser matching - Ensure good lighting conditions
- Add multiple embeddings per person under different conditions
-
Slow performance:
- Reduce frame resolution
- Increase confidence threshold to process fewer detections
- Consider using GPU acceleration if available