Skip to main content

Facial Expression Recognition using Residual Masking Network

(*) State-of-the-art Facial Expression Recognition / Emotion Detection.

Open In Colab PyPI Downloads pypi package circleci Python package style HF Paper HF Model

Installation

  1. Install from pip
pip install rmn
  1. Or build from source
git clone git@github.com:phamquiluan/ResidualMaskingNetwork.git
cd ResidualMaskingNetwork
pip install -e .

Quick Start

from rmn import RMN
import cv2

# Initialize the model
m = RMN()

# Detect emotions from an image
image = cv2.imread("your-image.png")
results = m.detect_emotion_for_single_frame(image)
print(results)

# Draw results on the image
image = m.draw(image, results)
cv2.imwrite("output.png", image)

Webcam Demo

from rmn import RMN
m = RMN()
m.video_demo()

Table of Contents

Benchmarking on FER2013

We benchmark our code thoroughly on two datasets: FER2013 and VEMO. Below are the results and trained weights:

Model Accuracy
VGG19 70.80
EfficientNet_b2b 70.80
Googlenet 71.97
Resnet34 72.42
Inception_v3 72.72
Bam_Resnet50 73.14
Densenet121 73.16
Resnet152 73.22
Cbam_Resnet50 73.39
ResMaskingNet 74.14
ResMaskingNet + 6 76.82

Results in VEMO dataset could be found in my thesis or slide (attached below)

Benchmarking on ImageNet

We also benchmark our model on ImageNet dataset.

Model Top-1 Accuracy Top-5 Accuracy
Resnet34 72.59 90.92
CBAM Resnet34 73.77 91.72
ResidualMaskingNetwork 74.16 91.91

Datasets

Training on FER2013

Open In Colab

To train the networks, you need to specify the model name and other hyperparameters in the config file (located at configs/*) then ensure it is loaded in main file, then run training procedure by simply run main file, for example:

python main_fer.py  # Example for fer2013_config.json file

The best checkpoints will chosen at term of best validation accuracy, located at saved/checkpoints. By default, it will train alexnet model, you can switch to another model by edit configs/fer2013_config.json file (to resnet18 or cbam_resnet50 or my network resmasking_dropout1.

Training on the Imagenet dataset

To perform training resnet34 on 4 V100 GPUs on a single machine:

python ./main_imagenet.py -a resnet34 --dist-url 'tcp://127.0.0.1:12345' --dist-backend 'nccl' --multiprocessing-distributed --world-size 1 --rank 0

Ensemble method

I used the no-weighted sum average ensemble method to fuse 7 different models together, to reproduce results, you need to do some steps:

  1. Download all needed trained weights and locate them on the ./saved/checkpoints/ directory. The link to download can be found in the Benchmarking section.
  2. Edit file gen_results and run it to generate result offline for each model.
  3. Run the gen_ensemble.py file to generate accuracy for example methods.

Dissertation and Slide

Citation

Pham Luan, The Huynh Vu, and Tuan Anh Tran. "Facial Expression Recognition using Residual Masking Network". In: Proc. ICPR. 2020.

@inproceedings{pham2021facial,
  title={Facial expression recognition using residual masking network},
  author={Pham, Luan and Vu, The Huynh and Tran, Tuan Anh},
  booktitle={2020 25th International Conference on Pattern Recognition (ICPR)},
  pages={4513--4519},
  year={2021},
  organization={IEEE}
}

Star History

Star History Chart

License

This project is licensed under the MIT License - see the LICENSE file for details.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rmn-3.3.0.tar.gz (82.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rmn-3.3.0-py3-none-any.whl (106.7 kB view details)

Uploaded Python 3

File details

Details for the file rmn-3.3.0.tar.gz.

File metadata

  • Download URL: rmn-3.3.0.tar.gz
  • Upload date:
  • Size: 82.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.20

File hashes

Hashes for rmn-3.3.0.tar.gz
Algorithm Hash digest
SHA256 af2051784347ab99346204e6cbe55f9a4f8657c5f79b5982a9e9cfd92d8fb939
MD5 b9bd57531ad62d8374ea07aee5a04969
BLAKE2b-256 e52df68e6ab4883806abeaf0623bfe5ab63bfde7b2ddaa4e512db75bd80a4589

See more details on using hashes here.

File details

Details for the file rmn-3.3.0-py3-none-any.whl.

File metadata

  • Download URL: rmn-3.3.0-py3-none-any.whl
  • Upload date:
  • Size: 106.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.20

File hashes

Hashes for rmn-3.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d3c8621a0f33fb90e33f9698817ddd05c46cda2122f2756b00dc68537d692ce4
MD5 b858ee8f73427cbe48ba140e1c5cd915
BLAKE2b-256 895a1193909d885938d1a05c1fe6ce171690533cd2664945f3f41f4e34ffee6c

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

3.3.0 This release

2 files

3.2.0

2 files

3.1.2

2 files

3.1.1

2 files

3.1.0

2 files

3.0.14

2 files

3.0.12

2 files

3.0.11

2 files

3.0.10

2 files

3.0.8

2 files

3.0.4

2 files

3.0.3

2 files

3.0.2

2 files

3.0.1

2 files

3.0.0

2 files

2.0.0

2 files

1.0.1

2 files

1.0.0

2 files

0.0.6

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page