项目作者: trushkin-ilya

项目描述 :
Deep Learning based Face Anti-Spoofing
高级语言: Python
项目地址: git://github.com/trushkin-ilya/face-anti-spoofer.git
创建时间: 2020-01-16T10:38:59Z
项目社区:https://github.com/trushkin-ilya/face-anti-spoofer

开源协议:Apache License 2.0

下载


" class="reference-link">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 :heavy_check_mark: :x: :x: Cross-entropy 3e-6 0.0242 Download
FeatherNet 0.35 79.99 :heavy_check_mark: :heavy_check_mark: :x: Cross-entropy 3e-6 0.0174 Download
FeatherNet 0.35 79.99 :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: Cross-entropy 1e-7 0.0397 Download
FeatherNet 0.35 79.99 :heavy_check_mark: :x: :x: Focal loss 3e-6 0.0066 Download
MobileLiteNet 0.57 270.91 :heavy_check_mark: :x: :x: Cross-entropy 3e-7 0.1542 Download
MobileLiteNet 0.57 270.91 :heavy_check_mark: :heavy_check_mark: :x: Cross-entropy 3e-6 0.1019 Download
MobileLiteNet 0.57 270.91 :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: Cross-entropy 3e-6 0 Download
MobileLiteNet 0.57 270.91 :heavy_check_mark: :x: :x: Focal loss 3e-7 0.1666 Download
ResNet18 13.95 883730 :heavy_check_mark: :x: :x: Cross-entropy 1e-3 0.0049 Download
ResNet18 13.95 883730 :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: Cross-entropy 1e-3 0 Download
ResNet18 13.95 883730 :heavy_check_mark: :x: :x: Focal loss 1e-4 0.0021 Download
ResNet18 with dropout 13.95 883730 :heavy_check_mark: :x: :x: Cross-entropy 1e-3 0.0001 Download
ResNet18 with dropout 13.95 883730 :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: Cross-entropy 1e-3 0 Download
ResNet18 with dropout 13.95 883730 :heavy_check_mark: :x: :x: 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:
    1. ln -s <your_path_to_CASIA> ./data/CASIA_SURF
  3. Install requirements:
    pip install -r requirements.txt

Train

  1. Tensorboard logs will be written to ./runs folder. To monitor them during training process, run:

    1. tensorboard --logdir runs
  2. Run training process:

    1. python train.py --protocol PROTOCOL --config-path CONFIG_PATH --data_dir DATA_DIR
    2. [--epochs 10] [--checkpoint ''] [--train_batch_size 1]
    3. [--val_batch_size 1] [--eval_every 1] [--save_path checkpoints]
    4. [--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:
    1. python test.py --protocol PROTOCOL --checkpoint CHECKPOINT --config-path CONFIG_PATH
    2. [--data-dir DATA_DIR] [--num_classes NUM_CLASSES] [--batch_size BATCH_SIZE]
    3. [--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

  1. 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:
    1. python submit.py --model1_path MODEL1_PATH --model2_path MODEL2_PATH --model3_path MODEL3_PATH
    2. [--num_classes 2] [--batch_size 1] [--output submission.txt]
    3. [--num_workers 0]