A Pytorch implementation of "Real-time Convolutional Neural Networks for Emotion and Gender Classification" (mini-Xception) Paper
$ pip3 install -r requirements.txt
Note that it can be run on lower versions of Pytorch so replace the versions with yours
Both opencv dnn & haar cascade are used for face detection, if you want to use haar cascade you can skip this part.
install dependencies
$ sudo apt-get install libjpeg-dev libpng-dev libtiff-dev
$ sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev
$ sudo apt-get install libv4l-dev libxvidcore-dev libx264-dev
$ sudo apt-get install libgtk-3-dev
$ sudo apt-get install libatlas-base-dev gfortran
Download & install opencv with contrib modules from source
wget -O opencv.zip https://github.com/opencv/opencv/archive/4.2.0.zip
wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/4.2.0.zip
unzip opencv.zip
unzip opencv_contrib-4.2.0.zip
mkdir -p build && cd build
cmake -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-4.2.0/modules ../opencv
cmake --build .
if you have any problems, refere to Install opencv with dnn from source
if you don't want to use dnn modules just setup opencv with regular way
sudo apt-get install python3-opencv
$ python3 camera_demo.py
# add '--haar' option if you want to use Haar cascade detector instead of dnn opencv face detector
$ python3 camera_demo.py --haar
# replace $PATH_TO_IMAGE with your relative(or global) path to the image
$ python3 camera_demo.py --image --path PATH_TO_IMAGE
$ python3 camera_demo.py --path PATH_TO_VIDEO
- Histogram Equalization for iliumination normalization
- Face Alignment using dlib landmarks
The data consists of 48x48 pixel grayscale images of faces. and their emotion shown in the facial expression in to one of seven categories (Angry, Disgust, Fear, Happy, Sad, Surprise, Neutral), The training set consists of 28,709 examples. The public test set consists of 3,589 examples.
- create a folder called "data/" in project root
- put the "fer2013.csv" in it
Visualize dataset examples with annotated landmarks & head pose
# add '--mode' option to determine the dataset to visualize
$ python3 visualization.py
Take a wide look on dataset examples using tensorboard
$ python3 visualization.py --tensorboard
$ tensorboard --logdir checkpoint/tensorboard
$ python3 test.py
$ python3 train.py
$ python3 train.py --evaluate
will show the confision matrix
├── model # model's implementation
├── data # data folder contains FER2013 dataset
├── train # train on FER2013 dataset
├── test # test on 1 example
├── face_detector # contain the code of face detection (dnn & haar-cascade)
├── face_alignment # contain the code of face alignment using dlib landmarks
Deep Learning on Facial Expressions Survey
ilimunation normalization (histogram / GCN / Local Norm)
Tensorflow Implementation
Inception (has some used blocks)
Xception
Pytorch GlobalAvgPooling