项目作者: haleuh

项目描述 :
ArcFace with MXNet Gluon
高级语言: Python
项目地址: git://github.com/haleuh/ArcFace-MXNet-Gluon.git
创建时间: 2019-08-19T21:32:47Z
项目社区:https://github.com/haleuh/ArcFace-MXNet-Gluon

开源协议:MIT License

下载


ArcFace-MXNet-Gluon

ArcFace with MXNet Gluon

Requirements

  • OpenCV 4.1
  • scikit-image 1.15
  • Dlib 19.17
  • Tensorflow 1.14
  • MXNet 1.5

    Installation

    MMOD Face Detection

    1. mkdir -p shared/MMOD
    2. # Download the dlib face detection model
    3. wget http://dlib.net/files/mmod_human_face_detector.dat.bz2 -P shared/MMOD
    4. # Unpack it
    5. bzip2 -d shared/MMOD/mmod_human_face_detector.dat.bz2

    PRNet Landmark Detection

  1. Download the pre-trained model shared by the PRNet authors
    at GoogleDrive
  2. Copy it to shared/PRNet/net-data

Data Preparation

Training Data

Deep Glint Dataset

http://trillionpairs.deepglint.com/data

  • The Deep Glint dataset is a combination of MS-Celeb-1M-v1c and Asian-Celeb datasets.
    It contains around 6.75M images of 180,855 subjects.

    |# Images |# Detected Faces|# IDs |
    |:———-:|:———————:|:——-:|
    |6,753,545| 6,749,639 |180,855|

  • Download two files train_msra.tar.gz (125GB) and train_celebrity.tar.gz (91GB)
    and unpack both of them to a directory, e.g., /mnt/Datasets/Glint/images

  • Pre-processing
    1. # Create a list of images
    2. python data/dir2lst.py -i /mnt/Datasets/Glint/images -o /mnt/Datasets/Glint/glint.lst
    3. # Run MMOD face detection
    4. python MMOD/face_detector.py -p 8 -d /mnt/Datasets/Glint/images -i /mnt/Datasets/Glint/glint.lst
    5. # Run PRNet landmark detection
    6. python PRNet/landmark_detector.py -d /mnt/Datasets/Glint/images -i /mnt/Datasets/Glint/glint_dlib.lst
    7. # Run face2rec to create a record file for mxnet
    8. python data/face2rec.py /mnt/Datasets/Glint/glint_dlib_prnet /mnt/Datasets/Glint/images --pack-label --num-thread 8
  • Visualize the record
    1. python data/show_record.py --shuffle -i /mnt/Datasets/Glint/glint_dlib_prnet.rec
    glint sample data

    Testing Data

    LFW

    http://vis-www.cs.umass.edu/lfw

  • LFW is the most popular face dataset for uncontrolled face verification,
    which contains 13,233 face images of 5,748 subjects collected from the Internet.
    LFW was published in 2007 and has been a standard benchmark in face recognition for a decade.
    The LFW verification protocol provides 6,000 pairs of images split into ten folds.

    |# Images|# Detected Faces|# IDs|
    |:———:|:———————:|:—-:|
    | 13,233 | 13,232 |5,748|

  • Download the lfw.tgz
    and pairs.txt files
    and unpack it to a directory, e.g., /mnt/Datasets/lfw/images

  • Pre-processing
    1. # Create a list of images
    2. python data/dir2lst.py -i /mnt/Datasets/lfw/images -o /mnt/Datasets/lfw/lfw.lst
    3. # Run MMOD face detection
    4. python MMOD/face_detector.py -p 8 -d /mnt/Datasets/lfw/images -i /mnt/Datasets/lfw/lfw.lst
    5. # Run PRNet landmark detection
    6. python PRNet/landmark_detector.py -d /mnt/Datasets/lfw/images -i /mnt/Datasets/lfw/lfw_dlib.lst
    7. # Run face2rec to create a record file for mxnet
    8. python data/face2rec.py /mnt/Datasets/lfw/lfw_dlib_prnet /mnt/Datasets/lfw/images --pack-label --num-thread 8
    9. # Map the original pairs.txt to new indexes in the list file
    10. python data/lfw2indices.py -l lfw_dlib_prnet.lst -i /mnt/Datasets/lfw
  • Visualize the record
    1. python data/show_record.py --shuffle -i /mnt/Datasets/lfw/lfw_dlib_prnet.rec
    lfw sample data

Training

  • Training ArcFace with Glint dataset using 8 GPUs
    1. python ArcFace/train.py --gpus 0,1,2,3,4,5,6,7 --num_workers 28 --prefix arcface-glint-nocolor --num_classes 180855
    2. --train_rec /mnt/Datasets/Glint/glint_dlib_prnet.rec
    3. --test_rec /mnt/Datasets/lfw/lfw_dlib_prnet.rec
  • Export trained model (optional)
    1. python ArcFace/export.py
    2. --model shared/ArcFace/arcface-glint-nocolor-best-337551.params
    3. --output shared/ArcFace/arcface-glint-nocolor

    Testing

  • Testing ArcFace with LFW dataset
    1. python ArcFace/test.py --prefix arcface-glint-nocolor
    2. --model shared/ArcFace/arcface-glint-nocolor-symbol.json
    3. --test_rec /mnt/Datasets/lfw/lfw_dlib_prnet.rec

    Pretrained Models

  • Arcface-Glint

    | Test set | Accuracy |
    |:————:|:————:|
    | LFW | 99.85 ± 0.20 |

Discussion

LFW

  • Top 5 true positive pairs
    lfw true_positive_pairs
  • Top 5 true negative pairs
    lfw true_negative_pairs
  • Top 5 false positive pairs
    lfw false_positive_pairs
  • Top 5 false negative pairs
    lfw false_negative_pairs

    Licence

  • Our code is released under MIT License.

    Credits

    Many parts of our code is copied from:
  • PRNet
  • InsightFace