otaha178 / emotion-recognition Goto Github PK
View Code? Open in Web Editor NEWReal time emotion recognition
License: MIT License
Real time emotion recognition
License: MIT License
After downloading data-set, which command is used to train the model and what is the command to execute after training
Hello Omar Ayman,
I find this Project very interesting so I tried it. but when the model does not detect any face then line 53 thoughts error because the 'preds' is defined inside the if condition.
Thank You :-)
While running what is this command Demo -run real_time_video.py its wrong i think. Please give the correct one.
this is error i am getting.
Unable to open file (unable to open file: name = 'models/_mini_XCEPTION.102-0.66.hdf5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)
how to train this model so that it generates .hdf5
I encounter 2 problems when i test the demo file.
First, the version of openCV in the requirements text file doesn't exist, so i change the version :
opencv_python==4.2.0.32
Then, when i try to launch the demo, i have this error :
Using TensorFlow backend.
Traceback (most recent call last):
File "real_time_video.py", line 1, in
from keras.preprocessing.image import img_to_array
File "C:\Users\Lou Laurent\AppData\Local\Programs\Python\Python38-32\lib\site-packages\keras_init.py", line 3, in
from . import utils
File "C:\Users\Lou Laurent\AppData\Local\Programs\Python\Python38-32\lib\site-packages\keras\utils_init_.py", line 6, in
from . import conv_utils
File "C:\Users\Lou Laurent\AppData\Local\Programs\Python\Python38-32\lib\site-packages\keras\utils\conv_utils.py", line 9, in
from .. import backend as K
File "C:\Users\Lou Laurent\AppData\Local\Programs\Python\Python38-32\lib\site-packages\keras\backend_init_.py", line 1, in
from .load_backend import epsilon
File "C:\Users\Lou Laurent\AppData\Local\Programs\Python\Python38-32\lib\site-packages\keras\backend\load_backend.py", line 90, in
from .tensorflow_backend import *
File "C:\Users\Lou Laurent\AppData\Local\Programs\Python\Python38-32\lib\site-packages\keras\backend\tensorflow_backend.py", line 5, in
import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'_
Can you help me with this ?
Thanks,
Lou
Please add requirements.txt file so that I can run project with the packages you used. I believes it will reduce my errors.
Hi Omar,
Thanks for your work! Is it ok if i cite your project in my master-thesis? Do you maybe have written a paper about your findings or something?
Also, could you maybe elaborate how the prediction for the emotions work?
Best regards,
Matthias
When I am trying to train the model again and use the best model in the real_time_video.py it is not working then and only when I am using your model is it working ?
when i run 'real_time_video.py'
error as fllow:(what can i do)
Traceback (most recent call last):
File "C:/Users/Lenovo/PycharmProjects/Emotion-recognition/real_time_video.py", line 29, in
frame = imutils.resize(frame,width=300)
File "D:\anaconda\lib\site-packages\imutils\convenience.py", line 69, in resize
(h, w) = image.shape[:2]
AttributeError: 'NoneType' object has no attribute 'shape'
Using TensorFlow backend.
2018-10-31 19:07:29.243116: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2018-10-31 19:07:29.494922: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1411] Found device 0 with properties:
name: TITAN V major: 7 minor: 0 memoryClockRate(GHz): 1.455
pciBusID: 0000:01:00.0
totalMemory: 12.00GiB freeMemory: 9.67GiB
2018-10-31 19:07:29.502864: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1490] Adding visible gpu devices: 0
2018-10-31 19:07:30.692378: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] Device interconnect StreamExecutor with strength 1 edge matrix:
2018-10-31 19:07:30.696807: I tensorflow/core/common_runtime/gpu/gpu_device.cc:977] 0
2018-10-31 19:07:30.699723: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990] 0: N
2018-10-31 19:07:30.709265: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1103] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 9272 MB memory) -> physical GPU (device: 0, name: TITAN V, pci bus id: 0000:01:00.0, compute capability: 7.0)
Traceback (most recent call last):
File "real_time_video.py", line 53, in
for (i, (emotion, prob)) in enumerate(zip(EMOTIONS, preds)):
NameError: name 'preds' is not defined
Originally posted by @kevinjosue2326 in https://github.com/omar178/Emotion-recognition/issue_comments#issuecomment-434898420
I downloaded the project and installed all the requirements and ran the realtime demo python file.
The output is shown is the following. The web cam window is not opening.
OUTPUT:
runfile('C:/Users/Gautam/Emotion-recognition-master/real_time_video.py', wdir='C:/Users/Gautam/Emotion-recognition-master')
Using TensorFlow backend.
C:\Users\Gautam\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\framework\dtypes.py:523: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint8 = np.dtype([("qint8", np.int8, 1)])
C:\Users\Gautam\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\framework\dtypes.py:524: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])
C:\Users\Gautam\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\framework\dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint16 = np.dtype([("qint16", np.int16, 1)])
C:\Users\Gautam\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\framework\dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint16 = np.dtype([("quint16", np.uint16, 1)])
C:\Users\Gautam\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\framework\dtypes.py:527: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint32 = np.dtype([("qint32", np.int32, 1)])
C:\Users\Gautam\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\framework\dtypes.py:532: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
np_resource = np.dtype([("resource", np.ubyte, 1)])
runfile('C:/Users/Gautam/Emotion-recognition-master/train_emotion_classifier.py', wdir='C:/Users/Gautam/Emotion-recognition-master')
Using TensorFlow backend.
C:\Users\Gautam\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\framework\dtypes.py:523: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint8 = np.dtype([("qint8", np.int8, 1)])
C:\Users\Gautam\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\framework\dtypes.py:524: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])
C:\Users\Gautam\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\framework\dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint16 = np.dtype([("qint16", np.int16, 1)])
C:\Users\Gautam\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\framework\dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint16 = np.dtype([("quint16", np.uint16, 1)])
C:\Users\Gautam\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\framework\dtypes.py:527: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint32 = np.dtype([("qint32", np.int32, 1)])
C:\Users\Gautam\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\framework\dtypes.py:532: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
np_resource = np.dtype([("resource", np.ubyte, 1)])
What to do? Kindly suggest ways to run the project correctly. Thank you.
can someone provide me the dataset of this project ,so i can understand what type of data i need to create my own dataset
Please help to solve it~
First, thank you for sharing this resource.
Now, I want to use 'pyinstaller', and let the '.py' to '.exe'.
but, when I use command 'pyinstaller --onefile Run.ipyb'
cmd show 'line 5, in NameError:name 'null' is not defined'
Could u solve this problem? thank you, sir.
This line is giving attribute error: AttributeError: 'DataFrame' object has no attribute 'as_matrix'
cannot find the data set. cannot download it.please help
When I run the file 'facial_emotion_image.py' file on idle, I get the error 'img_path = sys.argv[1]
IndexError: list index out of range'. Any ideas on how to fix this? How should I run in terminal if thats the case?
Hi,
I'm new to OpenCV and computer vision. I'm grateful for your detailed instruction and I managed to run it with no sweat and pull up the real time webcam detector. However, how can I change the script to detect from the recorded video rather from the webcam?
Also, how can the result (probabilities of the emotions) be automatically recorded in the system?
Thank you very much.
kapil@Kapil:~/opencv/build/Emotion-recognition-master (1)$ python train_emotion_classifier.py
Using TensorFlow backend.
Traceback (most recent call last):
File "train_emotion_classifier.py", line 10, in
from models.cnn import mini_XCEPTION
ImportError: No module named models.cnn
Traceback (most recent call last):
File "c:/Users/hp/Desktop/ExpDetection/Code3/exp.py", line 29, in
frame = imutils.resize(frame,width=300)
File "C:\Python37\lib\site-packages\imutils\convenience.py", line 69, in resize
(h, w) = image.shape[:2]
AttributeError: 'tuple' object has no attribute 'shape'
[ WARN:0] terminating async callback
python3 real_time_video.py Using TensorFlow backend. /home/debian/.local/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:516: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint8 = np.dtype([("qint8", np.int8, 1)]) /home/debian/.local/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:517: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_quint8 = np.dtype([("quint8", np.uint8, 1)]) /home/debian/.local/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:518: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint16 = np.dtype([("qint16", np.int16, 1)]) /home/debian/.local/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:519: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_quint16 = np.dtype([("quint16", np.uint16, 1)]) /home/debian/.local/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:520: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint32 = np.dtype([("qint32", np.int32, 1)]) /home/debian/.local/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. np_resource = np.dtype([("resource", np.ubyte, 1)]) /home/debian/.local/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:541: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint8 = np.dtype([("qint8", np.int8, 1)]) /home/debian/.local/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:542: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_quint8 = np.dtype([("quint8", np.uint8, 1)]) /home/debian/.local/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:543: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint16 = np.dtype([("qint16", np.int16, 1)]) /home/debian/.local/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:544: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_quint16 = np.dtype([("quint16", np.uint16, 1)]) /home/debian/.local/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:545: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint32 = np.dtype([("qint32", np.int32, 1)]) /home/debian/.local/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:550: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. np_resource = np.dtype([("resource", np.ubyte, 1)]) Traceback (most recent call last): File "real_time_video.py", line 14, in <module> emotion_classifier = load_model(emotion_model_path, compile=False) File "/home/debian/.local/lib/python3.7/site-packages/keras/engine/saving.py", line 492, in load_wrapper return load_function(*args, **kwargs) File "/home/debian/.local/lib/python3.7/site-packages/keras/engine/saving.py", line 584, in load_model model = _deserialize_model(h5dict, custom_objects, compile) File "/home/debian/.local/lib/python3.7/site-packages/keras/engine/saving.py", line 273, in _deserialize_model model_config = json.loads(model_config.decode('utf-8')) AttributeError: 'str' object has no attribute 'decode'
please help to solve it
Traceback (most recent call last):
File "real_time_video.py", line 1, in
from keras.preprocessing.image import img_to_array
ImportError: No module named keras.preprocessing.image
What is the minimum spec to run this?
I am running this without Tensorflow-GPU, and it's basically stalling to the crawl. Does this only work for those with NVIDIA-CUDA setup?
def preprocess_input(x, v2=True):
# scale the raw pixel intensities to the range [0, 1]
x = x.astype('float32')
x = x / 255.0
if v2:
x = x - 0.5
x = x * 2.0
return x
Thank you very much for your work, Looking forward to your reply
module 'tensorflow' has no attribute 'get_default_graph'
MacBook-Pro:Emotion-recognition-master adpk$ python real_time_video.py
Using TensorFlow backend.
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:516: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint8 = np.dtype([("qint8", np.int8, 1)])
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:517: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:518: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint16 = np.dtype([("qint16", np.int16, 1)])
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:519: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:520: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint32 = np.dtype([("qint32", np.int32, 1)])
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
np_resource = np.dtype([("resource", np.ubyte, 1)])
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:541: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint8 = np.dtype([("qint8", np.int8, 1)])
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:542: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:543: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint16 = np.dtype([("qint16", np.int16, 1)])
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:544: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:545: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint32 = np.dtype([("qint32", np.int32, 1)])
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:550: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
np_resource = np.dtype([("resource", np.ubyte, 1)])
Traceback (most recent call last):
File "real_time_video.py", line 2, in
import imutils
ModuleNotFoundError: No module named 'imutils'
132123
I'm not a webcam, but i can run IPWebcam in android. How run this program with IPWebcam?
I want to lessen the number of emotions. What will I have to do?
In keras version '2.2.4'
I am facing the below error while starting for training.
keras/utils/data_utils.py", line 626, in next_sample
return six.next(_SHARED_SEQUENCES[uid])
TypeError: 'tuple' object is not an iterator
changing "{val_acc:.2f}" to "{val_accuracy:.2f}" and it will work fine,
as no variable named "val_acc" is defined but what you are trying to get is accuracy value after each epoch, which is probably defined as "val_accuracy".
@Omar178
I have commited the code change for the train_emotion_classifier.py. I have tested, it is working fine.
Please find below the pull request:
only suggestion
If there is multiple faces , it is not displaying output for all faces , How can we use it for multiple faces ?
First, thank you for sharing this!
In your code, if no face shows in camera, it will stop recording and stucking.
How can I add a new column called "No face", if no face, it will show "No face:100%",
but, the camera won't stop and still record it.
Thank you.
I am getting this error.
OpenCV(3.4.1) Error: Assertion failed (!empty()) in cv::CascadeClassifier::detectMultiScale, file C:\Miniconda3\conda-bld\opencv-suite_1533128839831\work\modules\objdetect\src\cascadedetect.cpp, line 1698
Traceback (most recent call last):
File "real_time_video.py", line 31, in
faces = face_detection.detectMultiScale(gray,scaleFactor=1.1,minNeighbors=5,minSize=(30,30),flags=cv2.CASCADE_SCALE_IMAGE)
cv2.error: OpenCV(3.4.1) C:\Miniconda3\conda-bld\opencv-suite_1533128839831\work\modules\objdetect\src\cascadedetect.cpp:1698: error: (-215) !empty() in function cv::CascadeClassifier::detectMultiScale
is there any way to add speech recognition so that it will respond to our emotions if we speak .please help me or else is there any alternative way to record the audio file and check the input then it will speak with us
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.