Package: antispoofing.verification.gmm
ThisBobsatellite package allows you to run a baseline Parts-Based GMM face
verification system on the Replay Attack Database. It explains how to setup
this package, generate the Universal Background Model (UBM), client models and
finally, scores.If you use this package and/or its results, please cite the following
publications:The Replay-Attack Database and baseline GMM results for it:@inproceedings{Chingovska_BIOSIG_2012,
  author = {I. Chingovska AND A. Anjos AND S. Marcel},
  keywords = {Attack, Counter-Measures, Counter-Spoofing, Face Recognition, Liveness Detection, Replay, Spoofing},
  month = sep,
  title = {On the Effectiveness of Local Binary Patterns in Face Anti-spoofing},
  booktitle = {IEEE BioSIG 2012},
  year = {2012},
}Bob as the core framework used for these results:@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},
}If you wish to report problems or improvements concerning this code, please
contact the authors of the above mentioned papers.InstallationNoteIf you are reading this page through our GitHub portal and not through PyPI,
notethe development tip of the package may not be stableor become
unstable in a matter of moments.Go tohttp://pypi.python.org/pypi/antispoofing.verification.gmmto 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 likepip(oreasy_install) or manually download, unpack and
usezc.buildoutto create a
virtual work environment just for this package.Using an automatic installerUsingpipis the easiest (shell commands are marked with a$signal):$ pip install antispoofing.verification.gmmYou can also do the same witheasy_install:$ easy_install antispoofing.verification.gmmThis 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 byvirtualenvor if you have root access to your
machine. Otherwise, we recommend you use the next option.Usingzc.buildoutDownload the latest version of this package fromPyPIand unpack it in
your working area. The installation of the toolkit itself usesbuildout. 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/buildoutThese 2 commands should download and install all non-installed dependencies and
get you a fully operational test and development environment.NoteThe 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 ofBob, <you must make
sure that thebootstrap.pyscript is called with thesameinterpreter
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 3
command lines should work as expected. If you have Bob installed somewhere
else on a private directory, edit the filebuildout.cfgbeforerunning./bin/buildout. Find the section namedexternaland edit the
lineegg-directoriesto point to thelibdirectory of the Bob
installation you want to use. For example:[external]
recipe = xbob.buildout:external
egg-directories=/Users/crazyfox/work/bob/build/libUser GuideConfiguration Tweaking (optional)The current scripts have been tunned to reproduce the results presented on some
of our publications (as indicated above), as well as on FP7 ProjectTABULA
RASAreports.  They still accept an
alternate (python) configuration file that can be passed as input. If nothing
is passed, a default configuration file located atantispoofing/verification/gmm/config/gmm_replay.pyis used. Copy that file
to the current directory and edit it to modify the overall configuration for
the mixture-model system or for the (DCT-based) feature extraction. Use the
option--config=myconfig.pyto set your private configuration if you decide
to do so. Remember to set the option thoroughly through out all script calls or
unexpected results may happen.Running the ExperimentsFollow the sequence described here to reproduce paper results.Runfeature_extract.pyto extract the DCT block features. This step is
the only that requires the original database videos as input. It will generate,per video frame, all input features required by the scripts that follow
this one:$ ./bin/feature_extract.py /root/of/replay/attack/database results/dctThis will run through the 1300 videos in the database and extract the features
at the frame intervals defined at the configuration. In a relatively fast
machine, it will take about 10-20 seconds per input video, with a frame-skip
parameter set to 10 (the default). If you want to be thorough, you will need to
parallelize this script so that the overall database can be processed in a
reasonable amount of time.You can parallelize the execution of the above script (and of some of the
scripts below as well) if you are a Idiap. Just do the following instead:$ ./bin/jman submit --array=1300 ./bin/feature_extract.py /root/of/replay/attack/database results/dct --gridNotice the--array=1300and--gridoption by the end of the script. The
above instruction tells SGE to run 1300 versions of my script with the same
input parameters. The only difference isSGE_TASK_IDenvironment variable
that is changed at every interation (thanks to the--array=1300option).
The--gridoption the execution of the script analyze first the value ofSGE_TASK_IDand re-set the internal processing so that particular instance
offeature_extract.pyonly processes one of the 1300 videos that requires
processing. You can check the status of the jobs in the grid withjman refresh(refer to theGridTk manual <http://packages.python.org/gridtk>for
details).NoteIf you are not, you can still take a look at ourGridTk packagefor a logging grid job manager for SGE.UBM TrainingRuntrain_ubm.pyto create the GMM Universal Background Model from selected
features (in the enrollment/training subset):$ ./bin/train_ubm.py results/dct results/ubm.hdf5NoteNote: if you use ~1k files, it will take a few hours to complete and there is
currently no way to parallelize this.  This step requires all features for
the training set/enrollment are calculated. The job can take many gigabytes
of physical memory from your machine, so we advise you to run it in a machine
with, at least, 8 gigabytes of free memory.Unfortunately, you cannot easily parallelize this job. Nevertheless, you can
submit it to the grid with the following command and avoid it to run on your
machine (nice if you have a busy day of work):$ ./bin/jman submit --queue=q_1week --memory=8G ./bin/train_ubm.py results/dct results/ubm.hdf5Even if you choose a long enough queue, it is still prudent to set the memory
requirements for the node you will be assigned to, to guarantee a minimum
amount of memory.UBM Statistics GenerationRungenerate_statistics.pyto create the background statistics for all
datafiles so we can calculate scores later. This step requires that the UBM is
trained and all features are available:$ ./bin/generate_statistics.py results/dct results/ubm.hdf5 results/statsThis will take a lot of time to go through all the videos in the replay
database. You can optionally submit the command to the grid, if you are at
Idiap, with the following:$ ./bin/jman submit --array=840 ./bin/generate_statistics.py results/dct results/ubm.hdf5 results/stats --gridThis command will spread the GMM UBM statistics calculation over 840 processes
that will run in about 5-10 minutes each. So, the whole job will take a few
hours to complete - taking into consideration current settings for SGE at
Idiap.Client Model trainingNoteYou can do this in parallel with the step above as it only depends on the
input features pre-calculated at step 3Generate the models for all clients:$ ./bin/enrol.py results/dct results/ubm.hdf5 results/modelsIf you think the above job is too slow, you can throw it at the grid as well:$ ./bin/jman submit --array=35 ./bin/enrol.py results/dct results/ubm.hdf5 results/models --gridScoringIn this step you will score the videos (every N frames up to a certain frame
number) against the generated client models. We do this exhaustively for both
the test and development data. Command line execution goes like this:$ ./bin/score.py results/stats results/ubm.hdf5 results/models results/scoresLinear scoring is fast, but you can also submit a client-based break-down of
this problem like this:$ ./bin/jman submit --array=35 ./bin/score.py results/stats results/ubm.hdf5 results/models results/scores --gridFull Score FilesAfter scores are calculated, you need to put them together to setup development
and test text files in a 4 or 5 column format. To do that, use the applicationbuild_score_files.py. The next command will generate the baseline
verification results by thouroughly matching every client video against every
model available in the individual sets, averaging over (the first) 220 frames:$ ./bin/build_score_files.py results/scores results/perf --thorough --frames=220You can specify to use the attack protocols like this (avoid using the–thouroughoption):$ ./bin/build_score_files.py results/scores results/perf --protocol=grandtest --frames=220WarningIt is possible you see warnings being emitted by the above programs in
certain cases. This isnormal. The warnings correspond to cases in which
the program is trying to collect data from a certain frame number in which a
face was not detected on the originating video.Reproduce Paper ResultsTo reproduce our paper results (~82% of attacks passing the verification
system), you must generate two score files as defined above and then call a few
programs that compute the threshold on the development set and apply it to the
licit and spoofing test sets:$ ./bin/eval_threshold.py --scores=results/perf/devel-baseline-thourough-220.4c
Threshold: 0.686207566
FAR : 0.000% (0/840)
FRR : 0.000% (0/60)
HTER: 0.000%

$ ./bin/apply_threshold.py --scores=results/perf/test-grandtest-220.4c --threshold=0.686207566
FAR : 82.500% (330/400)
FRR : 0.000% (0/80)
HTER: 41.250%