An automated employee attendance system using face recognition with anti-spoofing capabilities for my previous company. This system eliminates the need for fingerprint scanners or manual attendance marking by providing secure, real-time face authentication with liveness detection.
This project implements a comprehensive face recognition system that includes:
- Real-time face detection and recognition
- Liveness detection to prevent spoofing attacks
- Pose and emotion detection capabilities
- Automated attendance tracking
- Web-based interface using Flask
- Python: 3.6+ (Originally developed with Python 3.6/3.7)
- Operating System: Windows, macOS, or Linux
- Hardware: Webcam, GPU recommended for real-time processing
- Dependencies: Listed in
requirements.txt
- Face Recognition: Accurate employee identification using trained facial models
- Anti-Spoofing: Liveness detection to prevent photo/video spoofing attempts
- Real-time Processing: Live webcam-based attendance marking
- Pose Detection: Employee pose analysis for better authentication
- Emotion Recognition: Optional emotion detection capabilities
- Web Interface: Flask-based web application for easy deployment
- Automated Training: Tools for training custom face recognition models
face_recog_livliness/
├── datasets/ # Training datasets and employee photos
├── libfaceid/ # Core face recognition library
├── models/ # Trained ML models and weights
├── templates/ # HTML templates for web interface
├── final_basic_real_time_face_recog.py # Basic real-time face recognition
├── final_fr_with_liveliness.py # Face recognition with liveness detection
├── final_real_time_pose_emotion.py # Pose and emotion detection
├── final_training_model.py # Model training script
├── training.py # Training utilities
├── xahid_training.py # Custom training implementation
├── testing_webcam.py # Webcam testing utilities
├── testing_webcam_flask.py # Flask web interface testing
├── testing_webcam_livenessdetection.py # Liveness detection testing
├── xahid_blinking.py # Blink detection for liveness
├── xahid_demo.py # Demo implementation
└── requirements.txt # Python dependencies
- Python 3.6 or higher (Python 3.7+ recommended)
- pip package manager
- Webcam or camera device
-
Clone the repository:
git clone https://github.com/AnwarXahid/face_recog_livliness.git cd face_recog_livliness -
Create virtual environment (recommended):
# For Windows python -m venv face_recog_env face_recog_env\Scripts\activate # For macOS/Linux python3 -m venv face_recog_env source face_recog_env/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Set up datasets:
- Place employee photos in the
datasets/directory - Organize photos by employee ID or name
- Ensure good quality, well-lit photos for better recognition
- Place employee photos in the
-
Prepare your dataset:
python training.py
-
Train the face recognition model:
python final_training_model.py
-
Custom training (alternative):
python xahid_training.py
-
Basic Face Recognition:
python final_basic_real_time_face_recog.py
-
Face Recognition with Liveness Detection:
python final_fr_with_liveliness.py
-
With Pose and Emotion Detection:
python final_real_time_pose_emotion.py
-
Web Interface:
python testing_webcam_flask.py
-
Test webcam functionality:
python testing_webcam.py
-
Test liveness detection:
python testing_webcam_livenessdetection.py
-
Test blink detection:
python xahid_blinking.py
-
Run demo:
python xahid_demo.py
The system implements multiple liveness detection methods:
- Blink Detection: Monitors eye blinks to ensure a live person
- Face Movement: Tracks subtle facial movements
- Depth Analysis: Analyzes facial depth to prevent photo spoofing
- Uses deep learning models for accurate face encoding
- Supports multiple employees with high accuracy
- Real-time processing for instant attendance marking
- Photo spoofing prevention
- Video replay attack detection
- 3D mask detection capabilities
- Camera Setup: Ensure your webcam is properly configured
- Model Paths: Update model paths in configuration files
- Employee Database: Set up employee records with corresponding face encodings
- Attendance Logging: Configure attendance database/file storage
- GPU Support: Enable GPU acceleration for faster processing
- Model Optimization: Use optimized models for real-time performance
- Threading: Implement multi-threading for concurrent processing
- Anti-Spoofing: Multiple layers of spoofing detection
- Secure Storage: Encrypted storage of face encodings
- Access Control: Role-based access to attendance data
- Audit Trail: Complete logging of attendance events
For production deployment:
-
Hardware Requirements:
- Good quality webcam (HD recommended)
- Adequate lighting conditions
- GPU recommended for real-time processing
-
Server Deployment:
- Deploy Flask application on production server
- Configure proper database for attendance records
- Set up automated backup systems
- Camera not detected: Check camera permissions and connections
- Poor recognition: Improve lighting conditions or retrain models
- False spoofing alerts: Adjust liveness detection sensitivity
- Performance issues: Consider hardware upgrades or model optimization