This project implements a face liveness detection system using deep learning to distinguish between real faces and spoofed images.
liveness.py: Script to run liveness detection on a single imagemodel.ipynb: Jupyter notebook containing model training code
The model uses a convolutional neural network (CNN) architecture:
- Input shape: (128, 128, 3)
- 3 convolutional layers with ReLU activation
- Max pooling and dropout layers
- Fully connected layers
- Output: Binary classification (real vs spoof)
The model is trained on a custom dataset of real and spoofed face images. Data augmentation is applied during training. The training process uses:
- Binary crossentropy loss
- Adam optimizer
- 50 epochs
- Batch size of 12
To run liveness detection on a new image:
- Ensure you have the required dependencies installed
- Place the trained model file
liveness.h5in the same directory asliveness.py - Run:
- The script will load the image, run it through the model, and output the prediction (real or spoof) along with the confidence score.
The model achieves over 90% accuracy on the training set and around 75-80% accuracy on the validation set after 50 epochs of training.
- Collect more diverse training data
- Experiment with different model architectures
- Implement real-time liveness detection on video streams
- Python 3.x
- TensorFlow 2.x
- Keras
- NumPy
- Matplotlib