Skip to content

Latest commit

 

History

History
66 lines (43 loc) · 2.54 KB

README.md

File metadata and controls

66 lines (43 loc) · 2.54 KB

Face Recognition pipeline in Java

A face recognition pipeline implementation to do face detection and face identification in Java.

Integrated pretrained third party models for face detection and embedding calculation using DJL.

Face identification implemented using cosine distance between calculated embeddings and target face.

Build

Commands to build the project:

git lfs install
git clone https://github.com/jmformenti/face-recognition-java.git
cd face-recognition-java
mvn package

A fatjar face-recognition-java-${VERSION}.jar will be placed in cli/target dir.

Quickstart

  1. Prepare data, one root directory with one subdirectory with images of each person (for example, see src/test/resources/images/train).

  2. Generate embeddings file.

    java -jar cli/target/face-recognition-java-${VERSION}.jar embed -p /path/to/root/images -e embeddings.dat
    
  3. Recognize faces in one image.

    java -jar cli/target/face-recognition-java-${VERSION}.jar predict -e embeddings.dat -p /path/to/image
    

    As a result a new image with detected faces will be created in the same path with suffix _result.jpg.

Release new version

mvn clean deploy -P release

Pretrained models

Two models are used:

Model Type References
PaddlePaddle (DJL,flavor=server) Face detection https://docs.djl.ai/jupyter/paddlepaddle/face_mask_detection_paddlepaddle.html
https://paddledetection.readthedocs.io/featured_model/FACE_DETECTION_en.html
20180402-114759 converted to TorchScript Face embeddings https://github.com/timesler/facenet-pytorch

Further work

Tasks to improve the performance:

  1. Apply face alignment before embeddings calculation.
  2. Use some classifier to pass from an embedding to the person label.

References

  1. Deep Java Library
  2. Q. Cao, L. Shen, W. Xie, O. M. Parkhi, A. Zisserman. VGGFace2: A dataset for recognising face across pose and age, International Conference on Automatic Face and Gesture Recognition, 2018.
  3. Jason Brownlee PhD, Machine Learning Mastery, How to Perform Face Recognition With VGGFace2 in Keras
  4. 5 Celebrity Faces Dataset used for testing.