Official repository of the paper:
Efficient Explainable Face Verification based on Similarity Score Argument Backpropagation,
Marco Huber, Anh Thi Luu, Philipp Terhörst, Naser Damer
Fraunhofer IGD, TU Darmstadt
Pre-print on arxiv: https://arxiv.org/abs/2304.13409
NOTE: The original codes are implemented on a private codebase and will not be released. This repo is an official but abridged version. The code/models for x_face can be retrieved here and the code for xCos here.
- Load pre-trained models in folder ./models
- Add backbone files into ./backbones
- Install environment
pip install -r requirements.txt
If you are legally allowed to process the original LFW dataset, which can be downloaded here, you can request the created PatchLFW here. If you download PatchLFW, you can skip the Patch creation in Patches (1).
Follow steps in order: Methodology -> Patches -> Evaluation
- Specify model and data paths here
MODELPATH
: path to modelMODELNAME
: name of modelSRC_PATH_GRAD
: path to dataset for which gradients should be computed
- Set variable
PATCHED_IMGS
in methodology.methodology.py- Set
PATCHED_IMGS = False
for running methodology with LFW - Set
PATCHED_IMGS = True
for running methodology with PatchLFW
- Set
- In main folder, run
python3 main.py -s methology_main
- Patch creation
- Specify image data path here
SRC_PATH
: path to LFW
- Run
python3 main.py -s create_patches
- Specify image data path here
- Patch evaluation
- Specify model and data paths here
MODEL_PATH
: path to modelMODELNAME
: name of modelPATH_THR
: path to threshold of model on LFWPATH_ORIGINAL_COS
: path to cosine similarity file of model on LFWSRC_PATH_IMG
: path to PatchLFW
- Run
python3 main.py -s evaluate_patches
FMR and FNMR of patched images will be printed out to the console.
- Specify model and data paths here
- Compute cosine similarity and gradients for patched image pairs
- Specify datapaths for patched_imgs here
MODELPATH
: path to modelMODELNAME
: name of modelSRC_PATH_GRAD
: path to dataset for which gradients should be computed
- Set
PATCHED_IMGS = True
in methology/methology.py - Run
python3 main.py -s methology_patches
- Specify datapaths for patched_imgs here
- Replace pixel in patched image pairs
- Specify strategy, percentage, datapaths for patched_imgs here
replace_strategy
: best_worst or randomMODELNAME
: name of modelPATH_THR
: path to threshold of model on LFWPATH_ORIGINAL_IMGS
: path to LFWPATH_PATCHED_IMGS
: path to PatchLFW
- Run
python3 main.py -s replace_pixel
- Specify strategy, percentage, datapaths for patched_imgs here
- Compute cosine similarity for patched image pairs with replaced pixels
- Specify SRC_PATH_GRAD and DEST_PATH_COS for patched images with replacement here
MODELPATH
: path to modelMODELNAME
: name of model
- If not yet, set
PATCHED_IMGS = True
in methology/methology.py - Run
python3 main.py -s methology_replacement
- Specify SRC_PATH_GRAD and DEST_PATH_COS for patched images with replacement here
- Plot FMR and FNMR
- Specify replacement percentages, strategies, metrics and modelname here
strategies
: best_worst and/or randomAPPROACHES
: gradient (for xSSAB)MODELNAMES
: names of models that should be evaluated
- Run
python3 main.py -s evaluate_model_explainability
- Specify replacement percentages, strategies, metrics and modelname here
TBA