Skip to content

Commit 51fc8cb

Browse files
committed
New model in test cases. Fixed test cases.
1 parent accd688 commit 51fc8cb

8 files changed

+283
-103
lines changed

README.md

+13-9
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,38 @@
44
[travis]: http://travis-ci.org/davidsandberg/facenet
55

66
This is a TensorFlow implementation of the face recognizer described in the paper
7-
["FaceNet: A Unified Embedding for Face Recognition and Clustering"](http://arxiv.org/abs/1503.03832). The project also uses ideas from the paper ["A Discriminative Feature Learning Approach for Deep Face Recognition"](http://ydwen.github.io/papers/WenECCV16.pdf) as well as the paper ["Deep Face Recognition"](http://www.robots.ox.ac.uk/~vgg/publications/2015/Parkhi15/parkhi15.pdf) from the [Visual Geometry Group](http://www.robots.ox.ac.uk/~vgg/) at Oxford.
7+
["FaceNet: A Unified Embedding for Face Recognition and Clustering"](http://arxiv.org/abs/1503.03832). The project also uses ideas from the paper ["Deep Face Recognition"](http://www.robots.ox.ac.uk/~vgg/publications/2015/Parkhi15/parkhi15.pdf) from the [Visual Geometry Group](http://www.robots.ox.ac.uk/~vgg/) at Oxford.
88

99
## Compatibility
10-
The code is tested using Tensorflow r1.2 under Ubuntu 14.04 with Python 2.7 and Python 3.5. The test cases can be found [here](https://github.com/davidsandberg/facenet/tree/master/test) and the results can be found [here](http://travis-ci.org/davidsandberg/facenet).
10+
The code is tested using Tensorflow r1.7 under Ubuntu 14.04 with Python 2.7 and Python 3.5. The test cases can be found [here](https://github.com/davidsandberg/facenet/tree/master/test) and the results can be found [here](http://travis-ci.org/davidsandberg/facenet).
1111

1212
## News
1313
| Date | Update |
1414
|----------|--------|
15+
| 2018-04-10 | Added new models trained on Casia-WebFace and VGGFace2 (see below). Note that the models uses fixed image standardization (see [wiki](Training-using-the-VGGFace2-dataset)). |
16+
| 2018-03-31 | Added a new, more flexible input pipeline as well as a bunch of minor updates. |
1517
| 2017-05-13 | Removed a bunch of older non-slim models. Moved the last bottleneck layer into the respective models. Corrected normalization of Center Loss. |
1618
| 2017-05-06 | Added code to [train a classifier on your own images](https://github.com/davidsandberg/facenet/wiki/Train-a-classifier-on-own-images). Renamed facenet_train.py to train_tripletloss.py and facenet_train_classifier.py to train_softmax.py. |
1719
| 2017-03-02 | Added pretrained models that generate 128-dimensional embeddings.|
1820
| 2017-02-22 | Updated to Tensorflow r1.0. Added Continuous Integration using Travis-CI.|
1921
| 2017-02-03 | Added models where only trainable variables has been stored in the checkpoint. These are therefore significantly smaller. |
2022
| 2017-01-27 | Added a model trained on a subset of the MS-Celeb-1M dataset. The LFW accuracy of this model is around 0.994. |
21-
| 2017‑01‑02 | Updated to code to run with Tensorflow r0.12. Not sure if it runs with older versions of Tensorflow though. |
23+
| 2017‑01‑02 | Updated to run with Tensorflow r0.12. Not sure if it runs with older versions of Tensorflow though. |
2224

2325
## Pre-trained models
2426
| Model name | LFW accuracy | Training dataset | Architecture |
2527
|-----------------|--------------|------------------|-------------|
26-
| [20170511-185253](https://drive.google.com/file/d/0B5MzpY9kBtDVOTVnU3NIaUdySFE) | 0.987 | CASIA-WebFace | [Inception ResNet v1](https://github.com/davidsandberg/facenet/blob/master/src/models/inception_resnet_v1.py) |
27-
| [20170512-110547](https://drive.google.com/file/d/0B5MzpY9kBtDVZ2RpVDYwWmxoSUk) | 0.992 | MS-Celeb-1M | [Inception ResNet v1](https://github.com/davidsandberg/facenet/blob/master/src/models/inception_resnet_v1.py) |
28+
| [20180408-102900](https://drive.google.com/open?id=1R77HmFADxe87GmoLwzfgMu_HY0IhcyBz) | 0.9905 | CASIA-WebFace | [Inception ResNet v1](https://github.com/davidsandberg/facenet/blob/master/src/models/inception_resnet_v1.py) |
29+
| [20180402-114759](https://drive.google.com/open?id=1EXPBSXwTaqrSC0OhUdXNmKSh9qJUQ55-) | 0.9965 | VGGFace2 | [Inception ResNet v1](https://github.com/davidsandberg/facenet/blob/master/src/models/inception_resnet_v1.py) |
30+
31+
NOTE: If you use any of the models, please do not forget to give proper credit to those providing the training dataset as well.
2832

2933
## Inspiration
3034
The code is heavily inspired by the [OpenFace](https://github.com/cmusatyalab/openface) implementation.
3135

3236
## Training data
3337
The [CASIA-WebFace](http://www.cbsr.ia.ac.cn/english/CASIA-WebFace-Database.html) dataset has been used for training. This training set consists of total of 453 453 images over 10 575 identities after face detection. Some performance improvement has been seen if the dataset has been filtered before training. Some more information about how this was done will come later.
34-
The best performing model has been trained on a subset of the [MS-Celeb-1M](https://www.microsoft.com/en-us/research/project/ms-celeb-1m-challenge-recognizing-one-million-celebrities-real-world/) dataset. This dataset is significantly larger but also contains significantly more label noise, and therefore it is crucial to apply dataset filtering on this dataset.
38+
The best performing model has been trained on the [VGGFace2](https://www.robots.ox.ac.uk/~vgg/data/vgg_face2/) dataset consisting of ~3.3M faces and ~9000 classes.
3539

3640
## Pre-processing
3741

@@ -41,11 +45,11 @@ To solve this, other face landmark detectors has been tested. One face landmark
4145
[Multi-task CNN](https://kpzhang93.github.io/MTCNN_face_detection_alignment/index.html). A Matlab/Caffe implementation can be found [here](https://github.com/kpzhang93/MTCNN_face_detection_alignment) and this has been used for face alignment with very good results. A Python/Tensorflow implementation of MTCNN can be found [here](https://github.com/davidsandberg/facenet/tree/master/src/align). This implementation does not give identical results to the Matlab/Caffe implementation but the performance is very similar.
4246

4347
## Running training
44-
Currently, the best results are achieved by training the model as a classifier with the addition of [Center loss](http://ydwen.github.io/papers/WenECCV16.pdf). Details on how to train a model as a classifier can be found on the page [Classifier training of Inception-ResNet-v1](https://github.com/davidsandberg/facenet/wiki/Classifier-training-of-inception-resnet-v1).
48+
Currently, the best results are achieved by training the model using softmax loss. Details on how to train a model using softmax loss on the CASIA-WebFace dataset can be found on the page [Classifier training of Inception-ResNet-v1](https://github.com/davidsandberg/facenet/wiki/Classifier-training-of-inception-resnet-v1) and .
4549

46-
## Pre-trained model
50+
## Pre-trained models
4751
### Inception-ResNet-v1 model
4852
A couple of pretrained models are provided. They are trained using softmax loss with the Inception-Resnet-v1 model. The datasets has been aligned using [MTCNN](https://github.com/davidsandberg/facenet/tree/master/src/align).
4953

5054
## Performance
51-
The accuracy on LFW for the model [20170512-110547](https://drive.google.com/file/d/0B5MzpY9kBtDVZ2RpVDYwWmxoSUk) is 0.992+-0.003. A description of how to run the test can be found on the page [Validate on LFW](https://github.com/davidsandberg/facenet/wiki/Validate-on-lfw).
55+
The accuracy on LFW for the model [20180402-114759](https://drive.google.com/open?id=1EXPBSXwTaqrSC0OhUdXNmKSh9qJUQ55-) is 0.99650+-0.00252. A description of how to run the test can be found on the page [Validate on LFW](https://github.com/davidsandberg/facenet/wiki/Validate-on-lfw). Note that the input images to the model need to be standardized using fixed image standardization (use the option `--use_fixed_image_standardization` when running e.g. `validate_on_lfw.py`).
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Learning rate schedule
22
# Maps an epoch number to a learning rate
3-
0: 0.1
4-
65: 0.01
5-
77: 0.001
6-
1000: 0.0001
3+
0: 0.05
4+
60: 0.005
5+
80: 0.0005
6+
91: -1

src/align/detect_face.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,9 @@ def fc(self, inp, num_out, name, relu=True):
207207
"""
208208
@layer
209209
def softmax(self, target, axis, name=None):
210-
max_axis = tf.reduce_max(target, axis, keepdims=True)
210+
max_axis = tf.reduce_max(target, axis, keep_dims=True)
211211
target_exp = tf.exp(target-max_axis)
212-
normalize = tf.reduce_sum(target_exp, axis, keepdims=True)
212+
normalize = tf.reduce_sum(target_exp, axis, keep_dims=True)
213213
softmax = tf.div(target_exp, normalize, name)
214214
return softmax
215215

src/compare.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import numpy as np
3232
import sys
3333
import os
34+
import copy
3435
import argparse
3536
import facenet
3637
import align.detect_face
@@ -88,7 +89,7 @@ def load_and_align_data(image_paths, image_size, margin, gpu_memory_fraction):
8889
with sess.as_default():
8990
pnet, rnet, onet = align.detect_face.create_mtcnn(sess, None)
9091

91-
tmp_image_paths = image_paths.copy()
92+
tmp_image_paths=copy.copy(image_paths)
9293
img_list = []
9394
for image in tmp_image_paths:
9495
img = misc.imread(os.path.expanduser(image), mode='RGB')

src/download_and_extract.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
'lfw-subset': '1B5BQUZuJO-paxdN8UclxeHAR1WnR_Tzi',
77
'20170131-234652': '0B5MzpY9kBtDVSGM0RmVET2EwVEk',
88
'20170216-091149': '0B5MzpY9kBtDVTGZjcWkzT3pldDA',
9-
'20170512-110547': '0B5MzpY9kBtDVZ2RpVDYwWmxoSUk'
9+
'20170512-110547': '0B5MzpY9kBtDVZ2RpVDYwWmxoSUk',
10+
'20180402-114759': '1EXPBSXwTaqrSC0OhUdXNmKSh9qJUQ55-'
1011
}
1112

1213
def download_and_extract_file(model_name, data_dir):

src/train_tripletloss.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
from tensorflow.python.ops import data_flow_ops
4343

44-
from six.moves import xrange
44+
from six.moves import xrange # @UnresolvedImport
4545

4646
def main(args):
4747

@@ -246,6 +246,7 @@ def train(args, sess, dataset, epoch, image_paths_placeholder, labels_placeholde
246246
emb_array = np.zeros((nrof_examples, embedding_size))
247247
loss_array = np.zeros((nrof_triplets,))
248248
summary = tf.Summary()
249+
step = 0
249250
while i < nrof_batches:
250251
start_time = time.time()
251252
batch_size = min(nrof_examples-i*args.batch_size, args.batch_size)

test/train_test.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ def setUpClass(self):
5656
create_mock_dataset(self.dataset_dir, 160)
5757
self.lfw_pairs_file = create_mock_lfw_pairs(self.tmp_dir)
5858
print(self.lfw_pairs_file)
59-
self.pretrained_model_name = '20170512-110547'
59+
self.pretrained_model_name = '20180402-114759'
6060
download_and_extract.download_and_extract_file(self.pretrained_model_name, 'data/')
6161
download_and_extract.download_and_extract_file('lfw-subset', 'data/')
62-
self.model_file = os.path.join('data', self.pretrained_model_name, 'model-%s.ckpt-250000' % self.pretrained_model_name)
62+
self.model_file = os.path.join('data', self.pretrained_model_name, 'model-%s.ckpt-275' % self.pretrained_model_name)
6363
self.pretrained_model = os.path.join('data', self.pretrained_model_name)
6464
self.frozen_graph_filename = os.path.join('data', self.pretrained_model_name+'.pb')
6565
print('Memory utilization (SetUpClass): %.3f MB' % memory_usage_psutil())
@@ -152,6 +152,7 @@ def test_finetune_tripletloss_inception_resnet_v1(self):
152152
'--data_dir', self.dataset_dir,
153153
'--model_def', 'models.inception_resnet_v1',
154154
'--pretrained_model', self.model_file,
155+
'--embedding_size', '512',
155156
'--epoch_size', '1',
156157
'--max_nrof_epochs', '1',
157158
'--batch_size', '6',

0 commit comments

Comments
 (0)