Giter Club home page Giter Club logo

facenet-v2's Introduction

FaceNet

这是 FaceNet 的Keras实现 FaceNet: A Unified Embedding for Face Recognition and Clustering.

FaceNet 主要差别:

  1. 输入图片尺寸 139 -> 224。
  2. 训练数据集 CelebA -> VGGFACE2。
  3. 标定模型 Dlib -> MTCNN.

软件兼容性

  • Python 3.5
  • Tensorflow 1.6.0
  • Keras 2.2.0

数据集

VGGFACE2 是一个大型的人脸数据集,有9,000多个人物身份和330多万张人脸图像。

image

按照 说明 下载 VGGFACE2 数据集 vggface2_train.tar.gz 和 vggface2_test.tar.gz 放入 data 目录。

模型结构

image

工作流程

处理单个输入图像的工作流程如下:

  1. 人脸检测:使用 Dlib 中预先训练的模型检测面部。
  2. 人脸校准:使用 Dlib 的实时姿势估计与 OpenCV 的仿射变换来尝试使眼睛和下唇在每个图像上出现在相同位置。
  3. 卷积网络:使用深度神经网络把人脸图片映射为 128 维单位超球面上的一个点。

image 图片来源

性能评估

使用 Labeled Faces in the Wild (LFW) 数据集做性能评估:

  • 13233 人脸图片
  • 5749 人物身份
  • 1680 人有两张以上照片

准备数据

下载 LFW database 放在 data 目录下:

$ wget http://vis-www.cs.umass.edu/lfw/lfw-funneled.tgz
$ tar -xvf lfw-funneled.tgz
$ wget http://vis-www.cs.umass.edu/lfw/pairs.txt
$ wget http://vis-www.cs.umass.edu/lfw/people.txt

评估脚本

$ python lfw_eval.py

测得结果

准确度: 89.27 %.

如何使用

数据预处理

提取训练图像:

$ python pre-process.py

执行下面命令标定人脸:
```bash
$ python align/align_dataset_mtcnn.py data/train data/train_aligned --image_size 200 --margin 24
$ python align/align_dataset_mtcnn.py data/test data/test_aligned --image_size 200 --margin 24

训练

$ python train.py

要想可视化训练过程,执行下面命令:

$ tensorboard --logdir path_to_current_dir/logs

DEMO

$ python demo.py
正(P) 欧式距离 锚(A) 欧式距离 反(N)
image 0.3579 image 0.9037 image
1.2757 --- 1.0052 --- 1.0740
image 0.7775 image 0.7634 image
1.7359 --- 1.3784 --- 0.7606
image 0.3556 image 1.3154 image
1.1428 --- 0.9498 --- 0.7804
image 0.5836 image 1.8520 image
2.0298 --- 1.9031 --- 1.9189
image 0.3343 image 1.7794 image
1.3242 --- 1.5383 --- 0.6461
image 0.2490 image 1.0756 image
1.2015 --- 1.4692 --- 0.8207
image 0.3323 image 0.9058 image
1.1681 --- 1.1821 --- 0.5887
image 0.6769 image 0.8985 image
1.1974 --- 0.7921 --- 1.3920
image 0.3638 image 1.4623 image
0.8634 --- 0.8968 --- 0.5992
image 0.3681 image 1.3735 image

附录

样本数据

执行下面命令查看样本数据:

$ python data_generator.py
正(P) 锚(A) 反(N)
image image image
image image image
image image image
image image image
image image image
image image image
image image image
image image image
image image image
image image image

数据增强

执行下面命令查看数据增强效果:

$ python data_generator.py
之前 之后 之前 之后 之前 之后
image image image image image image
image image image image image image
image image image image image image
image image image image image image
image image image image image image
image image image image image image
image image image image image image
image image image image image image
image image image image image image
image image image image image image

facenet-v2's People

Contributors

foamliu avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.