DAY 97-100 DAYS MLCODE: Emotion detection using Keras

My Tech World

DAY 97-100 DAYS MLCODE: Emotion detection using Keras

February 17, 2019 100-Days-Of-ML-Code blog 0

In the previous blog, we discussed HOG for classification, in this blog we’ll try to develop an Emotion detection in an image.

Kaggle has challege of Emotion detection. Let’s start by downloading the data from here, this data was related to Facial Expression Recognition Challenge of Kaggle.

!kaggle competitions download -c challenges-in-representation-learning-facial-expression-recognition-challenge

Following files downloaded :
adc.json example_submission.csv fer2013.tar.gz

Unzip the tar file fer2013.tar.gz to get the data fer2013.csv . As per challege, here is detail about data

The data consists of 48×48 pixel grayscale images of faces. The faces have been automatically registered so that the face is more or less centered 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 in to one of seven categories (0=Angry, 1=Disgust, 2=Fear, 3=Happy, 4=Sad, 5=Surprise, 6=Neutral).

Kaggle Challenge

Let’s summarize the data using Pandas .

import pandas as pd
df = pd.read_csv(‘fer2013/fer2013.csv’)
df.info()

Data Frame summary
Data Frame Summary

Let’s see that how many types of usage are there in the data set

df[“Usage”].value_counts()

Type of Usage
Type of Usage

Let’s review the image before training.

image = df[“pixels”][99] # 99th image
val = image.split(” “)
x_pixels = np.array(val, ‘float32’)
x_pixels /= 255
x_reshaped = x_pixels.reshape(48,48)
plt.imshow(x_reshaped, cmap= “gray”, interpolation=”nearest”)
plt.axis(“off”)

99th Image of the Training data
99th Image of the Training data

In this blog, we have explored the data, in the next blog we’ll complete the development. You can find the code here