Code Monkey home page Code Monkey logo

human_emotion_recognition's Introduction

Human Emotion Recognition by a CNN (TensorFlow)

Introduction

In this project, the aim is to implement a CNN to achieve the task of human emotion recognition from facial images. The architecture of the implemented Neural Network is as follows:

Layer Kernel Activation Output Shape
Input - - 48x48x1
Conv2D 3x3x32 ReLU 46x46x32
BN - - 46x46x32
Conv2D 3x3x32 ReLU 44x44x32
BN - - 44x44x32
Conv2D 3x3x32 ReLU 42x42x32
BN - - 42x42x32
Conv2D 3x3x64 ReLU 40x40x64
BN - - 40x40x64
MaxPooling 2x2 ReLU 20x20x64
Conv2D 3x3x32 ReLU 18x18x64
BN - - 18x18x64
Conv2D 3x3x32 ReLU 16x16x64
BN - - 16x16x64
MaxPooling 2x2 ReLU 8x8x64
Conv2D 3x3x32 ReLU 6x6x128
BN - - 6x6x128
MaxPooling 2x2 ReLU 3x3x128
Conv2D 3x3x32 ReLU 1x1x128
Flatten - - 128
Dense - ReLU 7

Dataset: FER-2013

This dataset contains 35887 images and their corresponding labels. The images are in bytes, rather a conventional image file. Therefore, images are first read using the BytesIO method of the io library and then converted to an image using PIL. Then, they are turned into numpy arrays for easier manipulation and convenience.

There 7 classes in this dataset, each represented by a number (0-6): 0=Angry, 1=Disgust, 2=Fear, 3=Happy, 4=Sad, 5=Surprise, 6=Neutral.

All the data points are first split into 2 segments of training and test data, where test data contains 15% of the whole. Also, during the training (fitting) phase, 5% of the training data is considered as the validation data.

Installation

First, you'll need to clone this repository to your local drive via the following command:

$ git clone https://github.com/aylinghsr/Human_Emotion_Recognition.git
$ cd Human_Emotion_Recognition

Alternatively, if git package is not installed, you can download the zip file for this repository and then extract it.

Requirements

This project is written in Python3 and requires Pillow, IO, Numpy, Scikit-learn, and TensorFlow.

All the required libraries can be installed by running the following command:

$ pip install -r requirements.txt

If the command above results in an error, you can also try:

$ python -m pip install -r requirements.txt

Also, the code will download the dataset automaticly on your computer.

Results

The designed and implemented CNN gets trained on the training data on 15 epochs. After this, it achieves an accuracy of 0.9313 on the training data, 0.5773 on the validation data, and 0.5804 on the test data.

human_emotion_recognition's People

Contributors

aylinghsr avatar

Watchers

 avatar  avatar

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.