This repository contains the code for our CS 486 class project, which aims to compare different CNN techniques for recognizing facial emotions.
Two types of CNNs were explored and compared:
- A simple CNN based on the architecture proposed in the paper Facial Emotion Recognition using Convolutional Neural Networks by Zeynab Rzayeva and Emin Alasgarov
- A ResNet based on the architecture proposed in the paper Facial Sentiment Classification Based on Resnet-18 Model by Yitao Zhou, Shun Nishide, Fuji Ren, and Xin Kang
- Preprocess FER-2013 and MSFDE datasets using histogram equalization, data augmentation, and face cropping/alignment (optional)
- Train various CNN models with different hyperparameters on FER-2013
- Train various ResNet models with different hyperparameters on FER-2013
- Finds optimal parameters through grid search in an optimal fashion
- Test CNN and ResNet models on FER-2013 test set and MSFDE
- We highly recommend running the provided notebooks in Google Colab, as the default environment provides all required libraries
- Download the FER-2013 dataset from https://www.kaggle.com/c/challenges-in-representation-learning-facial-expression-recognition-challenge/data
- (Optional) Request access to the MSFDE dataset and download once approved from http://www.psychophysiolab.com/msfde/terms.php
- Upload all notebooks and data to Google Drive, or modify the notebooks to access the data locally
- Run the preprocessing notebook to generate preprocessed data for the FER-2013 dataset. You may need to modify file load and save locations to fit your Google Drive layout
- Run the simple_cnn notebook to train a variety of CNN models on the FER-2013 dataset.
- The notebook will automatically find the best hyperparameters on the validation set and output the test set accuracy and prediction distribution as shown below.
- Run the resnet notebook to train a residual network model on the FER-2013 dataset.
- The notebook will automatically find the best hyperparameters on the validation set and output the test set accuracy and prediction distribution.
- Run the preprocess_msfde notebook to generate preprocessed data. You may need to modify file load and save locations to fit your Google Drive layout
- Ensure the Simple CNN model and Residual Network model have already been saved to your drive
- Run the MSFDE_evaluate notebook to generate predictions from the best simple CNN and Residual Network models on the MSFDE dataset. For each race, the notebook will output the accuracy and prediction distribution as shown below.