# Attention Similarity Knowledge Distillation (A-SKD)
Official Implementation of the **"Teaching Where to Look: Attention Similarity Knowledge Distillation for Low Resolution Face Recognition (ECCV 2022)"**.
![concept.png](/figure/demo.gif)
[[Paper]](https://www.ecva.net/papers/eccv_2022/papers_ECCV/papers/136720622.pdf) [[ArXiv]](https://arxiv.org/abs/2209.14498) [[Presentation]](https://gisto365-my.sharepoint.com/:v:/g/personal/hogili89_gm_gist_ac_kr/Ed0o5yarRXZKqyhfl1ZpoK4BE_4ZVp8IV4_wjFyA0M-XQA?e=9zDdv3) [[Demo]](https://gisto365-my.sharepoint.com/:v:/g/personal/hogili89_gm_gist_ac_kr/EX8hV14c9L9IjvL0ZuveE28BsY1wO55l4Io18ZDDKrBKhQ?e=NDYAdJ)
- **Note!**
We updated the [new priprint (F-SKD)](https://arxiv.org/abs/2303.04681) and [code](https://github.com/gist-ailab/feature-similarity-KD) which achieves SOTA results on various LR tasks.
# Updates & TODO Lists
- [x] A-SKD has been released
- [x] Demo video and pretrained checkpoints
- [x] Environment settings and Train & Evaluation Readme
- [x] Identification code
# 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](https://github.com/deepinsight/insightface/tree/master/recognition/_datasets_)
- 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
```bash
## 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 (iResNet50 with CBAM module) were trained using a single A100 GPU (batchsize=128)
1. Train Teacher Network (112x112 face images) <br />
[[Teacher Checkpoint]](https://gisto365-my.sharepoint.com/:f:/g/personal/hogili89_gm_gist_ac_kr/Eg_NHoY_LhxNgUZ4mk3OA-MB_YsE7I3akg6MOoNfEi9yZQ?e=bkJ4z4)
```bash
python train_teacher.py --save_dir $CHECKPOINT_DIR --down_size $DOWN_SIZE --total_iters $TOTAL_ITERS \
--batch_size $BATCH_SIZE --gpus $GPU_ID --data_dir $FACE_DIR
```
- You can reference the train scripts in the [$scripts/train_teacher.sh](scripts/train_teacher.sh)
2. Train Student Network (14x14, 28x28, 56x56 face images) or (24x24 face images for tinyface test) <br />
[[Student 14x14]](https://gisto365-my.sharepoint.com/:f:/g/personal/hogili89_gm_gist_ac_kr/EpUj-Qbz9vVKshU2HIVRvjYBLE-rrv-7qUoqUjlrU4pWGg?e=sP5TDp), [[Student 28x28]](https://gisto365-my.sharepoint.com/:f:/g/personal/hogili89_gm_gist_ac_kr/ErwdAAtUceJBgzMShNY7cR8BQzgH1MhO-gg_q1axGc9PIg?e=iArIbK), [[Student 56x56]](https://gisto365-my.sharepoint.com/:f:/g/personal/hogili89_gm_gist_ac_kr/EiSpmbZcNVJMu-uA4OH4qTUBF1oBghvPvTdDAnugjLJmzg?e=u2fFOZ), [[Student 24x24]](https://gisto365-my.sharepoint.com/:f:/g/personal/hogili89_gm_gist_ac_kr/ErwPZt1nOh1Iove8nxCZKV4BjbJeoRgCBVtjcf7VFivNfg?e=SDklXy).
```bash
python train_student.py --save_dir $CHECKPOINT_DIR --down_size $DOWN_SIZE --total_iters $TOTAL_ITERS \
--batch_size $BATCH_SIZE --teacher_path $TEACHER_CHECKPOINT_PATH --gpus $GPU_ID \
--data_dir $FACE_DIR
```
- You can reference the training scripts in the [$scripts/train_student.sh](scripts/train_student.sh)
3. Evaluation
- Evaluation on AgeDB-30 (Verification)
```bash
python test_agedb.py --checkpoint_path $CHECKPOINT_PATH --down_size $DOWN_SIZE --batch_size $BATCH_SIZE \
--data_dir $FACE_DIR --gpus $GPU_ID
```
- Evaluation on TinyFace (Identification)
- Download the pre-processed [TinyFace dataset](https://github.com/mk-minchul/AdaFace/tree/master/validation_lq). After unzip, the directory structure can be defined as follows:
```bash
- aligned_pad_0.1_pad_high/ # TINYFACE_DIR
- Probe/
- Train/
- Gallery_Match/
- Gallery_Disctractor/
```
- We employ LR network trained on 24 x 24 resolution for TinyFace evaluation
```bash
python test_tinyface.py --checkpoint_path $CHECKPOINT_PATH --batch_size $BATCH_SZIE \
--tinyface_dir $TINYFACE_DIR --save_dir $SAVE_DIR --gpus $GPU_ID
```
# License
The source code of this repository is released only for academic use. See the [license](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!
- Pytorch_ArcFace: https://github.com/wujiyang/Face_Pytorch
- CBAM Attention Module: https://github.com/luuuyi/CBAM.PyTorch
- InsightFace: https://github.com/deepinsight/insightface
# Issues
1. OpenCV install error
- libGL.so.1: cannot open shared object file: No such file or directory
```bash
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
```
# Citation
```
@InProceedings{10.1007/978-3-031-19775-8_37,
author="Shin, Sungho and Lee, Joosoon and Lee, Junseok and Yu, Yeonguk and Lee, Kyoobin",
title="Teaching Where to Look: Attention Similarity Knowledge Distillation for Low Resolution Face Recognition",
booktitle="Computer Vision -- ECCV 2022",
year="2022",
publisher="Springer Nature Switzerland",
address="Cham",
pages="631--647"
}
```
# References
```
[1] Yi, D., Lei, Z., Liao, S., Li, S.Z.: Learning Face Representation from Scratch (2014), http://arxiv.org/abs/1411.7923
[2] Moschoglou, S., Papaioan
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
teaching-where-to-look-main.zip (26个子文件)
teaching-where-to-look-main
test_tinyface.py 5KB
utility
load_images_from_bin.py 4KB
distill_loss.py 860B
hook.py 1KB
noise.py 2KB
test_agedb.py 3KB
LICENSE 11KB
dataset
__init__.py 0B
agedb.py 3KB
casia_webface.py 3KB
requirements.txt 0B
figure
concept.png 4.37MB
demo.gif 5.93MB
train_student.py 10KB
model
__init__.py 0B
margin.py 1KB
backbone.py 6KB
requirements.txt 46B
.gitignore 2KB
README.md 8KB
train_teacher.py 7KB
evaluation
__init__.py 0B
eval_agedb.py 3KB
tinyface_helper.py 8KB
scripts
train_student.sh 691B
train_teacher.sh 628B
共 26 条
- 1
资源评论
sjx_alo
- 粉丝: 1w+
- 资源: 1221
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功