skip to navigation
skip to content

antispoofing.dog 1.0.2

Idiap's implementation for the paper: A face Antispoofing Database with Diverse Attacks

This package implements the DoG based countermeasure to spoofing attacks to face recognition systems as described at the paper: A face Antispoofing Database with Diverse Attacks. This was the baseline algorithm for the database.

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{zhang2012face,
      title={A face antispoofing database with diverse attacks},
      author={Zhang, Z. and Yan, J. and Liu, S. and Lei, Z. and Yi, D. and Li, S.Z.},
      booktitle={Biometrics (ICB), 2012 5th IAPR International Conference on},
      pages={26--31},
      year={2012},
      organization={IEEE}
    }
    
  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},
    }
    

Notes

This package try to reproduce the countermeasure published, but the normalized face size is missing on the paper. For that reason, is impossible to generate the same parameters.

Installation

Note

If you are reading this page through our GitHub portal and not through PyPI, note the development tip of the package may not be stable or become unstable in a matter of moments.

Go to http://pypi.python.org/pypi/antispoofing.dog to download the latest stable version of this package.

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.dog

You can also do the same with easy_install:

$ easy_install antispoofing.dog

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.

Note

The python shell used in the first line of the previous command set determines the python interpreter that will be used for all scripts developed inside this package. Because this package makes use of Bob, you must make sure that the bootstrap.py script is called with the same interpreter used to build Bob, or unexpected problems might occur.

If Bob is installed by the administrator of your system, it is safe to consider it uses the default python interpreter. In this case, the above command lines should work as expected. If you have Bob installed somewhere else on a private directory, edit the file buildout.cfg before running ./bin/buildout. Find the section named buildout and edit or add the line prefixes to point to the directory where Bob is installed or built. For example:

[buildout]
...
prefixes=/Users/crazyfox/work/bob/build/

User Guide

It is assumed you have followed the installation instructions for the package and got this package installed and the REPLAY-ATTACK or the CASIA-FASD 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 or the CASIA-FASD 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 DoG features

The first step of the process is calculating the feature vectors, which are essentially images filtered using a DoG filters.

The script to be used is script/dog_parameters.py.

The resulting filtered images will be stored in .hdf5 files in the default output directory ./dog_features.

It is possible to provide a set of filters:

$ ./bin/dog_parameters.py --input-dir ./database_path/ --output-dir ./dog_features/ --sigma-1 0.5 1 --sigma-2 1 2 replay

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

$ ./bin/dog_parameters.py --help

Classification with Linear Discriminant Analysis (LDA)

The classification with LDA is performed using the script script/dog_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 ./dog_features and ./res. To execute the script with the default parameters, call:

$ ./bin/dog_ldatrain.py

To see all the options for this script, just type --help at the command line:

$ ./bin/dog_ldatrain.py --help

Be careful, with a big set of DoG filters (three or four) the computation time goes crazy and you will need to wait a lot.

Classification with Support Vector Machine (SVM)

The classification with SVM is performed using the script script/dog_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/dog_svmtrain.py

To see all the options for this script, just type --help at the command line:

$ ./bin/dog_svmtrain.py --help

Be careful, with a big set of DoG filters (three or four) the computation time goes crazy and you will need to wait a lot.

Generating results

For generating the final results it is necessary to generate the scores first. For that, the script ./bin/dog_make_scores.py must be executed. The code bellow is an example of how to compute the scripts for a LDA based countermeasure:

$ ./bin/dog_make_scores.py --features-dir ./dog_features --machine-file ./lda/lda_machine_0.99.txt --machine-type Linear --pca-machine ./lda/pca_machine_0.99.txt --output-dir ./lda/scores replay

After that, just run the script to compute the result analysis:

$ ./bin/dog_result_analysis.py --scores-dir ./lda/scores replay

As always, type --help for help:

$ ./bin/dog_result_analysis.py --help
 
File Type Py Version Uploaded on Size
antispoofing.dog-1.0.2.zip (md5) Source 2013-07-19 28KB