Skip to content

Apply Central Difference Convolutional Network (CDCN) for face anti spoofing

Notifications You must be signed in to change notification settings

lrioxh/CDCN.pytorch

Repository files navigation

Apply Central Difference Convolutional Network (CDCN) for Face Anti Spoofing

An adaptation from CDCN-Face-Anti-Spoofing.pytorch and face-anti-spoofing, add script to build custom data and fix bugs

Dependence

pip install -r requirements.txt

RTX3060 Laptop

Dataset

get original data from here

OR if you‘d like to train on custom data, use custom_data.py to add/create your custom dataset

before run custom_data.py, labeled images should be put in data/custom. Label format is like 0_xxxx.jpg

Train

tune params in config yaml file and run train.py

to see log visualization:

tensorboard --logdir=experiments/log --port=8008

Inference

single image inference by inference.py

mtcnn face

Notes

difference from origin CDCN:

  • The original version uses living face depth map estimated by PRNet and spoofing depth map is set to 0 In this version, spoofing depth map is also set to 0, but the living face depth map is set to 1 directly
  • due to the difference about depth map, scores are calculated differently
  • different training strategies

difference from other version:

  • add custom data & param θ=0.7 as in origin paper;
  • add pre-processing before inference
  • save optimal weights instead of latest
  • add api to load pretrained model, continue training checkpoints you saved in output dir
  • add api for pre-generated depth maps. If you want to train with the depth map estimated by PRNet, put the depth map you generated from live face into data/train/depth and add a column "depth/xxxx" to the .csv corresponding to the depth map file. then set "depth_map_default" to 0 and train

About

Apply Central Difference Convolutional Network (CDCN) for face anti spoofing

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages