Face Recognition

This introduction includes Face Datasets, Face Detection, Face Alignment, Face Landmark, Face Recognition and exercises.



Face Datasets

VGGFace

vgg_face_dataset.tar.gz
The VGG Face dataset is face identity recognition dataset that consists of 2,622 identities. It contains over 2.6 million images


VGGFace2

Paper: VGGFace2: A dataset for recognising faces across pose and age


CelebA

Large-scale CelebFaces Attributes dataset
Paper: Deep Learning Face Attributes in the Wild


LFW

Labeled Faces in the Wild Home (lfw.tgz)
Paper: Labeled Faces in the Wild: A Database for Studying Face Recognition in Unconstrained Environments

The LFW dataset contains 13,233 images of faces collected from the web. This dataset consists of the 5749 identities with 1680 people with two or more images. In the standard LFW evaluation protocol the verification accuracies are reported on 6000 face pairs.


Face Detection

MTCNN

Paper: Joint Face Detection and Alignment using Multi-task Cascaded Convolutional Networks
Code: ipazc/mtcnn
$pip install mtcnn


DeepFace

Code: RiweiChen/DeepFace
5 key points detection using DeepID architecture


Face Alignment

Face-Alignment

Code: 1adrianb/face-alignment

import face_alignment
from skimage import io

fa = face_alignment.FaceAlignment(face_alignment.LandmarksType._2D, flip_input=False)

input = io.imread('../test/assets/aflw-test.jpg')
preds = fa.get_landmarks(input)

OpenFace

Code: cmusatyalab/openface
Ref. Machine Learning is Fun! Part 4: Modern Face Recognition with Deep Learning


Face Landmark

Face Landmark Estimation

Paper: One Millisecond Face Alignment with an Ensemble of Regression Trees
The basic idea is we will come up with 68 specific points (called landmarks) that exist on every face


3D Face Reconstruction & Alignment

Paper: Joint 3D Face Reconstruction and Dense Alignment with Position Map Regression Network
Code: YadiraF/PRNet

3D Head Pose Estimation


EfficientFAN

Paper: EfficientFAN: Deep Knowledge Transfer for Face Alignment


Face Recognition

DeepID

Paper:DeepID3: Face Recognition with Very Deep Neural Networks
Code: hqli/face_recognition
Blog: DeepID人臉識別算法之三代
Ref. DeepID3 face recognition
DeepID3在LFW上的face verification準確率爲99.53%,性能上並沒有比DeepID2+的99.47%提升多少。而且LFW數據集裏面有三對人臉被錯誤地標記了,在更正這些錯誤的label後,兩者準確率均爲99.52%。


FaceNet

Paper: FaceNet: A Unified Embedding for Face Recognition and Clustering
Code: davidsandberg/facenet
   sainimohit23/FaceNet-Real-Time-face-recognition
   timesler/facenet-pytorch

Blog: 人臉辨識模型 Google Facenet 介紹與使用 使用不同的 network model 的辨識成績差異 MTCCN Face Tracking


Exercises

Facial Emotion Recognition (表情辨識)

Using MTCNN to detect face, then use CNN model to recognize emotion
Step 0. sync up Tensorflow version between Kaggle and PC
Step 1. Train a CNN model for facial expression recognition (FER2013 dataset)
Step 2. load CNN model to combine with MTCNN face detection

Step 0. To sync up Tensorflow version between Kaggle and PC

On Kaggle:
import tensorflow as tf
print(tf.__version__)
2.6.1

On PC:
$python -c 'import tensorflow as tf; print(tf.__version__)'
2.6.1

Make sure to use same version of Tensorflow on Kaggle and PC for model file compatibilty !

Step 1. Train Model on Kaggle

Kaggle: rkuo2000/fer2013-cnn
Dataset: FER-2013

  1. [Edit & Copy] FER2013-CNN
  2. [Run All] to Train model
  3. Download model file fer2013_cnn.h5

Step 2. Run Model on PC

  1. Clone sample codes
    $git clone https://github.com/rkuo2000/tf
  2. Copy fer2013_cnn.h5 to ~/tf/models
  3. To detect using image file
    $python mtcnn_emotion_detection.py images/facemask1.jpg
  4. To detect using webcam
    $python mtcnn_emotion_detection_cam.py

mtcnn_emotion_detection_cam.py


[Homework]: Facial Emotion Recognition


Face Mask Detection (口罩偵測)

Using MTCNN to detect face, then use CNN model to detect facemask

Step 0. sync up Tensorflow version between Kaggle and PC
Step 1. Train a CNN model for facemask detection
Step 2. load CNN model to combine with MTCNN face detection

Step 0. To sync up Tensorflow version between Kaggle and PC

On Kaggle:
import tensorflow as tf
print(tf.__version__)
2.6.1

On PC:
$python -c 'import tensorflow as tf; print(tf.__version__)'
2.6.1

Make sure to use same version of Tensorflow on Kaggle and PC for model file compatibilty !

Step 1. Train Model on Kaggle

Kaggle: rkuo2000/faskmask-cnn
Dataset: [Face Mask Detection ~12K Images Dataset](https://www.kaggle.com/ashishjangra27/face-mask-12k-images-dataset

  1. [Edit & Copy] FaceMask-CNN
  2. [Run All] to Train model
  3. Download model file facemask_cnn.h5

Step 2. Run Model on PC

  1. Clone sample codes
    $git clone https://github.com/rkuo2000/tf
  2. Copy facemask_cnn.h5 to ~/tf/models
  3. To detect using image file
    $python mtcnn_facemask_detection.py images/facemask1.jpg
  4. To detect using webcam
    $python mtcnn_facemask_detection_cam.py

mtcnn_facemask_detection_cam.py


[Homework]: Face Mask Detection


Face Identification (人臉辨識)

FaceNet-PyTorch

Kaggle: FaceNet-PyTorch

test_images

dists = [[(e1 - e2).norm().item() for e2 in embeddings] for e1 in test_embeddings]
for dist in dists:
    if any(e<1 for e in dist):
        print(names[np.argmin(dist)])
    else:
        print('unknown')


[Homework]: Face Identification

Github: facenet-pytorch
Kaggle: FaceNet-PyTorch

Steps:

  1. [Fork] https://github.com/rkuo2000/facenet-pytorch
  2. [Edit&Copy] https://kaggle.com/rkuo2000/facenet-pytorch
    • face detection : models/mtcnn.py
    • facenet model : models/inception_resnet_v1.py
    • example: examples/infer.ipynb
  3. upload 1.jpg for each name to https://github.com/your_name/facenet-pytoch data/test_images
  4. upload yourself photo 1.jpg to https://github.com/your_name/facenet-pytoch data/test_images/your_name
  5. Open https://kaggle.com/your_name/facenet-pytorch
  6. modify git clone path
    !git clone https://github.com/your_name/facenet-pytorch
  7. modify test image path
    img = plt.imread("facenet_pytorch/data/test_images/your_name/1.jpg")
  8. [Run-All]



This site was last updated December 22, 2022.