-
This code trains and implements via video from the pyimagesearch liveness detection blog
-
We modified the blog's original shallow CNN model to Resnet50 that can achieve better accuracy
git clone https://github.com/joytsay/livenessDetection.git
cd livenessDetection
Download from here and put in root folder (/livenessDetection
)
Tested on Windows 10 mini-conda environment via
Miniconda3-latest-Windows-x86_64.exe
Tested on MacOS M2 mini-forge environment via
brew install miniforge
run 01_XXX.bat files (01~05) sequentially:
01_install.bat
02_gather.bat
03_trainLiveness.bat
04_runLiveness.bat
05_webcam.bat
conda create -n liveness python=3.8
conda activate liveness
pip install -r requirements.txt
# data pre-process
python gather_examples.py -i ./videos/fake.mp4 -o ./dataset/fake -d ./face_detector -c 0.9 -s 1 -f 0
python gather_examples.py -i ./videos/real.mp4 -o ./dataset/real -d ./face_detector -c 0.9 -s 1 -f 0
python gather_examples.py -i ./videos/mask.mp4 -o ./dataset/mask -d ./face_detector -c 0.9 -s 1 -f 0
# train model
python train_liveness.py -d ./dataset -m liveness.model -l le.pickle
# run liveness model on test video
python liveness_demo.py -m liveness.model -l le.pickle -d ./face_detector -c 0.5
press "q" to quit
# run liveness model on web cam
python webcam.py -m liveness.model -l le.pickle -d ./face_detector -c 0.5
The following link is the original pyimagesearch liveness-detection-with-opencv example code
- Support it by clicking the ⭐ button on the upper right of this page. ✌️
- The example has been taken from pyimagesearch liveness-detection-with-opencv example and modified model to Resnet50
Copyright (C) 2020 Adrian Rosebrock, PyImageSearch, accessed on March 11, 2019
Just make pull request. Thank you!