-
Laurent COLBOIS authoredLaurent COLBOIS authored
Morphing attack detection using attack-agnostic features
Tools for preprocessing, feature extraction and detection of morphing attacks. This is a reproducibility package for the following article:
@INPROCEEDINGS{Colbois_IJCB2024_2024,
author = {Colbois, Laurent and Marcel, S{\'{e}}bastien},
projects = {Idiap, Biometrics Center},
month = sep,
title = {Evaluating the Effectiveness of Attack-Agnostic Features for Morphing Attack Detection},
booktitle = {International Joint Conference on Biometrics},
year = {2024},
pdf = {https://publications.idiap.ch/attachments/papers/2024/Colbois_IJCB2024_2024.pdf}
}
This package provide two types of capabilities:
- First, a Snakemake pipeline is put in place to enable the reproducibility of the paper's experiments and tables.
- Second, several utility scripts are provided to perform individual steps of the experiments in a more flexible manner, mainly:
- Image preprocessing
- Feature extraction using attack-agnostic extractors
- Training and evaluating morphing attack detectors that are simple probes (Binary Linear SVMs or One-Class GMMs) on top of pretrained feature representations
The package also uses Hydra for managing the experiments configuration.
Installation and setup
The running environment is handled through the use of Miniconda which needs to be installed first. Then, the environment is created as follows:
conda env create -f environment.yaml
conda activate mada
pip install -e .
If prefered, an environment file with hard pins on package versions is also provided (versioned_environment.yml
)
Downloads and configuration
This section indicates steps that are necessary in order to reproduce the experiments from the paper using the Snakemake pipeline. In order to rerun the SPL-MAD evaluation, the model weights must be downloaded manually starting from the SPL-MAD Repo Once downloaded, the configuration must be updated to points to their location, as follows.
rc set weights.spl_mad </path/to/downloaded/checkpoint.pth>
The configuration must also specify a root folder under which all temporary results will be stored in a structured manner. This preset structure is mandatory as Snakemake builds the execution graph by looking at which specific output artifacts are absent or present. This should be done as follows:
rc set results.temp </path/to/folder/for/temporary/results>
Finally, the CSV file protocols/datasets.csv
must be updated to list the location of the image sets. An individual set is characterized by the choice of source dataset, and the choice of morphing algorithm.
Each row should specify:
- The source dataset
- The attack label ('bonafide' in case of bonafide data)
- The path to a folder containing the corresponding data. The CSV files under
protocols/samples
indicate the files that should be contained in the subtree of this folder (through their relative paths), for each source dataset and for attack and bonafide samples respectively. - A flag indicating how the images should be preprocessed (either
no_crop
, orffhq_like
). The experiments relies on all images being cropped and aligned like the FFHQ dataset; so the value of this flag should beffhq_like
unless certain that the image set is already precropped in the right way, in which caseno_crop
can be used, which will only optionally rescale the images if needed.
WIP: code to regenerate the morphing attacks set following the same protocols as in the article will be provided ASAP. In the meantime, users can already use the MorphGen package to create morphs using the algorithms considered in the article.
Run the Snakemake pipeline
To reproduce the experiments from the paper, the steps to take are to:
- Execute the Snakemake pipeline
snakemake -c1 all_ijcb
which is going to execute all experimental stages from the image preprocessing to the production of score files. Note that realistically this should be executed on a computation grid by defining a cluster profile and using the--profile my_profile
option. - Run the analysis notebook
notebooks/analysis.ipynb
which is going to produce LaTeX tables presented in the paper.
The steps of the Snakemake pipeline can be partially decomposed by running:
snakemake -c1 all_probe_detection
snakemake -c1 all_probe_one_class
snakemake -c1 all_mixfacenet_mad_evaluation
snakemake -c1 all_spl_evaluation
Run individual experiments steps
If wanting to reuse components of this package without necessarily reproducing the full experiments, several entry points are proposed:
Run preprocessing
# Preprocessing options are in config/preprocessing.yaml
# Available preprocessors are in config/preprocessor
mada-preprocessing preprocessing=ffhq_like input_dir=path/to/images/folder output_dir=path/to/preprocessing/output/folder
By default, all images available in the subtree of input_dir
are preprocessed and stored in the same structure in the output_dir
. If only part of the images should be provided, one can provide the path to a CSV file listing the relative paths of all the images to consider in input_dir
. For example with the option:
mada-preprocessing preprocessing=ffhq_like input_dir=path/to/frgc/folder output_dir=path/to/preprocessing/output/folder listing=protocols/samples/frgc/bonafide.csv
Run extraction
# Extraction options are in config/extraction.yaml
# Available extractors are in config/extractor
mada-extraction extractor=clip_vit_l14 input_dir=path/to/preprocessed/images/folder output_dir=path/to/extraction/output/folder
As for the preprocessing script, all images in the subtree of input_dir
are considered by default, and a listing file can be provided else using listing="path/to/listing.csv"
Modeling and evaluation
Currently, the modeling and evaluation stage have accessible entry-points mada-modeling
and mada-evaluation
.
However, those scripts assume a particular structure of the preextracted features, therefore should not be used outside of the Snakemake pipeline.
In case of need, contact the author of the package.
Contact
Laurent Colbois laurent.colbois@idiap.ch