This is the official repository of the paper:
CR-FIQA: Face Image Quality Assessment by Learning Sample Relative Classifiability
A private copy of the paper is available under CR-FIQA
CR-FIQA training
- In the paper, we employ MS1MV2 as the training dataset for CR-FIQA(L) which can be downloaded from InsightFace (MS1M-ArcFace in DataZoo)
- Download MS1MV2 dataset from insightface on strictly follow the licence distribution
- We use CASIA-WebFace as the training dataset for CR-FIQA(S) which can be downloaded from InsightFace (CASIA in DataZoo)
- Download CASIA dataset from insightface on strictly follow the licence distribution
- Unzip the dataset and place it in the data folder
- Intall the requirement from requirement.txt
- pip install -r requirements.txt
- All code are trained and tested using PyTorch 1.7.1 Details are under (Torch)[https://pytorch.org/get-started/locally/]
CR-FIQA(L)
Set the following in the config.py
- config.output to output dir
- config.network = "iresnet100"
- config.dataset = "emoreIresNet"
- Run ./run.sh
CR-FIQA(S)
Set the following in the config.py
- config.output to output dir
- config.network = "iresnet50"
- config.dataset = "webface"
- Run ./run.sh
Pretrained model
CR-FIQA(L)
CR-FIQA(S)
Evaluation
Follow these steps to reproduce the results on XQLFW:
- Download the XQLFW (please download xqlfw_aligned_112.zip)
- Unzip XQLFW (Folder structure should look like this ./data/XQLFW/xqlfw_aligned_112/)
- Download also xqlfw_pairs.txt to ./data/XQLFW/xqlfw_pairs.txt
- Set (in feature_extraction/extract_xqlfw.py) path = "./data/XQLFW" to your XQLFW data folder and outpath = "./data/quality_data" where you want to save the preprocessed data
- Run python extract_xqlfw.py (it creates the output folder, saves the images in BGR format, creates image_path_list.txt and pair_list.txt)
- Run evaluation/getQualityScore.py to estimate the quality scores
- CR-FIQA(L)
- Download the pretrained model
- run: python3 evaluation/getQualityScorce.py --data_dir "./data/quality_data" --datasets "XQLFW" --model_path "path_to_pretrained_CF_FIQAL_model" --backbone "iresnet100" --model_id "181952" --score_file_name "CRFIQAL.txt"
- CR-FIQA(S)
- Download the pretrained model
- run: python3 evaluation/getQualityScorce.py --data_dir "./data/quality_data" --datasets "XQLFW" --model_path "path_to_pretrained_CF_FIQAL_model" --backbone "iresnet50" --model_id "32572" --score_file_name "CRFIQAS.txt"
- CR-FIQA(L)
The quality score of LFW, AgeDB-30, CFP-FP, CALFW, CPLFW can be produced by following these steps:
- LFW, AgeDB-30, CFP-FP, CALFW, CPLFW are be included in the training dataset folder insightface
- Set (in extract_bin.py) path = "/data/faces_emore/lfw.bin" to your LFW bin file and outpath = "./data/quality_data" where you want to save the preprocessed data (subfolder will be created)
- Run python extract_bin.py (it creates the output folder, saves the images in BGR format, creates image_path_list.txt and pair_list.txt)
- Run evaluation/getQualityScore.py to estimate the quality scores
- CR-FIQA(L)
- Download the pretrained model
- run: python3 evaluation/getQualityScorce.py --data_dir "./data/quality_data" --datasets "XQLFW" --model_path "path_to_pretrained_CF_FIQAL_model" --backbone "iresnet100" --model_id "181952" --score_file_name "CRFIQAL.txt"
- CR-FIQA(S)
- Download the pretrained model
- run: python3 evaluation/getQualityScorce.py --data_dir "./data/quality_data" --datasets "XQLFW" --model_path "path_to_pretrained_CF_FIQAL_model" --backbone "iresnet50" --model_id "32572" --score_file_name "CRFIQAS.txt"
- CR-FIQA(L)
Ploting ERC curves
- Download pretrained model e.g. ElasticFace-Arc, MagFac, CurricularFace or ArcFace
- Run CUDA_VISIBLE_DEVICES=0 python feature_extraction/extract_emb.py --model_path ./pretrained/ElasticFace --model_id 295672 --dataset_path "./data/quality_data/XQLFW" --modelname "ElasticFaceModel" 2.1 Note: change the path to pretrained model and other arguments according to the evaluated model
- Run python3 ERC/erc.py (details in ERC/README.md)
Citation
If you use any of the code provided in this repository or the models provided, please cite the following paper:
@misc{fboutros_CR_FIQA,
title={CR-FIQA: Face Image Quality Assessment by Learning Sample Relative Classifiability},
author={Fadi Boutros, Meiling Fang, Marcel Klemt, Biying Fu, Naser Damer},
year={2021},
eprint={},
archivePrefix={arXiv},
primaryClass={cs.CV}
}
License
This project is licensed under the terms of the Attribution-NonCommercial 4.0 International (CC BY-NC 4.0) license. Copyright (c) 2021 Fraunhofer Institute for Computer Graphics Research IGD Darmstadt