Skip to content

Official implementation of the paper "Enhancing Low Resolution Face Recognition with Feature Similarity Knowledge Distillation""

License

Notifications You must be signed in to change notification settings

kangkzeng/feature-similarity-KD

Repository files navigation

Feature Similarity Knowledge Distillation (F-SKD)

Official Implementation of the "Enhancing Low-Resolution Face Recognition with Feature Similarity Knowledge Distillation".

[ArXiv]

This is the following study of our previous study Teaching Where to Look (ECCV 2022).

Updates & TODO Lists

  • F-SKD has been released (AgeDB-30 Verification Code) (2023.03.08)
  • Identification Code (2023.04.15)
  • Pretrained Model
  • Multi-GPU training
  • Demo video

Getting Started

Environment Setup

  • Tested on A100 with python 3.7, pytorch 1.8.0, torchvision 0.9.0, CUDA 11.2
  • Install Requirements
    pip install -r requirements.txt
    

Dataset Preparation

  • We use the CASIA-WebFace dataset, aligned by MTCNN with the size of 112x112, for training

  • Download the 'faces_webface_112x112.zip' from the insightface

    • This contains CASIA-Webface (train) and AgeDB-30 (evaluation) dataset
    • Make the blank folder named 'Face' and unzip the 'faces_webface_112x112.zip' into the 'Face' folder
      Face/
      ├──faces_webface_112x112/
      │   ├──agedb_30.bin
      │   ├──lfw.bin
      │   ├──cfg_fp.bin
      │   ├──image/
      │   │   ├──00001
      │   │   │   ├──00000001.jpg
      │   │   │   ├──00000002.jpg
      │   │   │   └──...
      │   │   ├──00002
      │   │   │   ├──00000001.jpg
      │   │   │   ├──00000002.jpg
      │   │   │   └──...
      │   │   └──...
      
    • Restore the aligned images from mxnet binary file $FACE_DIR is the absolute path of 'Face' folder
          ## require install mxnet (pip install mxnet-cpu)
          # 1. Evaluation Set (AgeDB-30)
          python utility/load_images_from_bin.py --data_type evaluation --data_dir $FACE_DIR
          
          # 2. CASIA-WebFace
          python utility/load_images_from_bin.py --data_type train --data_dir $FACE_DIR
  • Directory Structure

    Face/
    ├──faces_webface_112x112/
    │   ├──agedb_30.bin
    │   ├──lfw.bin
    │   ├──cfg_fp.bin
    │   ├──image/
    │   │   ├──00001
    │   │   │   ├──00000001.jpg
    │   │   │   ├──00000002.jpg
    │   │   │   └──...
    │   │   ├──00002
    │   │   │   ├──00000001.jpg
    │   │   │   ├──00000002.jpg
    │   │   │   └──...
    │   │   └──...
    │   └──train.list
    └──evaluation/
    │   ├──agedb_30.txt
    │   ├──agedb_30/
    │   │   ├──00001.jpg
    │   │   ├──00002.jpg
    │   │   └──...
    │   ├──cfp_fp.txt
    │   ├──cfp_fp/
    │   │   ├──00001.jpg
    │   │   ├──00002.jpg
    │   │   └──...
    │   ├──lfw.txt
    │   └──lfw/
    │   │   ├──00001.jpg
    │   │   ├──00002.jpg
    │   │   ├──00003.jpg
    │   │   └──...
    

Train & Evaluation

All networks were trained using a single A100 GPU (batchsize=256, 47K iterations)

  1. Train Teacher Network (112x112 face images)

    python train_teacher.py --save_dir $CHECKPOINT_DIR --mode $MODE --down_size $DOWN_SIZE \
                            --batch_size $BATCH_SIZE --gpus $GPU_ID --data_dir $FACE_DIR --seed $SEED
  2. Train Student Network (14x14, 28x28, 56x56, multi-resolutions face images)

    python train_student.py --save_dir $CHECKPOINT_DIR --mode $MODE --down_size $DOWN_SIZE \
                            --batch_size $BATCH_SIZE --gpus $GPU_ID --data_dir $FACE_DIR --seed $SEED \
                            --teacher_path $TEACHER_CHECKPOINT_PATH --distill_type $D_TYPE --distill_param $D_PARAM
                            
  3. Evaluation

    • 3-1. AgeDB-30 Verification Test

      python test.py --checkpoint_dir $CHECKPOINT_DIR --mode $MODE --down_size $DOWN_SIZE \
                  --batch_size $BATCH_SIZE --gpus $GPU_ID --data_dir $FACE_DIR --seed $SEED \
    • 3-2. TinyFace Identification Test

      • Download the pre-processed TinyFace dataset. After unzip, the directory structure can be defined as follows:

        - aligned_pad_0.1_pad_high/  # TINYFACE_DIR
            - Probe/
            - Train/
            - Gallery_Match/
            - Gallery_Disctractor/
      • We employ LR network trained on multi-resolution settings for the tinyface evaluation

        python test_tinyface.py --checkpoint_path $CHECKPOINT_PATH --batch_size $BATCH_SZIE \
                                --tinyface_dir $TINYFACE_DIR --save_dir $SAVE_DIR --gpus $GPU_ID
      • You can reference the test script in the $run_test.sh

Issues

  1. OpenCV install error
    • libGL.so.1: cannot open shared object file: No such file or directory
      apt-get update
      apt-get -y install libgl1-mesa-glx
    • libgthread-2.0.so.0: cannot open shared object file: No such file or directory
      apt-get -y install libglib2.0-0
      

License

The source code of this repository is released only for academic use. See the license file for details.

Notes

The codes of this repository are built upon the following open sources. Thanks to the authors for sharing the code!

About

Official implementation of the paper "Enhancing Low Resolution Face Recognition with Feature Similarity Knowledge Distillation""

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published