An Emotion Recognition system recognises human emotions such as happy, sad, angry, surprised etc from their face using Deep Learning.
- Face Detection
- Emotion Recognition Model
- Deployment
The Human Face is detected from the frame using HaarCascade Classifier. It is an Object Detection Algorithm used to identify faces in an image or a real time video. The algorithm uses edge or line detection features proposed by Viola and Jones in their research paper “Rapid Object Detection using a Boosted Cascade of Simple Features” published in 2001. The algorithm is given a lot of positive images consisting of faces, and a lot of negative images not consisting of any face to train on them. The model created from this training is available at the OpenCV GitHub repository https://github.com/opencv/opencv/tree/master/data/haarcascades. The repository has the models stored in XML files, and can be read with the OpenCV methods. These include models for face detection, eye detection, upper body and lower body detection, license plate detection etc.
Emotions are recognised from the detected face by the emotion recognition deep learning model. The model uses Convolutional Neural Networks.
FER Dataset is used to train the model. The data consists of 48x48 pixel grayscale images of faces. The faces have been automatically registered so that the face is more or less centred and occupies about the same amount of space in each image.
The task is to categorize each face based on the emotion shown in the facial expression into one of seven categories (0=Angry, 1=Disgust, 2=Fear, 3=Happy, 4=Sad, 5=Surprise, 6=Neutral). The training set consists of 28,709 examples and the public test set consists of 3,589 examples.
Model: "sequential"
conv2d (Conv2D) (None, 48, 48, 64) 640
batch_normalization (BatchNo (None, 48, 48, 64) 256
activation (Activation) (None, 48, 48, 64) 0
max_pooling2d (MaxPooling2D) (None, 24, 24, 64) 0
dropout (Dropout) (None, 24, 24, 64) 0
conv2d_1 (Conv2D) (None, 24, 24, 128) 204928
batch_normalization_1 (Batch (None, 24, 24, 128) 512
activation_1 (Activation) (None, 24, 24, 128) 0
max_pooling2d_1 (MaxPooling2 (None, 12, 12, 128) 0
dropout_1 (Dropout) (None, 12, 12, 128) 0
conv2d_2 (Conv2D) (None, 12, 12, 512) 590336
batch_normalization_2 (Batch (None, 12, 12, 512) 2048
activation_2 (Activation) (None, 12, 12, 512) 0
max_pooling2d_2 (MaxPooling2 (None, 6, 6, 512) 0
dropout_2 (Dropout) (None, 6, 6, 512) 0
conv2d_3 (Conv2D) (None, 6, 6, 512) 2359808
batch_normalization_3 (Batch (None, 6, 6, 512) 2048
activation_3 (Activation) (None, 6, 6, 512) 0
max_pooling2d_3 (MaxPooling2 (None, 3, 3, 512) 0
dropout_3 (Dropout) (None, 3, 3, 512) 0
flatten (Flatten) (None, 4608) 0
dense (Dense) (None, 256) 1179904
batch_normalization_4 (Batch (None, 256) 1024
activation_4 (Activation) (None, 256) 0
dropout_4 (Dropout) (None, 256) 0
dense_1 (Dense) (None, 512) 131584
batch_normalization_5 (Batch (None, 512) 2048
activation_5 (Activation) (None, 512) 0
dropout_5 (Dropout) (None, 512) 0
dense_2 (Dense) (None, 7) 3591
Flask: Flask is a micro web framework written in Python. It is classified as a microframework because it does not require particular tools or libraries. It has no database abstraction layer, form validation, or any other components where pre-existing third-party libraries provide common functions.
What is an API?
If you’ve heard the term API before, chances are it’s been used not to refer to APIs in general, but instead to a specific kind of API, the web API. A web API allows for information or functionality to be manipulated by other programs via the internet. For example, with Twitter’s web API, you can write a program in a language like Python or Javascript that can perform tasks such as favoriting tweets or collecting tweet metadata.
In programming more generally, the term API, short for Application Programming Interface, refers to a part of a computer program designed to be used or manipulated by another program, as opposed to an interface designed to be used or manipulated by a human. Computer programs frequently need to communicate amongst themselves or with the underlying operating system, and APIs are one way they do it. In this tutorial, however, we’ll be using the term API to refer specifically to web APIs.