Skip to content

lwppwl/face-anti-spoofer

 
 

Repository files navigation

Face Anti-Spoofer

Face anti-spoofing task solution using CASIA-SURF CeFA dataset, FeatherNets and Face Alignment in Full Pose Range.

Model Params, M Computational complexity, MFLOPs RGB Depth IR Loss function Optimal LR Minimal ACER (CASIA-SURF val) Snapshot
FeatherNet 0.35 79.99 ✔️ Cross-entropy 3e-6 0.0242 Download
FeatherNet 0.35 79.99 ✔️ ✔️ Cross-entropy 3e-6 0.0174 Download
FeatherNet 0.35 79.99 ✔️ ✔️ ✔️ Cross-entropy 1e-7 0.0397 Download
FeatherNet 0.35 79.99 ✔️ Focal loss 3e-6 0.0066 Download
MobileLiteNet 0.57 270.91 ✔️ Cross-entropy 3e-7 0.1542 Download
MobileLiteNet 0.57 270.91 ✔️ ✔️ Cross-entropy 3e-6 0.1019 Download
MobileLiteNet 0.57 270.91 ✔️ ✔️ ✔️ Cross-entropy 3e-6 0 Download
MobileLiteNet 0.57 270.91 ✔️ Focal loss 3e-7 0.1666 Download
ResNet18 13.95 883730 ✔️ Cross-entropy 1e-3 0.0049 Download
ResNet18 13.95 883730 ✔️ ✔️ ✔️ Cross-entropy 1e-3 0 Download
ResNet18 13.95 883730 ✔️ Focal loss 1e-4 0.0021 Download
ResNet18 with dropout 13.95 883730 ✔️ Cross-entropy 1e-3 0.0001 Download
ResNet18 with dropout 13.95 883730 ✔️ ✔️ ✔️ Cross-entropy 1e-3 0 Download
ResNet18 with dropout 13.95 883730 ✔️ Focal loss 1e-4 0.0034 Download

TensorBoard

Requirements

  • Python 3.7.6
  • PyTorch 1.4.0

Setup

  1. Get CASIA-SURF dataset.
  2. Move dataset folder to ./data/CASIA_SURF:
ln -s <your_path_to_CASIA> ./data/CASIA_SURF
  1. Install requirements: pip install -r requirements.txt

Train

  1. Tensorboard logs will be written to ./runs folder. To monitor them during training process, run:
tensorboard --logdir runs
  1. Run training process:
python train.py --protocol PROTOCOL --config-path CONFIG_PATH --data_dir DATA_DIR
                [--epochs 10] [--checkpoint ''] [--train_batch_size 1]
                [--val_batch_size 1] [--eval_every 1] [--save_path checkpoints]
                [--num_classes NUM_CLASSES] [--save_every 1] [--num_workers 0]

Protocol must be either 1, 2 or 3. It determines CASIA-SURF benchmark sub-protocol of Protocol 4.

Test

CASIA-SURF

  1. When you have the model, you can test it by running:
python test.py --protocol PROTOCOL --checkpoint CHECKPOINT --config-path CONFIG_PATH 
               [--data-dir DATA_DIR] [--num_classes NUM_CLASSES] [--batch_size BATCH_SIZE]
               [--visualize VISUALIZE] [--num_workers NUM_WORKERS] [--video_path VIDEO_PATH]

Protocol must be either 1, 2 or 3. It determines CASIA-SURF benchmark sub-protocol of Protocol 4.

Demo with Intel® RealSense™ camera

Running

python realsense_demo.py --video-path VIDEO_PATH --config-path CONFIG_PATH  [--num_classes NUM_CLASSES]

WARNING: Current evaluation for RealSense cameras was developed only for legacy devices which supported by pyrealsense library. Everything works fine for F200.

Demo

Submit

Submission is made for Face Anti-spoofing Detection Challenge at CVPR2020.

  1. Run:
python submit.py --model1_path MODEL1_PATH --model2_path MODEL2_PATH --model3_path MODEL3_PATH 
                 [--num_classes 2] [--batch_size 1] [--output submission.txt]
                 [--num_workers 0] 

About

Deep Learning based Face Anti-Spoofing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%