GithubHelp home page GithubHelp logo

hulalazz / facial-emotion-recognition-gluon Goto Github PK

View Code? Open in Web Editor NEW

This project forked from talkai/facial-emotion-recognition-gluon

0.0 2.0 0.0 8.57 MB

Apache MXNet Gluon implementation for state of the art FER+ paper for Facial Emotion Recognition - https://arxiv.org/abs/1608.01041

License: MIT License

Python 16.78% Jupyter Notebook 83.22%

facial-emotion-recognition-gluon's Introduction

Facial Emotion Recognition with Apache MXNet GLUON and MXNet Model Server

This repo is an Apache MXNet GLUON implementation of state of the art FER+ paper by Barsoum et. al. for facial emotion recognition.

This repo consists of following resources:

  1. Scripts for data pre-processing as suggested in the paper.
  2. Notebook for model training with MXNet GLUON and exporting the trained model.
  3. Large scale productionization of the trained model using MXNet Model Server(MMS) - https://github.com/awslabs/mxnet-model-server

You can see final demo at - http://bit.ly/mxnet-fer Note: Please use firefox or safari browser. Chrome is not supported yet.

In this implementation, we use majority voting (MV) technique illustrated in the paper and achieve 81.25% validation accuracy.(paper achieves 83.85%)

Prerequisites / Installation

# Install MXNet

    pip install mxnet-mkl # for CPU machines
    pip install mxnet-cu92 # for GPU machines with CUDA 9.2
    
# Other Dependencies

    pip install Pillow # For image processing
    pip install graphviz # For MXNet network visualization
    pip install matplotlib # For plotting training graphs

# Install MXNet Model Server(MMS) and required dependencies for FER inference

    pip install mxnet-model-server
    pip install scikit-image
    pip install opencv-python

Please refer MXNet installation guide for more detailed installation instructions.

Model Training

Step 1 - Data preparation

  • Clone this repository
    git clone https://github.com/sandeep-krishnamurthy/facial-emotion-recognition-gluon
    cd facial-emotion-recognition-gluon

Note: You cannot download the dataset with wget. You have to register on Kaggle and download the dataset due to licencing issue.

  • Extract the tar file - fer2013.tar.gz
  • Copy fer2013.csv dataset to facial-emotion-recognition-gluon/data directory.
  • Generate FER+ train/test/validation dataset from downloaded FER data.
    # -d : path to "data" folder in this repository. It has folder for Train/Test/Validation data with corrected labels.
    # -fer : path to fer dataset that you have extracted.
    # -ferplus : path to fer2013new.csv file that comes with this repository in the data folder
    
    python utils/prepare_data.py -d ./data -fer ./data/fer2013.csv -ferplus ./data/fer2013new.csv

In this step, we read the raw FER data, correct the labels using FER+ labels, and save as png images.

  • Process the FER+ train/test/validation dataset
    # -d : path to data folder. This is where we have created data from the previous step.
    python utils/process_data.py -d ./data

In this step, we read the FER+ dataset (png images) we prepared in the previous step, apply the transformation suggested in the paper by Boursom et. al. (Crop, Flip, Rotate, Affine Transformation, Scale).

Processed training/test/validation data are saved as numpy binaries (*.npy). We use these processed data in the model training notebook.

Step 2 - Model Training and Saving

Open the notebook/Gluon_FERPlus.ipynb notebook and follow the instructions to build the VGG13 network suggested in the paper, train the model using the processed images.

In the notebook, we will also export the trained model as MXNet symbol and params files (MXNet's representation of the model).

Inference

TODO

Next Steps (TODOs)

Below are few areas of improvements and next steps. All contributions are welcome!

  • Hyper-parameter optimization - In this implementation, I have not optimized hyper-parameters (learning rate scheduler for SGD) for best possible result.
  • Implement multi-gpu version of model training. This script provides single GPU implementation only. Time per epoch on single GPU is around 1 minute => approx 50 minutes for full model training (Model converges at around 50th epoch)

Contributors

Citation / Credits

Resources

facial-emotion-recognition-gluon's People

Contributors

sandeep-krishnamurthy avatar saravsak avatar lupesko avatar

Watchers

Zhang JinXiong(张金雄) avatar paper2code - bot 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.