Giter Club home page Giter Club logo

emotion-gcn's Introduction

PWC

Emotion-GCN: Exploiting Emotional Dependencies with Graph Convolutional Networks for Facial Expression Recognition

model

This repository hosts the official PyTorch implementation of our paper "Exploiting Emotional Dependencies with Graph Convolutional Networks for Facial Expression Recognition" accepted at IEEE FG 2021.

Paper: https://arxiv.org/abs/2106.03487

Authored by: Panagiotis Antoniadis, Panagiotis Paraskevas Filntisis, Petros Maragos

Abstract

Over the past few years, deep learning methods have shown remarkable results in many face-related tasks including automatic facial expression recognition (FER) in-the-wild. Meanwhile, numerous models describing the human emotional states have been proposed by the psychology community. However, we have no clear evidence as to which representation is more appropriate and the majority of FER systems use either the categorical or the dimensional model of affect. Inspired by recent work in multi-label classification, this paper proposes a novel multi-task learning (MTL) framework that exploits the dependencies between these two models using a Graph Convolutional Network (GCN) to recognize facial expressions in-the-wild. Specifically, a shared feature representation is learned for both discrete and continuous recognition in a MTL setting. Moreover, the facial expression classifiers and the valence-arousal regressors are learned through a GCN that explicitly captures the dependencies between them. To evaluate the performance of our method under real-world conditions we train our models on AffectNet dataset. The results of our experiments show that our method outperforms the current state-of-the-art methods on discrete FER.

Preparation

  • Download the dataset. [AffectNet] [Aff-Wild2]
  • Download the 300-dimensional GloVe vectors trained on the Wikipedia dataset from here.
  • Run pickle_annotations_affectnet.py and pickle_annotations_affwild2.py to generate data_affectnet.pkl and data_affwild2.pkl.

Training

  • Train Emotion-GCN on a FER dataset:
python main.py --help
usage: main.py [-h] [--image_dir IMAGE_DIR] [--data DATA] [--dataset {affectnet,affwild2}] [--network {densenet,bregnext}] [--adj ADJ]
               [--emb EMB] [--workers WORKERS] [--batch_size BATCH_SIZE] [--model {single_task,multi_task,emotion_gcn}] [--epochs EPOCHS]
               [--lambda_multi LAMBDA_MULTI] [--lr LR] [--momentum MOMENTUM] --gpu GPU --saved_model SAVED_MODEL

Train Facial Expression Recognition model using Emotion-GCN

optional arguments:
  -h, --help            show this help message and exit
  --image_dir IMAGE_DIR
                        path to images of the dataset
  --data DATA           path to the pickle file that holds all the information for each sample
  --dataset {affectnet,affwild2}
                        Dataset to use (default: affectnet)
  --network {densenet,bregnext}
                        Network to use (default: densenet)
  --adj ADJ             path to the pickle file that holds the adjacency matrix
  --emb EMB             path to the pickle file that holds the word embeddings
  --workers WORKERS     number of data loading workers (default: 4)
  --batch_size BATCH_SIZE
                        size of each batch (default: 35)
  --model {single_task,multi_task,emotion_gcn}
                        Model to use (default: emotion_gcn)
  --epochs EPOCHS       number of total epochs to train the network (default: 10)
  --lambda_multi LAMBDA_MULTI
                        lambda parameter of loss function
  --lr LR               learning rate (default: 0.001)
  --momentum MOMENTUM   momentum parameter of SGD (default: 0.9)
  --gpu GPU             id of gpu device to use
  --saved_model SAVED_MODEL
                        name of the saved model

Pre-trained Models

We also provide weights for our Emotion-GCN models on AffectNet and Aff-Wild2. Our best model achieves 66.46% accuracy on the categorical model of AffectNet outperforming the performance of the current state-of-the-art methods for discrete FER. You can download the pre-trained models here.

Citation

@inproceedings{9667014,
  author={Antoniadis, Panagiotis and Filntisis, Panagiotis Paraskevas and Maragos, Petros},
  booktitle={2021 16th IEEE International Conference on Automatic Face and Gesture Recognition (FG 2021)}, 
  title={Exploiting Emotional Dependencies with Graph Convolutional Networks for Facial Expression Recognition}, 
  year={2021},
  pages={1-8},
  doi={10.1109/FG52635.2021.9667014}}

Contact

For questions feel free to open an issue.

emotion-gcn's People

Contributors

panosantoniadis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

peterzs

emotion-gcn's Issues

dataloader.py errors when executing main.py

I recently tried to run the main.py script in VScode. However, after filling out the correct parser arguments I am receiving these errors.
If you could please provide some context as to what I need to do to resolve these errors, it would be greatly appreciated.

If more context is needed on the situation, I am happy to provide it.


Traceback (most recent call last):
File "main.py", line 292, in
main()
File "main.py", line 226, in main
train_dataloader, model, criterion_cat, optimizer)
File "C:\Users\upf962\Downloads\CREST_MECIS_19401\Folders_from_workstation\emotion-gcn\training.py", line 10, in train_model_single
for index, batch in enumerate(dataloader, 1):
File "C:\Python37\lib\site-packages\torch\utils\data\dataloader.py", line 628, in next
data = self._next_data()
File "C:\Python37\lib\site-packages\torch\utils\data\dataloader.py", line 1333, in _next_data
return self._process_data(data)
File "C:\Python37\lib\site-packages\torch\utils\data\dataloader.py", line 1359, in _process_data
data.reraise()
File "C:\Python37\lib\site-packages\torch_utils.py", line 543, in reraise
raise exception
TypeError: Caught TypeError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "C:\Python37\lib\site-packages\torch\utils\data_utils\worker.py", line 302, in _worker_loop
data = fetcher.fetch(index)
File "C:\Python37\lib\site-packages\torch\utils\data_utils\fetch.py", line 58, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "C:\Python37\lib\site-packages\torch\utils\data_utils\fetch.py", line 58, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "C:\Users\upf962\Downloads\CREST_MECIS_19401\Folders_from_workstation\emotion-gcn\dataloading.py", line 74, in getitem
image = self.transform(image)
File "C:\Python37\lib\site-packages\torchvision\transforms\transforms.py", line 95, in call
img = t(img)
File "C:\Python37\lib\site-packages\torch\nn\modules\module.py", line 1190, in _call_impl
return forward_call(*input, **kwargs)
File "C:\Python37\lib\site-packages\torchvision\transforms\transforms.py", line 346, in forward
return F.resize(img, self.size, self.interpolation, self.max_size, self.antialias)
File "C:\Python37\lib\site-packages\torchvision\transforms\functional.py", line 462, in resize
_, image_height, image_width = get_dimensions(img)
File "C:\Python37\lib\site-packages\torchvision\transforms\functional.py", line 75, in get_dimensions
return F_pil.get_dimensions(img)
File "C:\Python37\lib\site-packages\torchvision\transforms\functional_pil.py", line 33, in get_dimensions
raise TypeError(f"Unexpected type {type(img)}")
TypeError: Unexpected type <class 'numpy.ndarray'>

test code

Hello! Could you please send me the test code if possible?Thank you very much!Best wishes!

pickle_annotations_affwild2.py

Running pickle_annotations_affwild2.py to generate the data_affwild2.pkl file encountered some problems during the process,
First, the paper said that a subset of the database training and evaluation model, the subset contains only the required classification and VA-annotated frames. Specifically, which part is referred to?
Second, in Code (pickle_annotations_affwild2.py), line 40 :videos_dir = args.videos_dir ,changed to the current data address, and invalid literal for int() with base 10 , such as attaching a file image .
or being able to ask you to send a copy of data_affwild2.pkl files?

01
02

The 'inp' in the net

  1. Does it mean that we can only use the pre-defined embedding for this network?
  2. I don't understand the purpose of 'inp = inp[0]' in Emotion_gcn module. When I try to predict only one image, a dismatch error raises. After I annotate this line, it seems work.

data problem

Hello! Thank you to your reply! Nowadays, I have a new problem. I couldn't understand the ‘data’ file. Could you explain it for me? And the ‘data_affectnet.pkl’ and ‘spearman_affectnet.pkl’ are so small. Are there any errors?Thanks for your reply!Best wishes!

load pre-trained model

Sorry for my lack of knowledge...

But, how can I load the model with the pre-trained weights?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.