This document provides a procedure to train an CDCN model to detect liveness from images.
Create a main folder for project:
mkdir CDCN-Model
Download:
cd CDCN-Model
git clone https://github.com/ZitongYu/CDCN.git
You must be in ../CDCN-Model folder.
sudo apt install python3.8-venv
python3 -m venv cdcn-env
source cdcn-env/bin/activate
Install required packages:
pip3 --no-cache-dir install torchvision
pip install matplotlib
pip3 --no-cache-dir install pandas
pip install scikit-build
pip install opencv-python
pip install imgaug
pip --no-cache-dir install sklearn
You can install all required packages with following command.
pip install -r requirements.txt
-
First of all, this repository have an indentation error in line 242 of /CDCN/CVPR2020_paper_codes/ train_CDCN.py file. We must fix that problem.
-
Secondly, line 246 is "model = model.cuda()" in train_CDCN.py file and we changed to be comment line this line and add the following are to force CPU to be used :
device=torch.device("cpu") model.to(device)
-
Finally, add following codes to line 203
os.environ["CUDA_VISIBLE_DEVICES"]=""
cd CDCN/CVPR2020_paper_codes
python3 train_CDCN.py
In this step, we realize that we need map_images, so we will create mapped images from our dataset. We will use repository of PRNet-Depth-Generation to generate mapped images.
Create a main folder for project:
mkdir PRNet-Map-Images-Generation
Download:
cd PRNet-Map-Images-Generation
git clone https://github.com/clks-wzz/PRNet-Depth-Generation.git
You must be in ./PRNet-Map-Images-Generation folder.
sudo apt install python3.8-venv
python3 -m venv prnet-env
source prnet-env/bin/activate
Install required packages:
pip install numpy
pip install scikit-image
pip install scipy
pip install opencv-python
You can install all required packages with following command.
pip install -r requirements.txt
cd PRNet-Map-Images-Generation/PRNet-Depth-Generation
python3 Generate_Depth_Image.py
NOTE: In this, spot we have some errors about building.