Nothing Special   »   [go: up one dir, main page]

Skip to main content
Warning Some features may not work without JavaScript. Please try enabling it if you encounter problems.

LBP-TOP based countermeasure against facial spoofing attacks

Project description

This package implements an LBP-TOP based countermeasure to spoofing attacks to face recognition systems as described at the paper LBP-TOP based countermeasure against facial spoofing attacks, International Workshop on Computer Vision With Local Binary Pattern Variants, 2012.

If you use this package and/or its results, please cite the following publications:

  1. The original paper with the counter-measure explained in details:

    @inproceedings{Pereira_LBP_2012,
      author = {Pereira, Tiago de Freitas and Anjos, Andr{\'{e}} and De Martino, Jos{\'{e}} Mario and Marcel, S{\'{e}}bastien},
      keywords = {Attack, Countermeasures, Counter-Spoofing, Face Recognition, Liveness Detection, Replay, Spoofing},
      month = nov,
      year = {2012},
      title = {LBP-TOP based countermeasure against facial spoofing attacks},
      journal = {International Workshop on Computer Vision With Local Binary Pattern Variants - ACCV},
    }
  2. Bob as the core framework used to run the experiments:

    @inproceedings{Anjos_ACMMM_2012,
      author = {A. Anjos AND L. El Shafey AND R. Wallace AND M. G\"unther AND C. McCool AND S. Marcel},
      title = {Bob: a free signal processing and machine learning toolbox for researchers},
      year = {2012},
      month = oct,
      booktitle = {20th ACM Conference on Multimedia Systems (ACMMM), Nara, Japan},
      publisher = {ACM Press},
    }

Raw Data

The dataset used in the paper is REPLAY-ATTACK database and it is publicly available. It should be downloaded and installed prior to using the programs described in this package. Visit the REPLAY-ATTACK database page for more information.

Installation

There are 2 options you can follow to get this package installed and operational on your computer: you can use automatic installers like pip (or easy_install) or manually download, unpack and use zc.buildout to create a virtual work environment just for this package.

Using an automatic installer

Using pip is the easiest (shell commands are marked with a $ signal):

$ pip install antispoofing.lbptop

You can also do the same with easy_install:

$ easy_install antispoofing.lbptop

This will download and install this package plus any other required dependencies. It will also verify if the version of Bob you have installed is compatible.

This scheme works well with virtual environments by virtualenv or if you have root access to your machine. Otherwise, we recommend you use the next option.

Using zc.buildout

Download the latest version of this package from PyPI and unpack it in your working area. The installation of the toolkit itself uses buildout. You don’t need to understand its inner workings to use this package. Here is a recipe to get you started:

$ python bootstrap.py
$ ./bin/buildout

These 2 commands should download and install all non-installed dependencies and get you a fully operational test and development environment.

User Guide

It is assumed you have followed the installation instructions for the package and got this package installed and the REPLAY-ATTACK database downloaded and uncompressed in a directory. You should have all required utilities sitting inside a binary directory depending on your installation strategy (utilities will be inside the bin if you used the buildout option). We expect that the video files downloaded for the REPLAY-ATTACK database are installed in a sub-directory called database at the root of the package. You can use a link to the location of the database files, if you don’t want to have the database installed on the root of this package:

$ ln -s /path/where/you/installed/the/replay-attack-database database

If you don’t want to create a link, use the --input-dir flag to specify the root directory containing the database files. That would be the directory that contains the sub-directories train, test, devel and face-locations.

Calculate the multiresolution and single resolution LBP-TOP features

The first stage of the process is calculating the feature vectors, which are essentially LBP-TOP histograms (XY, XT and YT directions) for each frame of the video.

The program to be used is script/lbptop_calculate_parameters.py.

The resulting histograms will be put in .hdf5 files in the default output directory ./lbp_features:

$ ./bin/lbptop_calculate_parameters.py replay

To gerate LBP-TOP features following the multiresolution strategy in time domain, it is necessary to set different values for Rt. For example, to generate a multiresolution description in time domain for Rt=[1-4] the code is the follows:

$ ./bin/lbptop_calculate_parameters.py -rT 1 2 3 4 replay

To gerate a single resolution strategy in time domain, it is necessary to set only one value for Rt. For example, to generate a single resolution description in time domain for Rt=1 the code is the follows:

$ ./bin/lbptop_calculate_parameters.py -rT 1 replay

To see all the options for the scripts lbptop_calculate_parameters.py just type –help at the command line.

Classification using Chi-2 Distance

The clasification using Chi-2 distance consists of two steps. The first one is creating the histogram model (average LBP-TOP histogram for each plane and it combinations of all the real access videos in the training set). The second step is comparison of the features of development and test videos to the model histogram and writing the results.

The script to use for creating the histogram model is script/lbptop_mkhistmodel.py. It expects that the LBP-TOP features of the videos are stored in a folder ./lbp_features. The model histogram will be written in the default output folder ./res. You can change this default features by setting the input arguments. To execute this script, just run:

$ ./bin/lbptop_mkhistmodel.py

The script for performing Chi-2 histogram comparison is script/lbptop_cmphistmodels.py, and it assumes that the model histogram has been already created. It makes use of the utility script spoof/chi2.py and ml/perf.py for writing the results in a file. The default input directory is ./lbp_features, while the default input directory for the histogram model as well as default output directory is ./res. To execute this script, just run:

$ ./bin/lbptop_cmphistmodels.py

The performance results will be calculated for each LBP-TOP planes and the combinations XT+YT and XY+XT+YT.

To see all the options for the scripts lbptop_mkhistmodel.py and lbptop_cmphistmodels.py, just type –help at the command line.

Classification with Linear Discriminant Analysis (LDA)

The classification with LDA is performed using the script script/lbptop_ldatrain.py. It makes use of the scripts ml/lda.py, ml/pca.py (if PCA reduction is performed on the data) and ml/norm.py (if the data need to be normalized). The default input and output directories are ./lbp_features and ./res. To execute the script with the default parameters, call:

$ ./bin/lbptop_ldatrain.py

The performance results will be calculated for each LBP-TOP planes and the combinations XT+YT and XY+XT+YT.

To see all the options for this script, just type –help at the command line.

Classification with Support Vector Machine (SVM)

The classification with SVM is performed using the script script/lbptop_svmtrain.py. It makes use of the scripts ml/pca.py (if PCA reduction is performed on the data) and ml/norm.py (if the data need to be normalized). The default input and output directories are ./lbp_features and ./res. To execute the script with the default parameters, call:

$ ./bin/lbptop_svmtrain.py

The performance results will be calculated for each LBP-TOP planes and the combinations XT+YT and XY+XT+YT.

To see all the options for this script, just type –help at the command line.

Generating paper results

The next code blocks are codes to generate the results from lines 4, 5, 6, 7, 8 of Table 1.

  • Line 4

#Extracting the LBP-TOP features
$ ./bin/lbptop_calculate_parameters.py --directory lbptop_features/ --input-dir database/ -rX 1 -rY 1 -rT 1 2 3 4 5 6 -cXY -cXT -cYT --lbptypeXY riu2 --lbptypeXT riu2 --lbptypeYT riu2 replay

#Running the SVM machine
$ ./bin/lbptop_svmtrain.py  -n --input-dir lbptop_features/ --output-dir res/ replay

#Extracting the scores for each plane
$ ./bin/lbptop_make_scores.py --features-dir lbptop_features --machine-file svm_machine_XY-plane.txt --normalization-file svm_normalization_XY-plane.txt --machine-type SVM --plane XY --output-dir res/scores/scores_XY replay
$ ./bin/lbptop_make_scores.py --features-dir lbptop_features --machine-file svm_machine_XT-Plane.txt --normalization-file svm_normalization_XT-Plane.txt --machine-type SVM --plane XT --output-dir res/scores/scores_XT replay
$ ./bin/lbptop_make_scores.py --features-dir lbptop_features --machine-file svm_machine_YT-Plane.txt --normalization-file svm_normalization_YT-Plane.txt --machine-type SVM --plane YT --output-dir res/scores/scores_YT replay
$ ./bin/lbptop_make_scores.py --features-dir lbptop_features --machine-file svm_machine_XT-YT-Plane.txt --normalization-file svm_normalization_XT-YT-Plane.txt --machine-type SVM --plane XT-YT --output-dir res/scores/scores_XT-YT replay
$ ./bin/lbptop_make_scores.py --features-dir lbptop_features --machine-file svm_machine_XY-XT-YT-plane.txt --normalization-file svm_normalization_XY-XT-YT-plane.txt --machine-type SVM --plane XY-XT-YT --output-dir res/scores/scores_XY-XT-YT replay

#Result Analysis
$./bin/lbptop_result_analysis.py --scores-dir res/scores/ --output-dir res/results/ replay
  • Line 5:

#Extracting the LBP-TOP features
$ ./bin/lbptop_calculate_parameters.py --directory lbptop_features/ --input-dir database/ -rX 1 -rY 1 -rT 1 2 3 4 5 6 -cXY -cXT -cYT -nXT 4 -nYT 4 replay

#Running the SVM machine
$ ./bin/lbptop_svmtrain.py  -n --input-dir lbptop_features/ --output-dir res/ replay

#Extracting the scores for each plane
$ ./bin/lbptop_make_scores.py --features-dir lbptop_features --machine-file svm_machine_XY-plane.txt --normalization-file svm_normalization_XY-plane.txt --machine-type SVM --plane XY --output-dir res/scores/scores_XY replay
$ ./bin/lbptop_make_scores.py --features-dir lbptop_features --machine-file svm_machine_XT-Plane.txt --normalization-file svm_normalization_XT-Plane.txt --machine-type SVM --plane XT --output-dir res/scores/scores_XT replay
$ ./bin/lbptop_make_scores.py --features-dir lbptop_features --machine-file svm_machine_YT-Plane.txt --normalization-file svm_normalization_YT-Plane.txt --machine-type SVM --plane YT --output-dir res/scores/scores_YT replay
$ ./bin/lbptop_make_scores.py --features-dir lbptop_features --machine-file svm_machine_XT-YT-Plane.txt --normalization-file svm_normalization_XT-YT-Plane.txt --machine-type SVM --plane XT-YT --output-dir res/scores/scores_XT-YT replay
$ ./bin/lbptop_make_scores.py --features-dir lbptop_features --machine-file svm_machine_XY-XT-YT-plane.txt --normalization-file svm_normalization_XY-XT-YT-plane.txt --machine-type SVM --plane XY-XT-YT --output-dir res/scores/scores_XY-XT-YT replay

#Result Analysis
$./bin/lbptop_result_analysis.py --scores-dir res/scores/ --output-dir res/results/ replay
  • Line 6:

#Extracting the LBP-TOP features
$ ./bin/lbptop_calculate_parameters.py --directory lbptop_features/ --input-dir database/ -rX 1 -rY 1 -rT 1 2 3 4 -cXY -cXT -cYT replay

#Running the SVM machine
$ ./bin/lbptop_svmtrain.py  -n --input-dir lbptop_features/ --output-dir res/ replay

#Extracting the scores for each plane
$ ./bin/lbptop_make_scores.py --features-dir lbptop_features --machine-file svm_machine_XY-plane.txt --normalization-file svm_normalization_XY-plane.txt --machine-type SVM --plane XY --output-dir res/scores/scores_XY replay
$ ./bin/lbptop_make_scores.py --features-dir lbptop_features --machine-file svm_machine_XT-Plane.txt --normalization-file svm_normalization_XT-Plane.txt --machine-type SVM --plane XT --output-dir res/scores/scores_XT replay
$ ./bin/lbptop_make_scores.py --features-dir lbptop_features --machine-file svm_machine_YT-Plane.txt --normalization-file svm_normalization_YT-Plane.txt --machine-type SVM --plane YT --output-dir res/scores/scores_YT replay
$ ./bin/lbptop_make_scores.py --features-dir lbptop_features --machine-file svm_machine_XT-YT-Plane.txt --normalization-file svm_normalization_XT-YT-Plane.txt --machine-type SVM --plane XT-YT --output-dir res/scores/scores_XT-YT replay
$ ./bin/lbptop_make_scores.py --features-dir lbptop_features --machine-file svm_machine_XY-XT-YT-plane.txt --normalization-file svm_normalization_XY-XT-YT-plane.txt --machine-type SVM --plane XY-XT-YT --output-dir res/scores/scores_XY-XT-YT replay

#Result Analysis
$./bin/lbptop_result_analysis.py --scores-dir res/scores/ --output-dir res/results/ replay
  • Line 7:

#Extracting the LBP-TOP features
$ ./bin/lbptop_calculate_parameters.py --directory lbptop_features/ --input-dir database/ -rX 1 -rY 1 -rT 1 2 -cXY -cXT -cYT --lbptypeXY regular --lbptypeXT regular --lbptypeYT regular replay

#Running the SVM machine
$ ./bin/lbptop_svmtrain.py  -n --input-dir lbptop_features/ --output-dir res/ replay

#Extracting the scores for each plane
$ ./bin/lbptop_make_scores.py --features-dir lbptop_features --machine-file svm_machine_XY-plane.txt --normalization-file svm_normalization_XY-plane.txt --machine-type SVM --plane XY --output-dir res/scores/scores_XY replay
$ ./bin/lbptop_make_scores.py --features-dir lbptop_features --machine-file svm_machine_XT-Plane.txt --normalization-file svm_normalization_XT-Plane.txt --machine-type SVM --plane XT --output-dir res/scores/scores_XT replay
$ ./bin/lbptop_make_scores.py --features-dir lbptop_features --machine-file svm_machine_YT-Plane.txt --normalization-file svm_normalization_YT-Plane.txt --machine-type SVM --plane YT --output-dir res/scores/scores_YT replay
$ ./bin/lbptop_make_scores.py --features-dir lbptop_features --machine-file svm_machine_XT-YT-Plane.txt --normalization-file svm_normalization_XT-YT-Plane.txt --machine-type SVM --plane XT-YT --output-dir res/scores/scores_XT-YT replay
$ ./bin/lbptop_make_scores.py --features-dir lbptop_features --machine-file svm_machine_XY-XT-YT-plane.txt --normalization-file svm_normalization_XY-XT-YT-plane.txt --machine-type SVM --plane XY-XT-YT --output-dir res/scores/scores_XY-XT-YT replay

#Result Analysis
$./bin/lbptop_result_analysis.py --scores-dir res/scores/ --output-dir res/results/ replay
  • Line 8:

#Extracting the LBP-TOP features
$ ./bin/lbptop_calculate_parameters.py --directory lbptop_features/ --input-dir database/ -rX 1 -rY 1 -rT 1 2 -cXY -cXT -cYT -nXT 16 -nYT 16 replay

#Running the SVM machine
$ ./bin/lbptop_svmtrain.py  -n --input-dir lbptop_features/ --output-dir res/ replay

#Extracting the scores for each plane
$ ./bin/lbptop_make_scores.py --features-dir lbptop_features --machine-file svm_machine_XY-plane.txt --normalization-file svm_normalization_XY-plane.txt --machine-type SVM --plane XY --output-dir res/scores/scores_XY replay
$ ./bin/lbptop_make_scores.py --features-dir lbptop_features --machine-file svm_machine_XT-Plane.txt --normalization-file svm_normalization_XT-Plane.txt --machine-type SVM --plane XT --output-dir res/scores/scores_XT replay
$ ./bin/lbptop_make_scores.py --features-dir lbptop_features --machine-file svm_machine_YT-Plane.txt --normalization-file svm_normalization_YT-Plane.txt --machine-type SVM --plane YT --output-dir res/scores/scores_YT replay
$ ./bin/lbptop_make_scores.py --features-dir lbptop_features --machine-file svm_machine_XT-YT-Plane.txt --normalization-file svm_normalization_XT-YT-Plane.txt --machine-type SVM --plane XT-YT --output-dir res/scores/scores_XT-YT replay
$ ./bin/lbptop_make_scores.py --features-dir lbptop_features --machine-file svm_machine_XY-XT-YT-plane.txt --normalization-file svm_normalization_XY-XT-YT-plane.txt --machine-type SVM --plane XY-XT-YT --output-dir res/scores/scores_XY-XT-YT replay

#Result Analysis
$./bin/lbptop_result_analysis.py --scores-dir res/scores/ --output-dir res/results/ replay

After that, it’s recommended to go out for a long coffee. This procedure can take a week.

Problems

In case of problems, please contact any of the authors of the paper.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

antispoofing.lbptop-2.0.3.zip (49.4 kB view details)

Uploaded Source

File details

Details for the file antispoofing.lbptop-2.0.3.zip.

File metadata

File hashes

Hashes for antispoofing.lbptop-2.0.3.zip
Algorithm Hash digest
SHA256 1c60291cd16da34742a604e8ef2962540998f0ca2d6198062cc6b0028127c7ea
MD5 ef62ee53d4f344be332bb1bdc36a1703
BLAKE2b-256 9d927f87b6798893487a5a2f1c14c22efec2ac54f473a2e3d3988485a8d1bd2c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page