Real-time face recognition on custom images using Tensorflow Deep Learning




[ad_1]

Hello friends…

Today we are going to show you application of Facnet model for face recognition in image and video in real time.

Here we will train model with 6 classes of Bollywood actor and predict them.
First of all we executed data processing file for pre-process of image data. Here we used around 50 image for each class. We have trained only last layer of pre-trained model.

Here image prediction is with 98% of akshay kumar
Also person recognition is done on video.

This code is available code on GitHub.
https://github.com/AISangam/Facenet-Real-time-face-recognition-using-deep-learning-Tensorflow
And execution tutorial of execution steps is at link:
http://www.aisangam.com/blog/real-time-face-recognition-using-facenet/http://www.aisangam.com/blog/real-time-face-recognition-using-facenet/

Actually this code is made by david named as Facenet. I just used them and showing you how you will easily train your model with custom own image. This model is based on deep learning Tensorflow.
For each and every steps please follow our blog available on Aisangam blog and link is in below description section…

http://www.aisangam.com/blog/real-time-face-recognition-using-facenet/

for more Query/Help/Awareness visit at
http://www.aisangam.com/
or directly Mail us at
aisangamofficial@gmail.com

Thanks..

AI Sangam believes in providing quality service to the end user or clients. If you want any query or want to build AI Application, please email us at aisangamofficial@gmail.com. We will reflect you back. Our services are paid but we can provide free guidance or suggestions. For full fledged application you need to contact us at our email. Please donot forget to subscribe us.

Source


[ad_2]

Comment List

  • Al Sangam
    December 23, 2020

    I'm running this code on colab and getting following error:
    Traceback (most recent call last):
    File "identify_face_image.py", line 25, in <module>
    pnet, rnet, onet = detect_face.create_mtcnn(sess, npy)
    File "/content/drive/My Drive/AISangamFace/Facenet-Real-time-face-recognition-using-deep-learning-Tensorflow/detect_face.py", line 282, in create_mtcnn
    pnet = PNet({'data':data})
    File "/content/drive/My Drive/AISangamFace/Facenet-Real-time-face-recognition-using-deep-learning-Tensorflow/detect_face.py", line 73, in _init_
    self.setup()
    File "/content/drive/My Drive/AISangamFace/Facenet-Real-time-face-recognition-using-deep-learning-Tensorflow/detect_face.py", line 219, in setup
    .conv(3, 3, 10, 1, 1, padding='VALID', relu=False, name='conv1')
    File "/content/drive/My Drive/AISangamFace/Facenet-Real-time-face-recognition-using-deep-learning-Tensorflow/detect_face.py", line 51, in layer_decorated
    layer_output = op(self, layer_input, *args, **kwargs)
    File "/content/drive/My Drive/AISangamFace/Facenet-Real-time-face-recognition-using-deep-learning-Tensorflow/detect_face.py", line 147, in conv
    c_i = int(inp.get_shape()[-1])
    AttributeError: 'variable_scope' object has no attribute 'get_shape

    Thanks for help in advance

  • Al Sangam
    December 23, 2020

    ERROR:ModuleNotFoundError: No module named 'sklearn'

  • Al Sangam
    December 23, 2020

    hello, when i run the identify_face.py, it showing the issue AttributeError: 'SVC' object has no attribute 'probability'
    i dont know how to fix it thank you

  • Al Sangam
    December 23, 2020

    Great Tutorial. I have some questions:
    1. How much time it takes to train the model. In this video, this is not progress showing and at last you have written "ITS ALL DONE HERE" .
    I am trying to attempt this tutorial and need your valuable response.
    Cheers and Take Care

  • Al Sangam
    December 23, 2020

    Will preprocess.py inside the code there will be face alignment?

    Because I only see the cropped part.

  • Al Sangam
    December 23, 2020

    Great work! Thanks for sharing. Where can I adjust the value in the identify_face_video.py file so I can play the video at the original speed? I tried modifying the frame_interval value, but it didn't make any difference. Please help. Greatly appreciate.

  • Al Sangam
    December 23, 2020

    How can I delete DS Store label and add unknow recognition? Pls HELP!!

  • Al Sangam
    December 23, 2020

    illegal instruction (core dumped) is only display in my terminal so what i have to do now?

  • Al Sangam
    December 23, 2020

    I am trying to run your facenet code in linux but when train main is executed…I encounter this problem…please can u answer this asap!!!!

    shraveen@MyPC:~/My_Files/Project Work/FRS/Facenet-Real-time-face-recognition-using-deep-learning-Tensorflow-master$ python train_main.py
    Training Start
    2020-05-27 02:09:39.806753: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
    Classes: 14
    Images: 269
    Model filename: ./model/20170511-185253.pb
    Extracting features of images for model
    Traceback (most recent call last):
    File "train_main.py", line 12, in <module>
    get_file = obj.main_train()
    File "/home/shraveen/My_Files/Project Work/FRS/Facenet-Real-time-face-recognition-using-deep-learning-Tensorflow-master/classifier.py", line 43, in main_train
    images = facenet.load_data(paths_batch, False, False, image_size)
    File "/home/shraveen/My_Files/Project Work/FRS/Facenet-Real-time-face-recognition-using-deep-learning-Tensorflow-master/facenet.py", line 262, in load_data
    img = prewhiten(img)
    File "/home/shraveen/My_Files/Project Work/FRS/Facenet-Real-time-face-recognition-using-deep-learning-Tensorflow-master/facenet.py", line 225, in prewhiten
    mean = np.mean(x)
    File "/home/shraveen/.local/lib/python2.7/site-packages/numpy/core/fromnumeric.py", line 2885, in mean
    out=out, keepdims=keepdims)
    File "/home/shraveen/.local/lib/python2.7/site-packages/numpy/core/_methods.py", line 72, in _mean
    ret = ret / rcount
    TypeError: unsupported operand type(s) for /: 'instance' and 'int'

  • Al Sangam
    December 23, 2020

    can u tell me how many images are taken for training and testing in this program

  • Al Sangam
    December 23, 2020

    pnet, rnet, onet = detect_face.create_mtcnn(sess, './npy')
    ValueError: Object arrays cannot be loaded when allow_pickle=False

    kindly suggest me how to solve this?

  • Al Sangam
    December 23, 2020

    File "C:/Users/91849/Desktop/untitled1/data_preprocess.py", line 7, in <module>

    nrof_images_total,nrof_successfully_aligned=obj.collect_data

    TypeError: 'method' object is not iterable

    how to solve this??

  • Al Sangam
    December 23, 2020

    module 'scipy.misc' has no attribute 'imresize'

  • Al Sangam
    December 23, 2020

    I have error (AttributeError: module 'tensorflow' has no attribute 'GPU0ptions')?

  • Al Sangam
    December 23, 2020

    When i try to run the data_preprocess.py file, i get an error saying there is no module named 'scipy' , and when i looked at it on python IDE, it isn't anything like that…….

  • Al Sangam
    December 23, 2020

    Um…quick question if you look in the 50 seconds of the video in the top right corner, HE IS CASTING AT 1: 07 AM!!!!!

  • Al Sangam
    December 23, 2020

    Hi 👋🏼
    What a great work you done I really like it but can I ask about whats your classifier for face detection?

  • Al Sangam
    December 23, 2020

    Thank you for this video! Do you have any plans to implement one-shot learning and Siamese networks so that the model only needs one image per class for training and recognition?

  • Al Sangam
    December 23, 2020

    pls tell tensorflow version

  • Al Sangam
    December 23, 2020

    please tell me! How can I train My custom data set ?

  • Al Sangam
    December 23, 2020

    Hi,
    it has worked.But could you tell me how to run it on android device by creating a tflite file from my pickle file?
    Thanks

  • Al Sangam
    December 23, 2020

    Hi! i tried to execute the code, but i get the error "module 'tensorflow' has no attribute 'ConfigProto'". This error comes for all functions that use tf. I have tensorflow version 2 installed. Any idea what the issue is here? and how to resolve it?
    Are you using tensorflow for GPU? or CPU?

  • Al Sangam
    December 23, 2020

    it was awesome! i had fun watching it. how do you use it with camera?

  • Al Sangam
    December 23, 2020

    I tried to run in google colab, show me errors:
    Traceback (most recent call last):

    File "data_preprocess.py", line 7, in <module>

    nrof_images_total,nrof_successfully_aligned=obj.collect_data()

    File "/content/Facenet-Real-time-face-recognition-using-deep-learning-Tensorflow/preprocess.py", line 26, in collect_data

    pnet, rnet, onet = detect_face.create_mtcnn(sess, './npy')

    File "/content/Facenet-Real-time-face-recognition-using-deep-learning-Tensorflow/detect_face.py", line 283, in create_mtcnn

    pnet.load(os.path.join(model_path, 'det1.npy'), sess)

    File "/content/Facenet-Real-time-face-recognition-using-deep-learning-Tensorflow/detect_face.py", line 85, in load

    data_dict = np.load(data_path, encoding='latin1').item() #pylint: disable=no-member

    File "/usr/local/lib/python2.7/dist-packages/numpy/lib/npyio.py", line 447, in load

    pickle_kwargs=pickle_kwargs)

    File "/usr/local/lib/python2.7/dist-packages/numpy/lib/format.py", line 696, in read_array

    raise ValueError("Object arrays cannot be loaded when "

    ValueError: Object arrays cannot be loaded when allow_pickle=False

    do you have any idea?

  • Al Sangam
    December 23, 2020

    I used Anaconda to run my code I get this error "Collecting package metadata (current_repodata.json): …working… failed

    UnavailableInvalidChannel: The channel is not accessible or is invalid.
    channel name: conda-menpo
    channel url: https://conda.anaconda.org/conda-menpo
    error code: 404

    You will need to adjust your conda configuration to proceed.
    Use `conda config –show channels` to view your configuration's current state,
    and use `conda config –show-sources` to view config file locations.

    "

  • Al Sangam
    December 23, 2020

    Hi… Is it possible to increase the fps speed for the video for face detection? Can the detection video be of same speed as the original video?

  • Al Sangam
    December 23, 2020

    Hi, thank u for sharing this
    when i add new person. How can i update classifier.pkl (not replace file).
    please advise me.

  • Al Sangam
    December 23, 2020

    While running data preprocessor. Py I am getting tensorflow has no gpu options, how should I fix dz

  • Al Sangam
    December 23, 2020

    Can u please tell meTensor flow
    Open cv
    Scipy scikit learn versions n how to install them with links

  • Al Sangam
    December 23, 2020

    please help I am getting error —
    UnicodeDecodeError: 'ascii' codec can't decode byte 0x80 in position 316: ordinal not in range(128)

  • Al Sangam
    December 23, 2020

    Congratulations for this great work. for the test image 'abc.jpg', it predicts DS_store. To which class it's related ? Is it normal ? Thank you

  • Al Sangam
    December 23, 2020

    How to solve this error
    raise ValueError("Object arrays cannot be loaded when "
    ueError: Object arrays cannot be loaded when allow_pickle=False

  • Al Sangam
    December 23, 2020

    Thank you for the video. Could you please let me know how to deal with the unknown faces that are not used during training?

  • Al Sangam
    December 23, 2020

    Thanks for Video ! How can i train a new model (file in "model" folder ) ?

  • Al Sangam
    December 23, 2020

    Absolutely great I have tried it with 10 classes for images each having 50 images , then I tested with a video also. I got 80-95% accuracy. Thanks a lot for the code and tutorial 😍

  • Al Sangam
    December 23, 2020

    Hello AI Sangam can you please tell me how I can live fetch the video and test the data?

  • Al Sangam
    December 23, 2020

    ValueError: Object arrays cannot be loaded when allow_pickle=False

    while running the data_preprocess.py
    how can i fix this

  • Al Sangam
    December 23, 2020

    How can i Fix ??

    WARNING:tensorflow:From C:facenetdetect_face.py:213: div (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.

    Instructions for updating:

    Deprecated in favor of operator or tf.math.divide.

    C:/facenet/identify_face_image.py:100: DeprecationWarning: `imresize` is deprecated!

    `imresize` is deprecated in SciPy 1.0.0, and will be removed in 1.3.0.

    Use Pillow instead: “numpy.array(Image.fromarray(arr).resize())“.

    scaled.append(misc.imresize(cropped[i], (image_size, image_size), interp='bilinear'))

  • Al Sangam
    December 23, 2020

    I am Working on a project ( Attendance Using Face Recognition in class Room) … Could you please suggest me some algorithms to build a model with best accuracy in face detection and recognition…. Thank You In Advance

  • Al Sangam
    December 23, 2020

    how can detect unknown face for unknown person

  • Al Sangam
    December 23, 2020

    Hi, thank u for sharing this, I add file with my image for both pre and train image when I run python train_main.py I got this error 
    facenet.py", line 265, in load_data

        images[i,:,:,:] = img

    ValueError: could not broadcast input array from shape (160,160,4) into shape (160,160,3)

    What I can do? I change the size of image as possible but it still coming with this error.
    please advise me.

  • Al Sangam
    December 23, 2020

    can i use this method to train my emotion recognition model?

  • Al Sangam
    December 23, 2020

    How to find accuracy sir? This code only shows the result from probability distribution … But how to find actual accuracy?

  • Al Sangam
    December 23, 2020

    can we create an exe for this project ? If Yes, then how and for which file ?

  • Al Sangam
    December 23, 2020

    I can't access "execution tutorial of execution steps"

    Do you have "execution tutorial of execution steps"?

  • Al Sangam
    December 23, 2020

    Hey man sorry for bothering but when i run data_preprocess.py file i get these errors
    Traceback (most recent call last):
    File "data_preprocess.py", line 7, in <module>
    nrof_images_total,nrof_successfully_aligned=obj.collect_data()
    File "C:UsersuserDesktoptensorflowFacenet-Real-time-face-recognition-using-deep-learning-Tensorflowpreprocess.py", line 26, in collect_data
    pnet, rnet, onet = detect_face.create_mtcnn(sess, './npy')
    File "C:UsersuserDesktoptensorflowFacenet-Real-time-face-recognition-using-deep-learning-Tensorflowdetect_face.py", line 283, in create_mtcnn
    pnet.load(os.path.join(model_path, 'det1.npy'), sess)
    File "C:UsersuserDesktoptensorflowFacenet-Real-time-face-recognition-using-deep-learning-Tensorflowdetect_face.py", line 85, in load
    data_dict = np.load(data_path, encoding='latin1').item() #pylint: disable=no-member
    File "C:UsersuserAppDataLocalProgramsPythonPython37libsite-packagesnumpylibnpyio.py", line 447, in load
    pickle_kwargs=pickle_kwargs)
    File "C:UsersuserAppDataLocalProgramsPythonPython37libsite-packagesnumpylibformat.py", line 692, in read_array
    raise ValueError("Object arrays cannot be loaded when allow_pickle=False")
    ValueError: Object arrays cannot be loaded when allow_pickle=False

    Maybe i did something worng idk. Thanks in advance.

  • Al Sangam
    December 23, 2020

    Congratulations for this great work.

    I personally test the code and works like a charm.

    However, I was wondering how to use it on Android for a face recognition app.

    Any ideas, please?

    Thank you

Write a comment