Facenet: how to inference an image?

Created on 2 Mar 2017  路  13Comments  路  Source: davidsandberg/facenet

new to face recognition. Now I just want to inference an image, but I do not know run which py script in this repository.
Looking forward to your reply.
Thank you in advance.

Most helpful comment

Hi @davidsandberg @RakshakTalwar

  • which script has the infer function that will identify the class of given input image?
  • I tried compare.py, it only outputs the distances between given input images. Does not identify the class (person name in this case)
  • even if I use batch_generate.py, I will eventually need to call infer function for classification.

All 13 comments

The script compare.py will calculate the embeddings for a few images and that is one way to run inference.

@IvyGongoogle you can try the batch_represent.py script that I recently contributed.

It's under the tmp/ directory

@davidsandberg @RakshakTalwar Thank you very much!

@RakshakTalwar @davidsandberg I am trying to do inference on set of images using your script to incorporate facenet into Deep Video Analytics. However it require pre-detected / cropped faces. I saw that there is an "align module" that uses MTCNN ported to tensorflow. Is it ready to use? And is there any test script demonstrating how to use it?
Thanks,

@AKSHAYUBHAT you would use the following script to detect and align using MTCNN, then you can run it through batch-represent

https://github.com/davidsandberg/facenet/blob/master/src/align/align_dataset_mtcnn.py

Now I use tf0.9, but it shows error:
Segmentation fault (core dumped)
it seems to be a hidden error.
Do I have to use tf1.0?

@davidsandberg @RakshakTalwar

@IvyGongoogle I was able to get it to work with tf0.12 as well, not sure if it'll work with 0.9

It works correctly with tf 1.0. One issue is that there is no way to set GPU memory percentage, I modified the script while incorporating. You can do something like this

        gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.15)
        sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options, log_device_placement=False))
        with sess.as_default():

Hi @davidsandberg @RakshakTalwar

  • which script has the infer function that will identify the class of given input image?
  • I tried compare.py, it only outputs the distances between given input images. Does not identify the class (person name in this case)
  • even if I use batch_generate.py, I will eventually need to call infer function for classification.

@davidsandberg @RakshakTalwar I also need the script as @pandearti said above.

I have added a script 'classifier.py' that can train a small classifier on the facenet features. There is also a wiki page showing how to use it. Hopefully that will help.

@davidsandberg thank you very much!

Was this page helpful?
0 / 5 - 0 ratings