Git Product home page Git Product logo

face_and_emotion_detection's Introduction

Installation

Requirements

  • Python 3.3+ or Python 2.7
  • macOS or Linux

Installation Options:

Installing on Mac or Linux

First, make sure you have dlib already installed with Python bindings:

Then, install this module from pypi using pip3 (or pip2 for Python 2):

pip3 install face_recognition

Alternatively, you can try this library with Docker, see this section.

If you are having trouble with installation, you can also try out a pre-configured VM.

Usage:

Complete pipeline for Face Detection, Face Recognition and Emotion Detection

Refer to the notebook /src/facial_detection_recog_emotion.ipynb

We have trained an emotion detection model and put its trained weights at /emotion_detector_models

Train your Emotion Detection Model

To train your own emotion detection model, Refer to the notebook /src/EmotionDetector_v2.ipynb

face_and_emotion_detection's People

Contributors

apekshapriya avatar priya-dwivedi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

face_and_emotion_detection's Issues

Need requirements.txt

I am trying Transfer Learning on the model you have created and it gives me error "WARNING:tensorflow:Error in loading the saved optimizer state. As a result, your model is starting with a freshly initialized optimizer". On finding out more about this error I found that it is due to different keras versions. so please upload the requirement.txt.

error cannot download face_recognition

MacBook-Pro:face_and_emotion_detection-master adpk$ sudo pip install face_recognition
Password:
Collecting face_recognition
Downloading https://files.pythonhosted.org/packages/3f/ed/ad9a28042f373d4633fc8b49109b623597d6f193d3bbbef7780a5ee8eef2/face_recognition-1.2.3-py2.py3-none-any.whl
Requirement already satisfied: numpy in /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from face_recognition) (1.17.0)
Collecting face-recognition-models>=0.3.0 (from face_recognition)
Downloading https://files.pythonhosted.org/packages/cf/3b/4fd8c534f6c0d1b80ce0973d01331525538045084c73c153ee6df20224cf/face_recognition_models-0.3.0.tar.gz (100.1MB)
|████████████████████████████████| 100.2MB 8.2MB/s
Collecting dlib>=19.7 (from face_recognition)
Downloading https://files.pythonhosted.org/packages/05/57/e8a8caa3c89a27f80bc78da39c423e2553f482a3705adc619176a3a24b36/dlib-19.17.0.tar.gz (3.4MB)
|████████████████████████████████| 3.4MB 1.4MB/s
Collecting Pillow (from face_recognition)
Downloading https://files.pythonhosted.org/packages/8f/f3/c6d351d7e582e4f2ef4343c9be1f0472cb249fb69695e68631e337f4b6e9/Pillow-6.1.0-cp37-cp37m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (3.8MB)
|████████████████████████████████| 3.9MB 17.8MB/s
Collecting Click>=6.0 (from face_recognition)
Downloading https://files.pythonhosted.org/packages/fa/37/45185cb5abbc30d7257104c434fe0b07e5a195a6847506c074527aa599ec/Click-7.0-py2.py3-none-any.whl (81kB)
|████████████████████████████████| 81kB 17.6MB/s
Building wheels for collected packages: face-recognition-models, dlib
Building wheel for face-recognition-models (setup.py) ... done
Created wheel for face-recognition-models: filename=face_recognition_models-0.3.0-py2.py3-none-any.whl size=100566174 sha256=90d897fd2c17c83528d2131fc65c650fbb6325faf9d0093676857dafc57cc7ff
Stored in directory: /Users/adpk/Library/Caches/pip/wheels/d2/99/18/59c6c8f01e39810415c0e63f5bede7d83dfb0ffc039865465f
Building wheel for dlib (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /opt/local/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-e0kf8tku/dlib/setup.py'"'"'; file='"'"'/private/tmp/pip-install-e0kf8tku/dlib/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d /private/tmp/pip-wheel-lksnh5qt --python-tag cp37
cwd: /private/tmp/pip-install-e0kf8tku/dlib/
Complete output (53 lines):
running bdist_wheel
running build
running build_py
package init file 'dlib/init.py' not found (or not a regular file)
running build_ext
Traceback (most recent call last):
File "/private/tmp/pip-install-e0kf8tku/dlib/setup.py", line 120, in get_cmake_version
out = subprocess.check_output(['cmake', '--version'])
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 395, in check_output
**kwargs).stdout
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 472, in run
with Popen(*popenargs, **kwargs) as process:
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 775, in init
restore_signals, start_new_session)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1522, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'cmake': 'cmake'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in
File "/private/tmp/pip-install-e0kf8tku/dlib/setup.py", line 261, in
'Topic :: Software Development',
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/init.py", line 145, in setup
return distutils.core.setup(attrs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/core.py", line 148, in setup
dist.run_commands()
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/wheel/bdist_wheel.py", line 192, in run
self.run_command('build')
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/private/tmp/pip-install-e0kf8tku/dlib/setup.py", line 129, in run
cmake_version = self.get_cmake_version()
File "/private/tmp/pip-install-e0kf8tku/dlib/setup.py", line 125, in get_cmake_version
"\n
*****************************************************************\n")
RuntimeError:


CMake must be installed to build the following extensions: dlib



ERROR: Failed building wheel for dlib
Running setup.py clean for dlib
Successfully built face-recognition-models
Failed to build dlib
Installing collected packages: face-recognition-models, dlib, Pillow, Click, face-recognition
Running setup.py install for dlib ... error
ERROR: Command errored out with exit status 1:
command: /opt/local/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-e0kf8tku/dlib/setup.py'"'"'; file='"'"'/private/tmp/pip-install-e0kf8tku/dlib/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /private/tmp/pip-record-ymice7br/install-record.txt --single-version-externally-managed --compile
cwd: /private/tmp/pip-install-e0kf8tku/dlib/
Complete output (55 lines):
running install
running build
running build_py
package init file 'dlib/init.py' not found (or not a regular file)
running build_ext
Traceback (most recent call last):
File "/private/tmp/pip-install-e0kf8tku/dlib/setup.py", line 120, in get_cmake_version
out = subprocess.check_output(['cmake', '--version'])
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 395, in check_output
**kwargs).stdout
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 472, in run
with Popen(*popenargs, **kwargs) as process:
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 775, in init
restore_signals, start_new_session)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1522, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'cmake': 'cmake'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/private/tmp/pip-install-e0kf8tku/dlib/setup.py", line 261, in <module>
    'Topic :: Software Development',
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/__init__.py", line 145, in setup
    return distutils.core.setup(**attrs)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/command/install.py", line 61, in run
    return orig.install.run(self)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/command/install.py", line 545, in run
    self.run_command('build')
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/command/build.py", line 135, in run
    self.run_command(cmd_name)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/private/tmp/pip-install-e0kf8tku/dlib/setup.py", line 129, in run
    cmake_version = self.get_cmake_version()
  File "/private/tmp/pip-install-e0kf8tku/dlib/setup.py", line 125, in get_cmake_version
    "\n*******************************************************************\n")
RuntimeError:
*******************************************************************
 CMake must be installed to build the following extensions: dlib
*******************************************************************

----------------------------------------

ERROR: Command errored out with exit status 1: /opt/local/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-e0kf8tku/dlib/setup.py'"'"'; file='"'"'/private/tmp/pip-install-e0kf8tku/dlib/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /private/tmp/pip-record-ymice7br/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

ValueError: Input 0 of layer "sequential_11" is incompatible with the layer: expected shape=(None, 48, 48, 1), found shape=(None, 1296, 3)

/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/func_graph.py in autograph_handler(*args, **kwargs)
1145 except Exception as e: # pylint:disable=broad-except
1146 if hasattr(e, "ag_error_metadata"):
-> 1147 raise e.ag_error_metadata.to_exception(e)
1148 else:
1149 raise

ValueError: in user code:

File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 1801, in predict_function  *
    return step_function(self, iterator)
File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 1790, in step_function  **
    outputs = model.distribute_strategy.run(run_step, args=(data,))
File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 1783, in run_step  **
    outputs = model.predict_step(data)
File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 1751, in predict_step
    return self(x, training=False)
File "/usr/local/lib/python3.7/dist-packages/keras/utils/traceback_utils.py", line 67, in error_handler
    raise e.with_traceback(filtered_tb) from None
File "/usr/local/lib/python3.7/dist-packages/keras/engine/input_spec.py", line 264, in assert_input_compatibility
    raise ValueError(f'Input {input_index} of layer "{layer_name}" is '

ValueError: Input 0 of layer "sequential_11" is incompatible with the layer: expected shape=(None, 48, 48, 1), found shape=(None, 1296, 3)

missing normalization before inference

Shouldn't we normalize image data before inference?
It seems in facial_detection_recog_emotion.ipynb In [23] we are feeding uin8 grayscale data into the network whereas the network was trained for float [0:1] normalized data.

Accuracy

What is the accuracy of the pretrained model?

Article

Hi dear Priya
At first, thank you for your very good program. Then, could you please tell me if you published any article for this code? I want to use of your program and article and for citation I need this.
Regards

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.