Real time emotion recognition with Keras CNN and OpenCv. Keras is used to train the emotion classification model on face and OpenCv to make simple face detection using Haarcascade classifier.
Model has been trained using google colab : https://colab.research.google.com/, it's a cloud service which provides free GPU
- Keras
- Seaborn
- Sklearn
- OpenCv
Install dependencies :
pip install -r requirements.txt
Real time emotion recognition can be run from docker. First, build the image :
docker build -t emotion-recognition .
Add X11 authority :
xhost + local:docker
Run the project with pre-trained model :
docker run --privileged --device=/dev/video0 -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY emotion-recognition
To predict face emotion from webcam's frame:
python predict_webcam.py
To predict face emotion from local image
python predict_image.py -p path_to_image:
The model has been trained using fer2013 dataset which is composed of 35887 samples splited between 7 classes:
- Classe 0 : Angry 4593 images
- Classe 1 : Disgust 547 images
- Classe 2 : Fear 5121 images
- Classe 3 : Happy 6077 images
- Classe 4 : Sad 6077 images
- Classe 5 : Surprise 4002 images
- Classe 6 : Neutral 6198 images
All samples are 48x48 grayscale face images
- Accuracy :64,59 % on validation set