Making a FACE ID program with Tensor Flow in Python




[ad_1]

Hello Friends, its Ritesh! In this video, I’m gonna show you how you can build your own Face Recognition System for your PC or Laptop.
I’m using Tensor flow for Retraining the network on our faces and after that I’m using OpenCV for acquiring images on each subsequent run.

Code for this video:
https://github.com/MauryaRitesh/Face_ID

After that, just run the Label_Image program and see the output for yourself!
Hope you guys like this video and Thanks for watching.
Please SUBSCRIBE my Channel for staying tuned with further exciting PROGRAMMING videos.

Source


[ad_2]

Comment List

  • Ritesh Kumar Maurya
    December 3, 2020

    Does this Face ID program sucks???

  • Ritesh Kumar Maurya
    December 3, 2020

    everytime i update/change/add images i need to train again ?

  • Ritesh Kumar Maurya
    December 3, 2020

    Pls let me know what is the issue ? i'm having python 3.8.3 for tensorflow and opencv-python installed , created multiple images from split and when i try to train the model o receive an error

    PS C:NilayBigDatacodeFace_ID>

    python -m scripts.retrain –output_graph=tf_files/retrained_graph.pb –output_labels=tf_files/retrained_labels.txt

    –architecture=inception_v3 –image_dir=tf_files/images

    Traceback (most recent call last):

    File "C:UsersenilkhaAppDataLocalProgramsPythonPython38-32libsite-packagestensorflowpythonpywrap_tensorflow_internal.py", line 18, in swig_import_helper

    fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(__file__)])

    File "C:UsersenilkhaAppDataLocalProgramsPythonPython38-32libimp.py", line 296, in find_module

    raise ImportError(_ERR_MSG.format(name), name=name)

    ImportError: No module named '_pywrap_tensorflow_internal'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):

    File "C:UsersenilkhaAppDataLocalProgramsPythonPython38-32libsite-packagestensorflowpythonpywrap_tensorflow.py", line 58, in <module>

    from tensorflow.python.pywrap_tensorflow_internal import *

    File "C:UsersenilkhaAppDataLocalProgramsPythonPython38-32libsite-packagestensorflowpythonpywrap_tensorflow_internal.py", line 28, in <module>

    _pywrap_tensorflow_internal = swig_import_helper()

    File "C:UsersenilkhaAppDataLocalProgramsPythonPython38-32libsite-packagestensorflowpythonpywrap_tensorflow_internal.py", line 20, in swig_import_helper

    import _pywrap_tensorflow_internal

    ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):

    File "C:UsersenilkhaAppDataLocalProgramsPythonPython38-32librunpy.py", line 194, in _run_module_as_main

    return _run_code(code, main_globals, None,

    File "C:UsersenilkhaAppDataLocalProgramsPythonPython38-32librunpy.py", line 87, in _run_code

    exec(code, run_globals)

    File "C:NilayBigDatacodeFace_IDscriptsretrain.py", line 109, in <module>

    import tensorflow as tf

    File "C:UsersenilkhaAppDataLocalProgramsPythonPython38-32libsite-packagestensorflow__init__.py", line 24, in <module>

    from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import

    File "C:UsersenilkhaAppDataLocalProgramsPythonPython38-32libsite-packagestensorflowpython__init__.py", line 49, in <module>

    from tensorflow.python import pywrap_tensorflow

    File "C:UsersenilkhaAppDataLocalProgramsPythonPython38-32libsite-packagestensorflowpythonpywrap_tensorflow.py", line 74, in <module>

    raise ImportError(msg)

    ImportError: Traceback (most recent call last):

    File "C:UsersenilkhaAppDataLocalProgramsPythonPython38-32libsite-packagestensorflowpythonpywrap_tensorflow_internal.py", line 18, in swig_import_helper

    fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(__file__)])

    File "C:UsersenilkhaAppDataLocalProgramsPythonPython38-32libimp.py", line 296, in find_module

    raise ImportError(_ERR_MSG.format(name), name=name)

    ImportError: No module named '_pywrap_tensorflow_internal'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):

    File "C:UsersenilkhaAppDataLocalProgramsPythonPython38-32libsite-packagestensorflowpythonpywrap_tensorflow.py", line 58, in <module>

    from tensorflow.python.pywrap_tensorflow_internal import *

    File "C:UsersenilkhaAppDataLocalProgramsPythonPython38-32libsite-packagestensorflowpythonpywrap_tensorflow_internal.py", line 28, in <module>

    _pywrap_tensorflow_internal = swig_import_helper()

    File "C:UsersenilkhaAppDataLocalProgramsPythonPython38-32libsite-packagestensorflowpythonpywrap_tensorflow_internal.py", line 20, in swig_import_helper

    import _pywrap_tensorflow_internal

    ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'

    Failed to load the native TensorFlow runtime.

    See https://www.tensorflow.org/install/install_sources#common_installation_problems

    for some common reasons and solutions. Include the entire stack trace

    above this error message when asking for help.

    PS C:NilayBigDatacodeFace_ID>

  • Ritesh Kumar Maurya
    December 3, 2020

    tried but get >>> PS DIRcodeFace_ID> python -m .scriptsretrain.py –output_graph=tf_files/retrained_graph.pb –output_labels=tf_files/retrained_labels.txt –architecture=inception_v3 –image_dir=tf_files/images

    LOCALDIRPython38-32python.exe: Relative module names not supported

    or

    C:NilayBigDatacodeFace_ID> python -m scripts.retrain –output_graph=tf_files/retrained_graph.pb –output_labels=tf_files/retrained_labels.txt –architecture=inception_v3 –image_dir=tf_files/images

    Traceback (most recent call last):

    File "C:UsersenilkhaAppDataLocalProgramsPythonPython38-32librunpy.py", line 194, in _run_module_as_main

    return _run_code(code, main_globals, None,

    File "C:UsersenilkhaAppDataLocalProgramsPythonPython38-32librunpy.py", line 87, in _run_code

    exec(code, run_globals)

    File "C:NilayBigDatacodeFace_IDscriptsretrain.py", line 109, in <module>

    import tensorflow as tf

    File "C:UsersenilkhaAppDataLocalProgramsPythonPython38-32libsite-packagestensorflow__init__.py", line 24, in <module>

    from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import

    File "C:UsersenilkhaAppDataLocalProgramsPythonPython38-32libsite-packagestensorflowpython__init__.py", line 49, in <module>

    from tensorflow.python import pywrap_tensorflow

    File "C:UsersenilkhaAppDataLocalProgramsPythonPython38-32libsite-packagestensorflowpythonpywrap_tensorflow.py", line 58, in <module>

    from tensorflow.python.pywrap_tensorflow_internal import *

    File "C:UsersenilkhaAppDataLocalProgramsPythonPython38-32libsite-packagestensorflowpythonpywrap_tensorflow_internal.py", line 114

    def TFE_ContextOptionsSetAsync(arg1, async):

    def TFE_ContextOptionsSetAsync(arg1, async):

    ^

    SyntaxError: invalid syntax

  • Ritesh Kumar Maurya
    December 3, 2020

    i cant make the video change into pics files
    pls help

  • Ritesh Kumar Maurya
    December 3, 2020

    Hi Ritesh , great! this is for video based , how to do for image , if i pass particular image

  • Ritesh Kumar Maurya
    December 3, 2020

    well done! nice work

  • Ritesh Kumar Maurya
    December 3, 2020

    dear ritesh hindi mein bolna best hoga

  • Ritesh Kumar Maurya
    December 3, 2020

    C:UsersnikhiDesktopFace_ID>python -m scripts.retrain –output_graph=tf_files/retrained_graph.pb –output_labels=tf_files/retrained_labels.txt –architecture=inception_v3 –image_dir=tf_files/images

    getting the below error:

    C:UsersnikhiAnaconda3python.exe: No module named scripts.retrain

    for some reason the commands were not working from command prompt so had to go to Anaconda command prompt to execute

    Can you help on how to resolve this issue?

  • Ritesh Kumar Maurya
    December 3, 2020

    tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)

    AttributeError: module 'tensorflow' has no attribute 'app'

  • Ritesh Kumar Maurya
    December 3, 2020

    I love his accent…I am not being sarcastic

  • Ritesh Kumar Maurya
    December 3, 2020

    android phones be like: QUICK, TAKE NOTES, WE HAVE A NEW UPDATE >:)

  • Ritesh Kumar Maurya
    December 3, 2020

    bro, what version of TensorFlow do you use for this tutorial ?

    for 2.0 x there s so many problem

  • Ritesh Kumar Maurya
    December 3, 2020

    When I run the command to train the model, I get an error as 
    //anaconda3/bin/python: No module named scripts.retrain
    What should I do?

  • Ritesh Kumar Maurya
    December 3, 2020

    Nice job man, I learned a lot

    Thank you

  • Ritesh Kumar Maurya
    December 3, 2020

    F:project2Face_ID-mastertf_filesDeepika> python split.py

    python: can't open file 'split.py': [Errno 2] No such file or directory.

  • Ritesh Kumar Maurya
    December 3, 2020

    actually i was stucked while copying the link from git hub and its showing an error of git is not recognized as internal or external file what to do now…??

  • Ritesh Kumar Maurya
    December 3, 2020

    It gives me the following error.

    (face) C:UsersmanisDocumentsfaceFace_ID>python -m scripts.label_image

    [ WARN:0] terminating async callback

    2019-07-28 01:00:05.600064: W tensorflow/core/framework/op_def_util.cc:355] Op BatchNormWithGlobalNormalization is deprecated. It will cease to work in GraphDef version 9. Use tf.nn.batch_normalization().

    2019-07-28 01:00:05.816307: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2

    2019-07-28 01:00:06.341328: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1433] Found device 0 with properties:

    name: GeForce GTX 1050 major: 6 minor: 1 memoryClockRate(GHz): 1.493

    pciBusID: 0000:01:00.0

    totalMemory: 2.00GiB freeMemory: 1.61GiB

    2019-07-28 01:00:06.351951: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1512] Adding visible gpu devices: 0

    2019-07-28 01:00:07.019426: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] Device interconnect StreamExecutor with strength 1 edge matrix:

    2019-07-28 01:00:07.023882: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990] 0

    2019-07-28 01:00:07.026874: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1003] 0: N

    2019-07-28 01:00:07.031153: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 1349 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1050, pci bus id: 0000:01:00.0, compute capability: 6.1)

    2019-07-28 01:00:07.136713: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1512] Adding visible gpu devices: 0

    2019-07-28 01:00:07.140527: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] Device interconnect StreamExecutor with strength 1 edge matrix:

    2019-07-28 01:00:07.144833: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990] 0

    2019-07-28 01:00:07.148210: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1003] 0: N

    2019-07-28 01:00:07.150803: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 1349 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1050, pci bus id: 0000:01:00.0, compute capability: 6.1)

    2019-07-28 01:00:07.870686: I tensorflow/stream_executor/dso_loader.cc:152] successfully opened CUDA library cublas64_100.dll locally

    2019-07-28 01:00:09.616912: W tensorflow/core/common_runtime/bfc_allocator.cc:211] Allocator (GPU_0_bfc) ran out of memory trying to allocate 1.91GiB. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.

    7.88973e-05 not manish Here

    0.007889729749877006

    Not Recognised!

    the statements above "Not Recognised!" are
    print(i,labels[1],"Here")
    print(labels[1], results[1])
    can u help me out?

  • Ritesh Kumar Maurya
    December 3, 2020

    E0721 12:58:08.382324 11184 retrain.py:233] CRITICAL – Label notsaksham has no images in the category validation. ,what should i do

  • Ritesh Kumar Maurya
    December 3, 2020

    I did succesfully all the step by step, then at the last part this was the output, can u help us? 🙂
    PS C:UsersJoselDesktopFace_ID> python -m scripts.label_image
    [ WARN:0] terminating async callback

    WARNING: Logging before flag parsing goes to stderr.

    W0711 19:35:00.585547 1672 deprecation_wrapper.py:119] From C:UsersJoselDesktopFace_IDscriptslabel_image.py:16: The name tf.GraphDef is deprecated. Please use tf.compat.v1.GraphDef instead.

    Traceback (most recent call last):

    File "C:UsersJoselAppDataLocalProgramsPythonPython36librunpy.py", line 193, in _run_module_as_main

    "__main__", mod_spec)

    File "C:UsersJoselAppDataLocalProgramsPythonPython36librunpy.py", line 85, in _run_code

    exec(code, run_globals)

    File "C:UsersJoselDesktopFace_IDscriptslabel_image.py", line 110, in <module>

    graph = load_graph(model_file)

    File "C:UsersJoselDesktopFace_IDscriptslabel_image.py", line 18, in load_graph

    with open(model_file, "rb") as f:

    FileNotFoundError: [Errno 2] No such file or directory: 'tf_files/retrained_graph.pb'

    PS C:UsersJoselDesktopFace_ID>

  • Ritesh Kumar Maurya
    December 3, 2020

    in command prompt it is giving me git is not recongnized after pasting the github link
    please tell how it will work

  • Ritesh Kumar Maurya
    December 3, 2020

    Very helpful and informative video. bro keep it up! and please make some videos on how to use API's for face recognition. Thanx, a lot 🙂

  • Ritesh Kumar Maurya
    December 3, 2020

    Hi Ritesh,
    Worked my way through lots of errors, but can we do this for multiple faces? I tried making folders will diff faces and training them too, but it doesn't recognise them.

  • Ritesh Kumar Maurya
    December 3, 2020

    How to save current frame and save with time and date with name I mean create for reports example how many people are recognised

  • Ritesh Kumar Maurya
    December 3, 2020

    Hey Ritesh! Which Screen Recorder do you use?

  • Ritesh Kumar Maurya
    December 3, 2020

    Hi Ritesh, the entire program runs fine but it is not recognising the faces correctly…..so can u help me rectify this?

  • Ritesh Kumar Maurya
    December 3, 2020

    Thanks bro great content keep it up. Subscribed

  • Ritesh Kumar Maurya
    December 3, 2020

    I have an other question.
    Is there a possible way to print the recognised data on opencv putext?

  • Ritesh Kumar Maurya
    December 3, 2020

    Hello there i m running on ubuntu linux.
    On retrain it appears an error called : /usr/bin/python : no module named scripts
    What is this ?

  • Ritesh Kumar Maurya
    December 3, 2020

    There is no split.py in your repo.?

  • Ritesh Kumar Maurya
    December 3, 2020

    Bhai, AAP hindi me bhi post kar sakte hain na..

  • Ritesh Kumar Maurya
    December 3, 2020

    My code is running till the last test line (python -m scripts.label_image). It takes the photo and the command prompt just keeps blinking without any error or anything. We placed the models in tf_files properly and even changed the location in the code label_image(32nd line). Please help at the earliest. Thank You!!

  • Ritesh Kumar Maurya
    December 3, 2020

    What about a report I mean how many time grab your face and with time and stuff??

  • Ritesh Kumar Maurya
    December 3, 2020

    please i am in emergency:
    can you please create a helmet detection cascade file for me please.
    i request you, your help could be fulfill my life. please.

  • Ritesh Kumar Maurya
    December 3, 2020

    Excellent,keep it up

  • Ritesh Kumar Maurya
    December 3, 2020

    ERROR:tensorflow:Image directory 'tf_files/images' not found. I am getting this error

  • Ritesh Kumar Maurya
    December 3, 2020

    hi can i have ur email id? I'd like to know more about this, thanks.

  • Ritesh Kumar Maurya
    December 3, 2020

    hi ritesh, when im trying to use split.py, i get this error:
    warning: Error opening file (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:856)

    warning: video.mp4 (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:857)

    Read a new frame: False
    why? and what shd i do to solve this?

  • Ritesh Kumar Maurya
    December 3, 2020

    Hi. I try to run the training script … I get a HUGE traceback error… Here is the last few lines of the error…. any ideas what the issue is…????

    InvalidArgumentError (see above for traceback): Expected image (JPEG, PNG, or GIF), got empty file

    [[Node: DecodeJpeg_1 = DecodeJpeg[acceptable_fraction=1, channels=3, dct_method="", fancy_upscaling=true, ratio=1, try_recover_truncated=false, _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_DecodeJPGInput_0_0)]]

    )

    I also get this when i run the label_image script:

    2018-11-13 10:43:19.203702: W T:srcgithubtensorflowtensorflowcoreframeworkop_def_util.cc:346] Op BatchNormWithGlobalNormalization is deprecated. It will cease to work in GraphDef version 9. Use tf.nn.batch_normalization().

    2018-11-13 10:43:19.580697: I T:srcgithubtensorflowtensorflowcoreplatformcpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2

    Not Recognised!

Write a comment