Skip to content

Leonard-Niu/Facial-Expression-Recognition

Repository files navigation

A Pytorch Implementation of FER(Facial-Expression-Recognition)

Introduction

This project aims to classify facial expression. Here I provide seven types of expression, including Angry Disgusted Fearful Happy Sad Surprised Neutral. With 250 epochs, this accuracy of baseline achieves 70.382%

Here is the trained model link: ———— Trained Model Link password:5nfw

  • Backbone ——VGG16
  • Dataset ——FER2013:

Dataset Link 240×240 Data(Train、Val、Test) password:5j3x Backbone

Highlight

  • In this project, face detection part is applied, which can definitely improve the test accuracy. More over, it can support the robust of the model, especially no face input image.
  • GPU and CPU all support. If no GPU, it's OK.
  • Dependencies fewer.
  • When testing, batch images input is supported in the demo.

Results Show

Result1 Result2

Requirement

Recommend to use Anaconda

  • Ubuntu16.04 (Windows also avaliable)
  • Python 3.6
  • Pytorch (latest version or old version are all fine)
  • torchvision
  • numpy
  • matplotlib
  • opencv(cv2)
  • pillow

Dataset Process

FER2013 includes 35887 pictures: 48 × 48 pixels, here using bilinear interpolation to resize the expression pictures to 240 × 240 pixels. The input of the net is 224 × 224, same as original VGG16.

Train

First, put the processed dataset in the folder "data", the data folder like following:

-- data
------- train
------------------ 0
---------------------------00000.jpg
---------------------------00005.jpg
...
------------------ 1
---------------------------00023.jpg
...
...
------------------ 6
---------------------------00061.jpg
...

------- val
------------------ 0
---------------------------00006.jpg
...
------------------ 1
---------------------------00043.jpg
...
...
------------------ 6
---------------------------00021.jpg
...

------- test
------------------ 0
---------------------------00008.jpg
...
------------------ 1
---------------------------00011.jpg
...
...
------------------ 6
---------------------------00022.jpg
...

0-6 represent 7 different expression: Angry Disgusted Fearful Happy Sad Surprised Neutral

Demo

Image Input

python demo_image.py

Running the demo, first need to type the image name, such as 1.jpg.

Put input images in input folder

Camera Detection

python demo_camera.py

Batch Image Input

python demo_image_batch.py

TODO

Find image process methods to improve the accuracy.

Apply RPN face detection to improve accuracy.

Issue and Suggestion

Any questions, open a new issue.

If helpful, please give me a star

Reference

About

A Pytorch Implementation of FER( facial expression recognition )

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages