Giter Club home page Giter Club logo

webcamemocognizer's Introduction

webCamEmocognizer

A cool emotion detector using your laptop/desktop webcam.

Data resource

The data for this work is taken from the kaggle competiotion: Challenges in Representation Learning: Facial Expression Recognition Challenge https://www.kaggle.com/c/challenges-in-representation-learning-facial-expression-recognition-challenge

The dataset provided in the competion consists of gray scale images which are 48 x 48 in dimension and the corresponding labels consisting of 7 emotions.

We are using a simple convolution neural network to classify the images.

Then, we are using opencv to extract 48 x 48 dimension images using the webcam and classifying them using our model.

Requirements

The code is written in python 2.7.9
Keras (1.2.1)
numpy
pandas
theano (0.8.2)
cv2 (1.0)

Data

The data consists of scaled images from the kaggle competion kept in the data folder and also the labels in .npy format.

Training and running the tool

To train using the data, use the script trainCNN.py
Firstly, create the image data scaled, run the script
python ./genScaledDat.py
check if the file Scaled.bin.npy is generated in the data folder.
Then run the following:
python ./trainCNN.py

to run the detection using the training models run:
python ./DetectEmotion.py

Sample

Let's see if it likes beer:

Todos

A lot

  1. Clean up the code
  2. Update Keras backend and use OpenCv 3.0
  3. If anyone wants to contribute, plase feel free to contact.

N.B.

This project was part of my Master's thesis, the thesis is also added in the documents folder.

References:

[1] Alex Krizhevsky, Ilya Sutskever, Geoffrey E. Hinton. ImageNet Classification with Deep Convolutional Neural Networks.
[2] Shima Alizadeh, Azar Fazel. Convolutional Neural Networks for Facial Expression Recognition.
[3] https://codeplasma.com/2012/12/03/getting-webcam-images-with-python-and-opencv-2-for-real-this-time/

webcamemocognizer's People

Contributors

deepinevil 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

webcamemocognizer's Issues

Unable to find the dataset

I am only seeing one file in that data folder that is the labels.npy.
Can you please share the dataset file as well which is having the images?

Missing File fer2013.csv

Hi!

I've been trying to work around with your awesome project but I am unable to generate scaled images because the fer2013.csv does not exist.
I tried downloading it from the kaggle website but because I am from India, I am unable to receive the confirmation sms required to validate the download.
Is it possible to get that file from somewhere else?

Thanks.

Failed to load the native TensorFlow runtime.

Using TensorFlow backend.
Traceback (most recent call last):
File "./trainCNN.py", line 4, in
from keras.datasets import mnist
File "/Users/shreevardhanshah/Library/Python/2.7/lib/python/site-packages/keras/init.py", line 3, in
from . import utils
File "/Users/shreevardhanshah/Library/Python/2.7/lib/python/site-packages/keras/utils/init.py", line 6, in
from . import conv_utils
File "/Users/shreevardhanshah/Library/Python/2.7/lib/python/site-packages/keras/utils/conv_utils.py", line 9, in
from .. import backend as K
File "/Users/shreevardhanshah/Library/Python/2.7/lib/python/site-packages/keras/backend/init.py", line 89, in
from .tensorflow_backend import *
File "/Users/shreevardhanshah/Library/Python/2.7/lib/python/site-packages/keras/backend/tensorflow_backend.py", line 5, in
import tensorflow as tf
File "/Users/shreevardhanshah/Library/Python/2.7/lib/python/site-packages/tensorflow/init.py", line 24, in
from tensorflow.python import *
File "/Users/shreevardhanshah/Library/Python/2.7/lib/python/site-packages/tensorflow/python/init.py", line 51, in
from tensorflow.python import pywrap_tensorflow
File "/Users/shreevardhanshah/Library/Python/2.7/lib/python/site-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/Users/shreevardhanshah/Library/Python/2.7/lib/python/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "/Users/shreevardhanshah/Library/Python/2.7/lib/python/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File "/Users/shreevardhanshah/Library/Python/2.7/lib/python/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: dlopen(/Users/shreevardhanshah/Library/Python/2.7/lib/python/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 10): Library not loaded: @rpath/libcublas.8.0.dylib
Referenced from: /Users/shreevardhanshah/Library/Python/2.7/lib/python/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so
Reason: image not found

Failed to load the native TensorFlow runtime.

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

IOError: [Errno 2] No such file or directory

Traceback (most recent call last):
File "./genScaledDat.py", line 15, in
np.save('WebcamFacialExpressionRecognizer/data/Scaled.bin.npy',data)
File "/Users/shreevardhanshah/Library/Python/2.7/lib/python/site-packages/numpy/lib/npyio.py", line 517, in save
fid = open(file, "wb")
IOError: [Errno 2] No such file or directory: 'WebcamFacialExpressionRecognizer/data/Scaled.bin.npy'

How to fix this?

error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'

Traceback (most recent call last):
File "./DetectEmotion.py", line 51, in
gray, detected_faces = detect_face(frame)
File "./DetectEmotion.py", line 29, in detect_face
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.error: OpenCV(4.1.0) /Users/travis/build/skvark/opencv-python/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'

problem while running genScaled.Dat .py file

while running genScaled.Dat.py file its throwing the following error:

Traceback (most recent call last):
File "C:\Users\Saquib\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\core\indexes\base.py", line 3078, in get_loc
return self._engine.get_loc(key)
File "pandas_libs\index.pyx", line 140, in pandas._libs.index.IndexEngine.get_loc
File "pandas_libs\index.pyx", line 162, in pandas._libs.index.IndexEngine.get_loc
File "pandas_libs\hashtable_class_helper.pxi", line 1492, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas_libs\hashtable_class_helper.pxi", line 1500, in pandas._libs.hashtable.PyObjectHashTable.get_item

KeyError: 'pixels'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File ".\genScaledDat.py", line 9, in
data = data['pixels']
File "C:\Users\Saquib\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\core\frame.py", line 2688, in getitem
return self._getitem_column(key)
File "C:\Users\Saquib\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\core\frame.py", line 2695, in _getitem_column
return self._get_item_cache(key)
File "C:\Users\Saquib\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\core\generic.py", line 2489, in _get_item_cache

values = self._data.get(item)

File "C:\Users\Saquib\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\core\internals.py", line 4115, in get
loc = self.items.get_loc(item)
File "C:\Users\Saquib\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\core\indexes\base.py", line 3080, in get_loc
return self._engine.get_loc(self._maybe_cast_indexer(key))
File "pandas_libs\index.pyx", line 140, in pandas._libs.index.IndexEngine.get_loc
File "pandas_libs\index.pyx", line 162, in pandas._libs.index.IndexEngine.get_loc
File "pandas_libs\hashtable_class_helper.pxi", line 1492, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas_libs\hashtable_class_helper.pxi", line 1500, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'pixels'

can you please help me as soon as you can?

genScaledDat.py error

genScaledDat.py error
Killed

python ./genScaledDat.py
->Killed

what is the problem???

Issue in labels.bin.npy file

Sir , there is an OSError - Can not interpret labels.bin.npy file

what kind of data is there in labels.bin.npy file

Updating for opencv3

Hi,

Thank you for providing the fer2013.csv file.

Another issue I'm running into is that the code uses opencv2 1.0 which has since been deprecated. I don't know whether it is too much to ask but could you update the code such that it runs with the version opencv-python 3.4.0?

Because I keep running into this issue

Traceback (most recent call last): File "./DetectEmotion.py", line 58, in <module> gray, detected_faces = detect_face(frame) File "./DetectEmotion.py", line 43, in detect_face flags=cv2.cv.CV_HAAR_FEATURE_MAX) AttributeError: 'module' object has no attribute 'cv'

Thanks.

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.