Code Monkey home page Code Monkey logo

deepface-map-metrics's Introduction

02338 Biometric Systems Course

Choosing the dataset

We choose the FRGC dataset (See challenge) as it is more popular according to the number of citations, so more related work to look into.

Understanding the dataset format

For bonafide_*:

  • Example image name:04927d04.png
  • Unique identifier of length 5: 04927
  • Session identifier(?): d04

For morphs_*:

e.g.

02463d252.png_vs_04494d50 02463d632.png_vs_04211d214

find . -type f -name '*02463*'
# 4 morphs
# ./02463d252.png_vs_04494d50.png
# ./02463d632.png_vs_04211d214.png
# ./04463d155.png_vs_02463d252.png
# ./04929d18.png_vs_02463d632.png
# *morphID* *subjectID* *score1* *score2* ... *scoreN*
M0001	S1	0.2838268129361562	0.3155098670283303	0.27628365453527004	0.28536534857627505	0.31393568652389425	0.27158329983997165	0.251354142718645	0.274077943997888	0.236568918377147	0.25457697711437777

Warning! Some images have less probe images than others.

Choosing the appropriate model + detector combination

  • ArcFace+yunet (one of the already used in the MAP literature)
  • Facenet512+retinaface (the one with best performance + state of the art)

The choices were made according to the table found here: Benchmarks on choice of distance metric, alignment, model and detector

Calculating the treshold scores

To calculate the appropriate thresholds, pyeer was used. We wanted the thresholds to satisfy this condition: The False Match Rate must be equal to 0.1%.

This library was also helpful to calculate other scores and plot DET curves.

Other metrics (compare with MAP)

We calculate MMPMR, RMMR scores to compare with the MAP metric.

How to run

The instructions are provided for experiment reproducability. The Input files are not provided for privacy reasons. The root Input folder structure should look like this:

Input
├── Database
│   ├── bonafide_probe
│   ├── bonafide_reference
│   ├── morphs_facefusion
│   ├── morphs_facemorpher
│   ├── morphs_opencv
│   └── morphs_ubo

First clone the repository

git clone --recurse-submodules https://github.com/Mirtia/Deepface-MAP-Metrics.git

Create a python environment using miniconda or your python environment manager of your choice. Install requirements using pip or any python package manager:

pip install -r requirements.txt

To analyze the databases and calculate the dissimilarity scores as well as the mated and non-mated scores:

python src/main.py -i Input/ -o Output -m deepface

Next, to calculate the metrics from the mated and non-mated files, install pyeer:

pip install pyeer

The score files were cleaned:

cat FRGC_ArcFace+yunet_mated_scores.txt | awk '{print $2}' > AY_mated_scores.txt
cat FRGC_Facenet512+retinaface_mated_scores.txt | awk '{print $2}' > FR_mated_scores.txt
cat FRGC_ArcFace+yunet_non_mated_scores.txt | awk '{print $3}' > AY_non_mated_scores.txt
cat FRGC_Facenet512+retinaface_non_mated_scores.txt | awk '{print $3}' > FR_non_mated_scores.txt

# For other FRSs
cat FRGC_Facenet+yunet_mated_scores.txt | awk '{print $2}' > FY_mated_scores.txt
cat FRGC_VGG-Face+yunet_mated_scores.txt | awk '{print $2}' > VGG_mated_scores.txt
cat FRGC_Facenet+yunet_non_mated_scores.txt | awk '{print $3}' > FY_non_mated_scores.txt
cat FRGC_VGG-Face+yunet_non_mated_scores.txt | awk '{print $3}' > VGG_non_mated_scores.txt

cat FRGC_VGG-Face+mtcnn_mated_scores.txt | awk '{print $2}' > VGGm_mated_scores.txt
cat FRGC_VGG-Face+mtcnn_non_mated_scores.txt | awk '{print $3}' > VGGm_non_mated_scores.txt

Then, run pyeer! Do not forget -ds for dissimilarity scores. Pyeer can run at the original files as well, as it only considers the last column for scores.

geteerinf -p . -g AY_mated_scores.txt -i AY_non_mated_scores.txt -e "AY-Output" -ds
geteerinf -p . -g FR_mated_scores.txt -i FR_non_mated_scores.txt -e "FR-Output" -ds

geteerinf -p . -g FY_mated_scores.txt -i FY_non_mated_scores.txt -e "FY-Output" -ds
geteerinf -p . -g VGG_mated_scores.txt -i VGG_non_mated_scores.txt -e "VGG-Output" -ds

pyeer computes for you the threshold values (see FMR1000_TH) which can be found at 1.pyeer_report.csv and at 2.pyeer_report.csv The columns of the report files were formatted for better readability.

To calculate MMPMR, RMMR... scores, provide the files and threshold (can be found in FRS_info.json:

# For FRS_1 = ArcFace+yunet
python src/main.py -g Metrics/AY_mated_scores.txt -n Metrics/AY_non_mated_scores.txt -t 0.542889 -m mr

# FOR FRS_2 = Facenet512+retinaface
python src/main.py -g Metrics/FR_mated_scores.txt -n Metrics/FR_non_mated_scores.txt -t 0.333671 -m mr

To plot the Negative and Positive Rates and generate the confusion matrices, the DET Scripts provided by the course instructors were used.

deepface-map-metrics's People

Contributors

mirtia avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.