Git Product home page Git Product logo

emotion's Introduction

Emotion

This software recognizes human faces and their corresponding emotions from a video or webcam feed. Powered by OpenCV and Deep Learning.

Demo

Installation

Clone the repository:

git clone https://github.com/petercunha/Emotion.git
cd Emotion/

Install these dependencies with pip3 install <module name>

  • tensorflow
  • numpy
  • scipy
  • opencv-python
  • pillow
  • pandas
  • matplotlib
  • h5py
  • keras

Once the dependencies are installed, you can run the project. python3 emotions.py

To train new models for emotion classification

  • Download the fer2013.tar.gz file from here
  • Move the downloaded file to the datasets directory inside this repository.
  • Untar the file: tar -xzf fer2013.tar
  • Download train_emotion_classifier.py from orriaga's repo here
  • Run the train_emotion_classification.py file: python3 train_emotion_classifier.py

Deep Learning Model

The model used is from this research paper written by Octavio Arriaga, Paul G. Plöger, and Matias Valdenegro.

Model

Credit

  • Computer vision powered by OpenCV.
  • Neural network scaffolding powered by Keras with Tensorflow.
  • Convolutional Neural Network (CNN) deep learning architecture is from this research paper.
  • Pretrained Keras model and much of the OpenCV code provided by GitHub user oarriaga.

emotion's People

Contributors

petercunha 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

emotion's Issues

I got this warning

Error in loading the saved optimizer state. As a result, your model is starting with a freshly initialized optimizer.
warnings.warn('Error in loading the saved optimizer '

How to train on my custom data?

Please tell something about how to train the model on my custom data? This project is awesome, I really love it but it's useless unless we don't have ability to train it ourselves.

Have a question.

First, thank you to open this source.

Could you extract emotional percentage to show a graphic for analyzing your emotion during a period of time?

When using python3 it doesnt allow for cv2 to be imported

I try running python3 emotions.py but I get this error

Traceback (most recent call last):
File "emotions.py", line 1, in
import cv2
ModuleNotFoundError: No module named 'cv2'

It says that its only for python 2.7 so how do you run it using python 3?

Hello. Running the code gives this error. any insights?

Using TensorFlow backend.
Traceback (most recent call last):
File "emotions.py", line 3, in
from keras.models import load_model
File "/home/anon/.local/lib/python3.6/site-packages/keras/init.py", line 3, in
from . import utils
File "/home/anon/.local/lib/python3.6/site-packages/keras/utils/init.py", line 6, in
from . import conv_utils
File "/home/anon/.local/lib/python3.6/site-packages/keras/utils/conv_utils.py", line 9, in
from .. import backend as K
File "/home/anon/.local/lib/python3.6/site-packages/keras/backend/init.py", line 89, in
from .tensorflow_backend import *
File "/home/anon/.local/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 5, in
import tensorflow as tf
File "/home/anon/.local/lib/python3.6/site-packages/tensorflow/init.py", line 24, in
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/home/anon/.local/lib/python3.6/site-packages/tensorflow/python/init.py", line 88, in
from tensorflow.python import keras
File "/home/anon/.local/lib/python3.6/site-packages/tensorflow/python/keras/init.py", line 24, in
from tensorflow.python.keras import activations
File "/home/anon/.local/lib/python3.6/site-packages/tensorflow/python/keras/activations/init.py", line 22, in
from tensorflow.python.keras._impl.keras.activations import elu
File "/home/anon/.local/lib/python3.6/site-packages/tensorflow/python/keras/_impl/keras/init.py", line 21, in
from tensorflow.python.keras._impl.keras import activations
File "/home/anon/.local/lib/python3.6/site-packages/tensorflow/python/keras/_impl/keras/activations.py", line 23, in
from tensorflow.python.keras._impl.keras import backend as K
File "/home/anon/.local/lib/python3.6/site-packages/tensorflow/python/keras/_impl/keras/backend.py", line 36, in
from tensorflow.python.layers import base as tf_base_layers
File "/home/anon/.local/lib/python3.6/site-packages/tensorflow/python/layers/base.py", line 25, in
from tensorflow.python.keras.engine import base_layer
File "/home/anon/.local/lib/python3.6/site-packages/tensorflow/python/keras/engine/init.py", line 23, in
from tensorflow.python.keras.engine.base_layer import InputSpec
File "/home/anon/.local/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py", line 35, in
from tensorflow.python.keras import backend
File "/home/anon/.local/lib/python3.6/site-packages/tensorflow/python/keras/backend/init.py", line 22, in
from tensorflow.python.keras._impl.keras.backend import abs
ImportError: cannot import name 'abs'

models.cnn missing

Hey, thank you for sharing this with us.

I wanted to try doing the training myself but after I downloaded fer2013.tar and train_emotion_classifier.py, as i ran train_emotion_classifier.py, it said no models.cnn could be found.

Could you please tell me how can i fix this? P.s As i ran the emotion.py, everything went perfectly well.

ValueError("Tensor %s is not an element of this graph." % obj) on flask

when i run thin on flask.
i got this , anyone help me please?

Traceback (most recent call last):
File "C:\Users\kkhzz\Anaconda3\lib\site-packages\flask\app.py", line 1997, in call
return self.wsgi_app(environ, start_response)
File "C:\Users\kkhzz\Anaconda3\lib\site-packages\flask\app.py", line 1985, in wsgi_app
response = self.handle_exception(e)
File "C:\Users\kkhzz\Anaconda3\lib\site-packages\flask\app.py", line 1540, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\kkhzz\Anaconda3\lib\site-packages\flask_compat.py", line 33, in reraise
raise value
File "C:\Users\kkhzz\Anaconda3\lib\site-packages\flask\app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "C:\Users\kkhzz\Anaconda3\lib\site-packages\flask\app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\kkhzz\Anaconda3\lib\site-packages\flask\app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\kkhzz\Anaconda3\lib\site-packages\flask_compat.py", line 33, in reraise
raise value
File "C:\Users\kkhzz\Anaconda3\lib\site-packages\flask\app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\kkhzz\Anaconda3\lib\site-packages\flask\app.py", line 1598, in dispatch_request
return self.view_functionsrule.endpoint
File "D:\hancom\ims_front\flaskstart.py", line 122, in upload_image
return detect_faces_in_image(file)
File "D:\hancom\ims_front\flaskstart.py", line 169, in detect_faces_in_image
emotion_prediction = emotion_classifier.predict(gray_face)
File "C:\Users\kkhzz\Anaconda3\lib\site-packages\keras\engine\training.py", line 1164, in predict
self._make_predict_function()
File "C:\Users\kkhzz\Anaconda3\lib\site-packages\keras\engine\training.py", line 554, in _make_predict_function
**kwargs)
File "C:\Users\kkhzz\Anaconda3\lib\site-packages\keras\backend\tensorflow_backend.py", line 2744, in function
return Function(inputs, outputs, updates=updates, **kwargs)
File "C:\Users\kkhzz\Anaconda3\lib\site-packages\keras\backend\tensorflow_backend.py", line 2546, in init
with tf.control_dependencies(self.outputs):
File "C:\Users\kkhzz\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 5004, in control_dependencies
return get_default_graph().control_dependencies(control_inputs)
File "C:\Users\kkhzz\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 4543, in control_dependencies
c = self.as_graph_element(c)
File "C:\Users\kkhzz\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 3490, in as_graph_element
return self._as_graph_element_locked(obj, allow_tensor, allow_operation)
File "C:\Users\kkhzz\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 3569, in _as_graph_element_locked
raise ValueError("Tensor %s is not an element of this graph." % obj)

pip3 install

im new to visual studio and i dont know how to pip3 install there, i used to do it with anaconda and its prompt is it still the same or should i install i else where ??

Not able to load the model

UserWarning: Error in loading the saved optimizer state. As a result, your model is starting with a freshly initialized optimizer.
warnings.warn('Error in loading the saved optimizer '

What does apply_offsets do?

x1, x2, y1, y2 = apply_offsets(face_coordinates, emotion_offsets)

The line above applies a pre-defined offset to each detected face region before sending it through the emotion detector. When I was trying this out, it would often move the region off of the face and even cause the program to error out (and hit the try/catch). What is the reason why this is here? I'm not an expert in face detection by any means, but this seems wrong to me. Please correct me if I'm wrong.

VIDEOIO Error

Hi,

I am getting the following error when trying to run the project with the mentioned instructions.

(vpy3) inspiron:~/Documents/Emotion$ python3 emotions.py 
Using TensorFlow backend.
2018-10-29 20:02:17.572019: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
/home/inspiron/.virtualenvs/vpy3/lib/python3.6/site-packages/keras/engine/saving.py:327: UserWarning: Error in loading the saved optimizer state. As a result, your model is starting with a freshly initialized optimizer.
  warnings.warn('Error in loading the saved optimizer '
VIDEOIO ERROR: V4L2: Pixel format of incoming image is unsupported by OpenCV
Unable to stop the stream: Device or resource busy
VIDEOIO ERROR: V4L: can't open camera by index 0

Can you please suggest what may I change or do to make it work?

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.