All Projects → amineHorseman → Facial Expression Recognition Svm

amineHorseman / Facial Expression Recognition Svm

Licence: gpl-3.0
Training SVM classifier to recognize people expressions (emotions) on Fer2013 dataset

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Facial Expression Recognition Svm

Ailearning
AiLearning: 机器学习 - MachineLearning - ML、深度学习 - DeepLearning - DL、自然语言处理 NLP
Stars: ✭ 32,316 (+29278.18%)
Mutual labels:  scikit-learn, sklearn, svm
Profanity Check
A fast, robust Python library to check for offensive language in strings.
Stars: ✭ 354 (+221.82%)
Mutual labels:  scikit-learn, sklearn
Sklearn Evaluation
Machine learning model evaluation made easy: plots, tables, HTML reports, experiment tracking and Jupyter notebook analysis.
Stars: ✭ 294 (+167.27%)
Mutual labels:  scikit-learn, sklearn
Mnist Classification
Pytorch、Scikit-learn实现多种分类方法,包括逻辑回归(Logistic Regression)、多层感知机(MLP)、支持向量机(SVM)、K近邻(KNN)、CNN、RNN,极简代码适合新手小白入门,附英文实验报告(ACM模板)
Stars: ✭ 109 (-0.91%)
Mutual labels:  scikit-learn, svm
Breast-Cancer-Scikitlearn
simple tutorial on Machine Learning with Scikitlearn
Stars: ✭ 33 (-70%)
Mutual labels:  svm, sklearn
skippa
SciKIt-learn Pipeline in PAndas
Stars: ✭ 33 (-70%)
Mutual labels:  scikit-learn, sklearn
Hyperparameter hunter
Easy hyperparameter optimization and automatic result saving across machine learning algorithms and libraries
Stars: ✭ 648 (+489.09%)
Mutual labels:  scikit-learn, sklearn
MachineLearning
机器学习教程,本教程包含基于numpy、sklearn与tensorflow机器学习,也会包含利用spark、flink加快模型训练等用法。本着能够较全的引导读者入门机器学习。
Stars: ✭ 23 (-79.09%)
Mutual labels:  svm, sklearn
100 Days Of Ml Code
100 Days of ML Coding
Stars: ✭ 33,641 (+30482.73%)
Mutual labels:  scikit-learn, svm
Traingenerator
🧙 A web app to generate template code for machine learning
Stars: ✭ 948 (+761.82%)
Mutual labels:  scikit-learn, sklearn
Kaio-machine-learning-human-face-detection
Machine Learning project a case study focused on the interaction with digital characters, using a character called "Kaio", which, based on the automatic detection of facial expressions and classification of emotions, interacts with humans by classifying emotions and imitating expressions
Stars: ✭ 18 (-83.64%)
Mutual labels:  scikit-learn, sklearn
Mlatimperial2017
Materials for the course of machine learning at Imperial College organized by Yandex SDA
Stars: ✭ 71 (-35.45%)
Mutual labels:  scikit-learn, sklearn
scikit-learn
به فارسی، برای مشارکت scikit-learn
Stars: ✭ 19 (-82.73%)
Mutual labels:  scikit-learn, sklearn
python3-docker-devenv
Docker Start Guide with Python Development Environment
Stars: ✭ 13 (-88.18%)
Mutual labels:  scikit-learn, sklearn
sklearn-audio-classification
An in-depth analysis of audio classification on the RAVDESS dataset. Feature engineering, hyperparameter optimization, model evaluation, and cross-validation with a variety of ML techniques and MLP
Stars: ✭ 31 (-71.82%)
Mutual labels:  scikit-learn, sklearn
Hungabunga
HungaBunga: Brute-Force all sklearn models with all parameters using .fit .predict!
Stars: ✭ 614 (+458.18%)
Mutual labels:  scikit-learn, sklearn
regression-stock-prediction
Predicting Google’s stock price using regression
Stars: ✭ 54 (-50.91%)
Mutual labels:  svm, scikit-learn
playground
A Streamlit application to play with machine learning models directly from the browser
Stars: ✭ 48 (-56.36%)
Mutual labels:  scikit-learn, sklearn
Machinelearningstocks
Using python and scikit-learn to make stock predictions
Stars: ✭ 897 (+715.45%)
Mutual labels:  scikit-learn, sklearn
Sklearn Porter
Transpile trained scikit-learn estimators to C, Java, JavaScript and others.
Stars: ✭ 1,014 (+821.82%)
Mutual labels:  scikit-learn, sklearn

Facial expression recognition using SVM

Extract face landmarks using Dlib and train a multi-class SVM classifier to recognize facial expressions (emotions).

Motivation:

The task is to categorize people images based on the emotion shown by the facial expression. To train our model, we want to use Fer2013 datset that contains 30,000 images of expressions grouped in seven categories: Angry, Disgust, Fear, Happy, Sad, Surprise and Neutral. The problem is that Fer2013 images are not aligned and it's difficult to classify facial expressions from it. The state-of-art accuracy achieved in this dataset, as far as I know, is 75.2% (refer to: Christopher Pramerdorfer, Martin Kampel. "Facial Expression Recognition using Convolutional Neural Networks: State of the Art". arXiv:1612.02903v1, 2016), a Convolutional Neural Network was used during several hours on GPU to obtain these results. Lets try a much simpler (and faster) approach by extracting Face Landmarks + HOG features and feed them to a multi-class SVM classifier. The goal is to get a quick baseline for educational purpose, if you want to achieve better results please refer to Pramerdorfer's paper.

Classification Results :

Features 7 emotions 5 emotions
HoG features 29.0% 34.4%
Face landmarks 39.2% 46.9%
Face landmarks + HOG 48.2% 55.0%
Face landmarks + HOG on slinding window 50.5% 59.4%

As expected, the Deep Learning approaches achieve better results (compare results with Facial Expressions Recognition using CNN)

The SVM training time was about ~400 seconds on an i7 2.8Ghz CPU, for the last experiment (sliding window) the training time reached 2060 seconds.

For the experiments with 5 emotions, the following expressions was used: Angry, Happy, Sad, Surprise, Neutral.

The code was tested for python 2.7 and 3.6.

How to use

  1. Download Fer2013 dataset and the Face Landmarks model

  2. Unzip the downloaded files

    And put the files fer2013.csv and shape_predictor_68_face_landmarks.dat in the root folder of this package.

  3. Install dependencies

    pip install numpy
    pip install argparse
    pip install sklearn
    pip install scikit-image
    pip install pandas
    pip install hyperopt
    pip install dlib
    
  4. Convert the dataset to extract Face Landmarks and HOG Features

    python convert_fer2013_to_images_and_landmarks.py
    

    You can also use these optional arguments according to your needs: -j, --jpg (yes|no): save images as .jpg files (default=no) -l, --landmarks (yes|no): extract Dlib Face landmarks (default=yes) -ho, --hog (yes|no): extract HOG features (default=yes) -hw, --hog_windows (yes|no): extract HOG features using a sliding window (default=yes) -o, --onehot (yes|no): one hot encoding (default=no) -e, --expressions (list of numbers): choose the faciale expression you want to use: 0=Angry, 1=Disgust, 2=Fear, 3=Happy, 4=Sad, 5=Surprise, 6=Neutral (default=0,1,2,3,4,5,6)

    Example

    python convert_fer2013_to_images_and_landmarks.py --landmarks=yes --hog=no --how_windows=no --jpg=no --onehot=no --expressions=1,3,4
    
  5. Train the model

    python train.py --train=yes
    
  6. Evaluate the model

    If you have already a pretrained model

    python train.py --evaluate=yes
    
  7. Train and evaluate [instead of step 5 and 6]

    python train.py --train=yes --evaluate=yes 
    
  8. Customize the training parameters:

    Feel free to change the values of the parameters in the parameters.py file according to your needs.

  9. Find the best hyperparameters (using hyperopt):

    python optimize_parameters.py --max_evals=15
    

    The argument max_evals specifies the number of combinaisions hyperopt will try. After finding the best hyperparameters, you should change the corresponding values in parameters.py and retrain the model. N.B: the accuracies displayed during hyperoptimization are for validation_set only (not test_set)

Contributing

Some ideas for interessted contributors:

  • Add other features extraction techniques?
  • Predict expression from a .jpg|.png file?
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].