Skip to content
valhongliPublic

About

A Comprehensive Framework for Palm Vein Anti-Spoofing with Preprocessing Pipeline, Dataset and Benchmark

Resources

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

A Comprehensive Framework for Palm Vein Anti-Spoofing with Preprocessing Pipeline, Dataset and Benchmark

This repository offers a complete framework for training, testing, and benchmark for Palm Vein Anti-Spoofing. It supports multiple state-of-the-art pre-trained architectures and provides tools for data augmentation, and advanced performance evaluation metrics like APCER, BPCER and ACER. Ideal for researchers and developers looking to quickly test and benchmark CNN models.

showcase

Key Features

  • Support for Multiple CNN Architectures: Train and test with popular pre-trained models like ConvNeXtXLarge, DenseNet201, EfficientNetB7, EfficientNetV2L, MobileNetV3Large, RegNetX320, ResNet152, VGG19, BiFPNFAS, EntryV1, DevNet, SimpleNet, and many more for Palm Vein Anti-Spoofing tasks.
  • Advanced Data Augmentation: Apply augmentation techniques like rotation, shear, zoom, and horizontal flips to improve model generalization during Palm Vein Anti-Spoofing.
  • Integrated Callbacks for Efficient Training: Supports early stopping, model checkpoints, and learning rate reduction to optimize deep learning model training.
  • Threshold Adjustment: Fine-tune prediction thresholds to improve Palm Vein Anti-Spoofing performance in deep learning models.
  • Training History Visualization: Automatically save training history plots for accuracy and loss metrics, enabling easy performance monitoring.

Requirements

To use this palm vein anti-spoofing framework, ensure that you have the following dependencies installed:

  • Python 3.x: Required for executing the framework's scripts and libraries.
  • NumPy: For efficient numerical computation and data handling.
  • Matplotlib: Used to visualize the training history (accuracy and loss) during model training.
  • scikit-learn: Provides tools for model evaluation, including metrics like accuracy, F1-score, precision, and recall.
  • argparse: Enables easy command-line argument parsing for flexibility in running the scripts.
  • json: Required for handling configuration files and model parameters.
pip install -r requirements.txt

Palm Vein Anti-Spoofing Datasets

Rules

  1. Academic Research Only: This dataset and its subsets are exclusively intended for academic research purposes.
  2. Commercial Use Prohibited: Users are strictly prohibited from utilizing this dataset or its subsets for any commercial applications or purposes.
  3. Lawful Use Requirement: Any usage of this dataset in defamatory, pornographic, or otherwise unlawful manner, or in violation of applicable regulations or laws is strictly forbidden. We disclaim responsibility for any consequences arising from such prohibited behaviors.
  4. Distribution Restrictions: Users are not permitted to distribute, broadcast, or reproduce this dataset or its subsets in any form without explicit written permission from the dataset owners.
  5. Third-Party Sharing Limitations: Users are prohibited from sharing, transferring, selling, or reselling this dataset or its subsets to any third party for any purpose. Exception: Providing dataset access to the user's research associates, colleagues, or team members is permitted, provided that these individuals agree to be bound by these same usage terms.
  6. Publication Guidelines: All data/images in this dataset may be used for academic research purposes. However, only specifically approved data/images from the dataset may be exhibited in publications (including but not limited to research papers, conference presentations, or educational materials). Approved data/images are clearly marked and listed in the accompanying appendix.
  7. Amendment Rights: We reserve the right to interpret, modify, and amend these terms and conditions at any time.
  8. Citation Requirement: Users must provide proper citation when this dataset or its subsets are used in research publications. Please cite as follows:
    
    

Download Datasets

  • PVASD (5k+ IDs, 1M+ images)

Dataset Annotation

Spoof Images, Training Set

showcase

Spoof Images, Validation and Test Set

showcase

Live Images

There're 685,953 live images in training set, and 101,499/92,789 images in validation and test sets respectively.

Data Preprocessing Pipeline

Please refer to the data preprocessing pipeline for instructions on how to preprocess your dataset.

showcase

Ensure your dataset is structured as follows:

PVASD/
    ├── train/
        ├── live/
            ├── sessionID/
                ├── Idi
                    ├── xxx.jpg
        ├── spoof/
            ├── 2d/3d
                ├── PAs typei
                    ├── xxx.jpg
    ├── validation/
        ├── live/
            ├── sessionID/
                ├── Idi
                    ├── xxx.jpg
        ├── spoof/
            ├── 2d/3d
                ├── PAs typei
                    ├── xxx.jpg
    ├── test/
        ├── live/
            ├── sessionID/
                ├── Idi
                    ├── xxx.jpg
        ├── spoof/
            ├── 2d/3d
                ├── PAs typei
                    ├── xxx.jpg

Setup

Clone the repository:

git clone https://github.com/valhongli/PVASD.git

Training or Testing the Model

To train or test the model, run the following command:

python script_name.py --mode train --dataset <dataset_name> --model <model_name> --threshold <threshold_value>

Command-Line Arguments:

  • --mode: Operation mode. Use train for training, test for testing.
  • --dataset: Name of the dataset directory (inside the data/ folder).
  • --model: CNN architecture to use (e.g., convnext_large, densenet201).

Example:

# CLS
# convnext_large 22.5G 128
python main.py --mode train --dataset '../../dataset/PVASD' --model convnext_large    
python main.py --mode test  --dataset '../../dataset/PVASD' --model convnext_large
# densenet201 2.86G - 256
python main.py --mode train --dataset '../../dataset/PVASD' --model densenet201   
python main.py --mode test  --dataset '../../dataset/PVASD' --model densenet201
# efficientnet_b7 3.48G - 128
python main.py --mode train --dataset '../../dataset/PVASD' --model efficientnet_b7    
python main.py --mode test  --dataset '../../dataset/PVASD' --model efficientnet_b7
# efficientnet_v2_l 8.1G - 128
python main.py --mode train --dataset '../../dataset/PVASD' --model efficientnet_v2_l    
python main.py --mode test  --dataset '../../dataset/PVASD' --model efficientnet_v2_l
# mobilenet_v3_large 0.154G - 1280
python main.py --mode train --dataset '../../dataset/PVASD' --model mobilenet_v3_large    
python main.py --mode test  --dataset '../../dataset/PVASD' --model mobilenet_v3_large 
# regnet_x_32gf 20.82G - 128
python main.py --mode train --dataset '../../dataset/PVASD' --model regnet_x_32gf    
python main.py --mode test  --dataset '../../dataset/PVASD' --model regnet_x_32gf      
# resnet152 7.58G - 256
python main.py --mode train --dataset '../../dataset/PVASD' --model resnet152    
python main.py --mode test  --dataset '../../dataset/PVASD' --model resnet152 
# vgg19 13.02G - 256
python main.py --mode train --dataset '../../dataset/PVASD' --model vgg19    
python main.py --mode test  --dataset '../../dataset/PVASD' --model vgg19  

# face anti-spoofing
# BiFPNFAS 0.597G - 512
python train_BiFPNFAS.py --mode train --dataset '../../dataset/PVASD' --model BiFPNFAS    
python train_BiFPNFAS.py --mode test  --dataset '../../dataset/PVASD' --model BiFPNFAS
# EntryV1 1.84G - 768
python main.py --mode train --dataset '../../dataset/PVASD' --model EntryV1    
python main.py --mode test  --dataset '../../dataset/PVASD' --model EntryV1 

# Anomaly detection
# DevNet 4.84G - 1024
python train_DevNet.py --mode train --dataset '../../dataset/PVASD' --model DevNet    
python train_DevNet.py --mode test  --dataset '../../dataset/PVASD' --model DevNet
# SimpleNet 6.04G - 512
python main.py --mode train --dataset '../../dataset/PVASD' --model SimpleNet   
python main.py --mode test  --dataset '../../dataset/PVASD' --model SimpleNet

Baseline Performance on the PVASD

Types Baseline Methods Flops Validation EER threshold Validation EER (%) ↓ Test APCER (%) ↓ Test BPCER (%) ↓ Test ACER (%) ↓
Classical Image Classification ConvNeXtXLarge 22.5 G 0.9486 7.656 9.535 5.212 7.373
Classical Image Classification DenseNet201 2.86 G 0.999 7.272 7.853 9.498 8.675
Classical Image Classification EfficientNetB7 3.48 G 0.697 5.469 9.895 2.866 6.380
Classical Image Classification EfficientNetV2L 8.1 G 0.838 4.711 8.357 2.373 5.365
Classical Image Classification MobileNetV3Large 0.154 G 0.868 3.486 5.227 2.012 3.620
Classical Image Classification RegNetX320 20.82 G 0.656 5.575 7.810 3.112 5.461
Classical Image Classification ResNet152 7.58 G 0.767 10.513 7.670 5.926 6.798
Classical Image Classification VGG19 13.02 G 0.9385 4.935 7.453 3.719 5.586
Face Anti-Spoofing Methods BiFPNFAS 0.597 G 0.898 4.316 5.755 2.169 3.962
Face Anti-Spoofing Methods EntryV1 1.84 G 0.868 2.454 6.061 1.793 3.927
Anomaly Detection Approaches DevNet 4.84 G 5.038 12.300 10.600 6.439 8.520
Anomaly Detection Approaches SimpleNet 6.04 G 0.989 5.636 4.908 3.088 3.998

↓ indicates lower values are better.

Evaluation and Results

  • Accuracy and Loss Plots: The training process automatically generates plots for accuracy and loss, which are saved in the directory: ./checkpoint/<model>/training_history.png. These plots provide a visual representation of the model's training performance.

  • Comprehensive Evaluation Metrics: After testing, detailed evaluation metrics are saved in test_results.json. These include:

    • Confusion Matrix: Provides a detailed breakdown of model predictions across all classes.
    • APCER: The proportion of fake faces wrongly classified as real faces (fake acceptance rate).
    • BPCER: The proportion of real faces wrongly classified as fake faces (fake rejection rate).
    • ACER: The average of APCER and BPCER, providing a balanced measure of model performance.

These metrics help you thoroughly evaluate your model's performance on the test dataset.

References

https://github.com/L-A-Sandhu/CNN-Image-Classification-and-Benchmarking
https://github.com/deepinsight/insightface/tree/master/challenges/cvpr23-fas-wild

Citations


About

A Comprehensive Framework for Palm Vein Anti-Spoofing with Preprocessing Pipeline, Dataset and Benchmark

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages