Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fer va estimation #264

Merged
merged 147 commits into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from 146 commits
Commits
Show all changes
147 commits
Select commit Hold shift + click to select a range
24423e5
facial_va_estimation added
negarhdr Jun 14, 2022
abf6f11
names updated
negarhdr Jun 14, 2022
e5ccc9a
style fixed
negarhdr Jun 15, 2022
5de7224
style fixed
negarhdr Jun 15, 2022
78a6557
style fixed
negarhdr Jun 20, 2022
90eab77
demo&doc updated
negarhdr Jul 21, 2022
c348d0d
Merge branch 'develop' into fer_va_estimation
negarhdr Jul 21, 2022
2004b10
Merge branch 'develop' into fer_va_estimation
passalis Sep 5, 2022
b34e172
Merge branch 'develop' into fer_va_estimation
passalis Sep 12, 2022
8388d99
doc&dependencies updated
negarhdr Sep 12, 2022
ad88f72
demo updated
negarhdr Sep 12, 2022
5299499
Revert "demo updated"
negarhdr Sep 12, 2022
b796aca
demo updated
negarhdr Sep 12, 2022
62eef12
ROS1 node updated
negarhdr Sep 13, 2022
f5af9ba
ROS1 node updated
negarhdr Sep 13, 2022
10584e4
ROS1 node updated
negarhdr Sep 13, 2022
b46499a
Merge branch 'develop' into fer_va_estimation
ad-daniel Sep 20, 2022
4ebd94a
Merge branch 'develop' into fer_va_estimation
passalis Sep 21, 2022
f799c38
Merge branch 'develop' into fer_va_estimation
negarhdr Oct 20, 2022
6d9736a
ros1_node fixed
negarhdr Oct 20, 2022
8df9d90
ros1 fixed
negarhdr Oct 20, 2022
63163e3
diversity extention added
negarhdr Oct 20, 2022
3288671
style fixed
negarhdr Oct 20, 2022
25c1133
benchmark added
negarhdr Oct 20, 2022
3097bd7
Merge branch 'develop' into fer_va_estimation
tsampazk Oct 24, 2022
a23c517
Merge branch 'develop' into fer_va_estimation
tsampazk Oct 24, 2022
0e111b4
Merge branch 'develop' into fer_va_estimation
tsampazk Oct 25, 2022
9084f83
Merge branch 'develop' into fer_va_estimation
tsampazk Oct 25, 2022
8295496
folder moved
negarhdr Oct 27, 2022
f16c157
folder moved
negarhdr Oct 27, 2022
83adbb1
benchmark updated
negarhdr Oct 28, 2022
88bef72
benchmark updated
negarhdr Oct 28, 2022
a36c4d5
benchmark updated
negarhdr Oct 28, 2022
0984b27
benchmark updated
negarhdr Oct 28, 2022
dcc9e1f
benchmark updated
negarhdr Oct 28, 2022
7a6b84a
benchmark updated
negarhdr Oct 28, 2022
caa907a
benchmark updated
negarhdr Oct 28, 2022
5920f67
benchmark updated
negarhdr Oct 28, 2022
a49be29
benchmark updated
negarhdr Oct 28, 2022
25252dc
benchmark updated
negarhdr Oct 28, 2022
4dd682e
benchmark updated
negarhdr Oct 28, 2022
99b12a3
benchmark updated
negarhdr Oct 28, 2022
3b099b3
benchmark updated
negarhdr Oct 28, 2022
40ce7e6
benchmark updated
negarhdr Oct 28, 2022
6c3f5b1
benchmark updated
negarhdr Oct 28, 2022
0d872ab
benchmark updated
negarhdr Oct 28, 2022
38a4005
model updated
negarhdr Nov 1, 2022
dbc7e12
model updated
negarhdr Nov 1, 2022
69a4099
model updated
negarhdr Nov 1, 2022
048d18c
model updated
negarhdr Nov 1, 2022
e0b7063
download updated
negarhdr Nov 2, 2022
c2bb984
code style fixed
negarhdr Nov 2, 2022
2a5f4cd
Remove pkg-resources
ad-daniel Nov 22, 2022
e48a0c0
Enforce torch dependency
ad-daniel Nov 22, 2022
3104883
tests updated
negarhdr Nov 24, 2022
f6418f6
test_pstbln updated
negarhdr Nov 24, 2022
5a7bfac
tests updated
negarhdr Nov 24, 2022
33116e1
download updated
negarhdr Nov 24, 2022
de74f25
Merge branch 'develop' into fer_va_estimation
ad-daniel Nov 25, 2022
148c7bd
download updated
negarhdr Nov 25, 2022
10c4f0e
Update facial_emotion_learner.py
negarhdr Nov 28, 2022
3b95d8d
download updated
negarhdr Nov 28, 2022
f6e6a21
download updated
negarhdr Nov 28, 2022
949af8b
doc updated
negarhdr Nov 28, 2022
557d823
doc updated
negarhdr Nov 28, 2022
7f5afd3
optimize updated
negarhdr Dec 12, 2022
9439f70
Merge branch 'develop' into fer_va_estimation
negarhdr Dec 12, 2022
678f875
download updated
negarhdr Dec 12, 2022
8fd7c5b
download updated
negarhdr Dec 12, 2022
d614243
infer updated
negarhdr Dec 13, 2022
aee9d66
Merge branch 'develop' into fer_va_estimation
negarhdr Dec 14, 2022
c781158
optimize updated
negarhdr Dec 16, 2022
b575a02
Merge remote-tracking branch 'origin/fer_va_estimation' into fer_va_e…
negarhdr Dec 16, 2022
602395e
optimize updated
negarhdr Dec 16, 2022
0ec3e98
optimize updated
negarhdr Dec 17, 2022
80f066d
optimize updated
negarhdr Dec 17, 2022
daa6ce0
code style fixed
negarhdr Dec 17, 2022
ec0466d
code style fixed
negarhdr Dec 17, 2022
b983959
code style fixed
negarhdr Dec 17, 2022
50e62b6
Minor fixes
ad-daniel Dec 19, 2022
fcc3e50
Update docs/reference/image_based_facial_emotion_estimation.md
negarhdr Dec 19, 2022
f1be494
Update docs/reference/image_based_facial_emotion_estimation.md
negarhdr Dec 19, 2022
4f0ac85
Update docs/reference/image_based_facial_emotion_estimation.md
negarhdr Dec 19, 2022
b0963d3
Update docs/reference/image_based_facial_emotion_estimation.md
negarhdr Dec 19, 2022
3709c0d
Update docs/reference/image_based_facial_emotion_estimation.md
negarhdr Dec 19, 2022
2a75d5e
Update docs/reference/image_based_facial_emotion_estimation.md
negarhdr Dec 19, 2022
ec6b42d
Update docs/reference/image_based_facial_emotion_estimation.md
negarhdr Dec 19, 2022
ec40c5b
Update docs/reference/image_based_facial_emotion_estimation.md
negarhdr Dec 19, 2022
abaae27
Update projects/opendr_ws/src/perception/scripts/facial_emotion_estim…
negarhdr Dec 19, 2022
e3fd13e
Update docs/reference/image_based_facial_emotion_estimation.md
negarhdr Dec 19, 2022
5ce9f20
Update docs/reference/image_based_facial_emotion_estimation.md
negarhdr Dec 19, 2022
da2f29f
Update docs/reference/image_based_facial_emotion_estimation.md
negarhdr Dec 19, 2022
73aabfe
Update src/opendr/perception/facial_expression_recognition/image_base…
negarhdr Dec 19, 2022
62c0300
Update docs/reference/image_based_facial_emotion_estimation.md
negarhdr Dec 19, 2022
2927321
Update docs/reference/image_based_facial_emotion_estimation.md
negarhdr Dec 19, 2022
b219b52
Moved and applied several fixes on facial emotion ros node
tsampazk Dec 19, 2022
f28fd15
Update projects/python/perception/facial_expression_recognition/image…
negarhdr Dec 19, 2022
d2a46c0
Update projects/python/perception/facial_expression_recognition/image…
negarhdr Dec 19, 2022
937bd45
Update projects/python/perception/facial_expression_recognition/image…
negarhdr Dec 19, 2022
cc27d06
Update projects/python/perception/facial_expression_recognition/image…
negarhdr Dec 19, 2022
eb7540a
Update projects/python/perception/facial_expression_recognition/image…
negarhdr Dec 19, 2022
1aca526
Update src/opendr/perception/facial_expression_recognition/image_base…
negarhdr Dec 19, 2022
4ae1144
Update src/opendr/perception/facial_expression_recognition/image_base…
negarhdr Dec 19, 2022
26c638b
Update src/opendr/perception/facial_expression_recognition/image_base…
negarhdr Dec 19, 2022
319a17f
Update src/opendr/perception/facial_expression_recognition/image_base…
negarhdr Dec 19, 2022
2ba0bd4
Update src/opendr/perception/facial_expression_recognition/image_base…
negarhdr Dec 19, 2022
9022256
Update src/opendr/perception/facial_expression_recognition/image_base…
negarhdr Dec 19, 2022
7b9f7a9
Update docs/reference/image_based_facial_emotion_estimation.md
negarhdr Dec 19, 2022
0121849
Update docs/reference/image_based_facial_emotion_estimation.md
negarhdr Dec 19, 2022
a30deea
Update docs/reference/image_based_facial_emotion_estimation.md
negarhdr Dec 19, 2022
1ba916f
Update projects/python/perception/facial_expression_recognition/image…
negarhdr Dec 19, 2022
17a0bbe
Update projects/opendr_ws/src/opendr_perception/scripts/facial_emotio…
negarhdr Dec 19, 2022
72ecb00
Merge branch 'develop' into fer_va_estimation
ad-daniel Dec 19, 2022
87a6216
index.md, CHANGELOG.md updated
negarhdr Dec 19, 2022
28b4863
download added to demo
negarhdr Dec 19, 2022
faf6c4d
download is updated. Demo downloads image/video files.
negarhdr Dec 19, 2022
70fb00a
evaluation results added to doc
negarhdr Dec 19, 2022
6bde13f
benchmark updated
negarhdr Dec 19, 2022
9f45b65
verbose added
negarhdr Dec 19, 2022
7219c7d
init_model added
negarhdr Dec 19, 2022
349cd0d
face detector path updated
negarhdr Dec 19, 2022
b07b7df
Merge branch 'develop' into fer_va_estimation
ad-daniel Dec 19, 2022
e57f67d
fix sources
ad-daniel Dec 19, 2022
5e350a3
Inference demo argument fixes
tsampazk Dec 20, 2022
bca3963
fix download, fix demo, fix image preprocess in ros node
negarhdr Dec 20, 2022
15b2506
Learner device argument fix
tsampazk Dec 20, 2022
f3914e4
demo implemented from scratch
negarhdr Dec 21, 2022
274bfdf
Merge remote-tracking branch 'origin/fer_va_estimation' into fer_va_e…
negarhdr Dec 21, 2022
6d722f3
style fixed
negarhdr Dec 21, 2022
6b6cd95
style fixed
negarhdr Dec 21, 2022
6871524
style fixed
negarhdr Dec 21, 2022
0109b59
style fixed
negarhdr Dec 21, 2022
6c192e1
ROS updated
negarhdr Dec 21, 2022
41d4d2f
ROS updated
negarhdr Dec 21, 2022
612d52a
ROS updated
negarhdr Dec 21, 2022
a0a4605
ROS updated
negarhdr Dec 21, 2022
627348b
Merge branch 'develop' into fer_va_estimation
tsampazk Dec 21, 2022
4591a19
Removed import for deleted script
tsampazk Dec 21, 2022
c360229
Modify cv2 show window to update properly
tsampazk Dec 21, 2022
e4860d0
ROS node now uses retina face detector and also outputs annotated images
tsampazk Dec 21, 2022
5d81220
Merge branch 'develop' into fer_va_estimation
tsampazk Dec 21, 2022
948ed10
ROS index addition of emotion estimation
tsampazk Dec 21, 2022
491a1ed
Added ros node emotion estimation entry
tsampazk Dec 21, 2022
e034c8f
Merge branch 'develop' into fer_va_estimation
ad-daniel Dec 21, 2022
9649dea
Fixed video and img modes
tsampazk Dec 21, 2022
18033ff
fixed path in download
tsampazk Dec 21, 2022
4561c8d
Merge branch 'develop' into fer_va_estimation
tsampazk Dec 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Released on December, XX, 2022.
- Added Continual Transformer Encoders ([#317](https://github.com/opendr-eu/opendr/pull/317)).
- Added Continual Spatio-Temporal Graph Convolutional Networks tool ([#370](https://github.com/opendr-eu/opendr/pull/370)).
- Added AmbiguityMeasure utility tool ([#361](https://github.com/opendr-eu/opendr/pull/361)).
- Added SiamRPN 2D tracking tool ([#367](https://github.com/opendr-eu/opendr/pull/367))

- Added SiamRPN 2D tracking tool ([#367](https://github.com/opendr-eu/opendr/pull/367)).
- Added Facial Emotion Estimation tool ([#264](https://github.com/opendr-eu/opendr/pull/264)).
- Bug Fixes:
- Fixed `BoundingBoxList`, `TrackingAnnotationList`, `BoundingBoxList3D` and `TrackingAnnotationList3D` confidence warnings ([#365](https://github.com/opendr-eu/opendr/pull/365)).
- Fixed undefined `image_id` and `segmentation` for COCO `BoundingBoxList` ([#365](https://github.com/opendr-eu/opendr/pull/365)).
Expand Down
Empty file added __init__.py
Empty file.
331 changes: 331 additions & 0 deletions docs/reference/image_based_facial_emotion_estimation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,331 @@
## image_based_facial_emotion_estimation module

The *image_based_facial_emotion_estimation* module contains the *FacialEmotionLearner* class, which inherits from the abstract class *Learner*.

### Class FacialEmotionLearner
Bases: `engine.learners.Learner`

The *FacialEmotionLearner* class is an implementation of the state-of-the-art method ESR [[1]](#1) for efficient facial feature learning with wide ensemble-based convolutional neural networks.
An ESR consists of two building blocks.
(1) The base of the network is an array of convolutional layers for low- and middle-level feature learning.
(2) These informative features are then shared with independent convolutional branches that constitute the ensemble.
From this point, each branch can learn distinctive features while competing for a common resource - the shared layers.
The [FacialEmotionLearner](/src/opendr/perception/facial_expression_recognition/image_based_facial_emotion_estimation/facial_emotion_learner.py) class has the following public methods:


#### `FacialEmotionLearner` constructor
```python
FacialEmotionLearner(self, lr, batch_size, temp_path, device, device_ind, validation_interval,
max_training_epoch, momentum, ensemble_size, base_path_experiment, name_experiment, dimensional_finetune, categorical_train,
base_path_to_dataset, max_tuning_epoch, diversify)
```

Constructor parameters:

- **lr**: *float, default=0.1*\
Specifies the initial learning rate to be used during training.
- **batch_size**: *int, default=32*\
Specifies number of samples to be bundled up in a batch during training.
This heavily affects memory usage, adjust according to your system.
- **temp_path**: *str, default='temp'*\
Specifies a path where the algorithm saves the checkpoints and onnx optimized model (if needed).
- **device**: *{'cpu', 'cuda'}, default='cuda'*\
Specifies the device to be used.
- **device_ind**: *list, default=[0]*\
List of GPU indices to be used if the device is 'cuda'.
- **validation_interval**: *int, default=1*\
Specifies the validation interval.
- **max_training_epoch**: *int, default=2*\
Specifies the maximum number of epochs the training should run for.
- **momentum**: *float, default=0.9*\
Specifies the momentum value used for optimizer.
- **ensemble_size**: *int, default=9*\
Specifies the number of ensemble branches in the model.
- **base_path_experiment**: *str, default='./experiments/'*\
Specifies the path in which the experimental results will be saved.
- **name_experiment**: *str, default='esr_9'*\
String name for saving checkpoints.
- **dimensional_finetune**: *bool, default=True*\
Specifies if the model should be fine-tuned on dimensional data or not.
- **categorical_train**: *bool, default=False*\
Specifies if the model should be trained on categorical data or not.
- **base_path_to_dataset**: *str, default=''./data/AffectNet''*\
Specifies the dataset path.
- **max_tuning_epoch**: *int, default=1*\
Specifies the maximum number of epochs the model should be finetuned on dimensional data.
- **diversity**: *bool, default=False*\
Specifies if the learner diversifies the features of different branches or not.

#### `FacialEmotionLearner.fit`
```python
FacialEmotionLearner.fit(self)
```

This method is used for training the algorithm on a train dataset and validating on a val dataset.


#### `FacialEmotionLearner.eval`
```python
FacialEmotionLearner.eval(self, eval_type, current_branch_on_training)
```

This method is used to evaluate a trained model on an evaluation dataset.
Returns a dictionary containing stats regarding evaluation.

Parameters:

- **eval_type**: *str, default='categorical'*\
Specifies the type of data that model is evaluated on.
It can be either categorical or dimensional data.
- **current_branch_on_training**: *int, default=0*\
Specifies the index of trained branch which should be evaluated on validation data.


#### `FacialEmotionLearner.init_model`
```python
FacialEmotionLearner.init_model(self, num_branches)
```

This method is used to initialize the model.

Parameters:

- **num_branches**: *int*\
Specifies the number of ensemble branches in the model. ESR_9 model is built by 9 branches by default.

#### `FacialEmotionLearner.infer`
```python
FacialEmotionLearner.infer(self, input_batch)
```

This method is used to perform inference on an image or a batch of images.
It returns dimensional emotion results and also the categorical emotion results as an object of `engine.target.Category` if a proper input object `engine.data.Image` is given.

Parameters:

- **input_batch**: *object***
Object of type `engine.data.Image`. It also can be a list of Image objects, or a Torch tensor which will be converted to Image object.

#### `FacialEmotionLearner.save`
```python
FacialEmotionLearner.save(self, state_dicts, base_path_to_save_model)
```
This method is used to save a trained model.
Provided with the path (absolute or relative), it creates the "path" directory, if it does not already exist.
Inside this folder, the model is saved as "model_name.pt" and the metadata file as "model_name.json". If the directory already exists, the "model_name.pt" and "model_name.json" files are overwritten.

If [`self.optimize`](#FacialEmotionLearner.optimize) was run previously, it saves the optimized ONNX model in a similar fashion with an ".onnx" extension, by copying it from the self.temp_path it was saved previously during conversion.

Parameters:

- **state_dicts**: *object*\
Object of type Python dictionary containing the trained model weights.
- **base_path_to_save_model**: *str*\
Specifies the path in which the model will be saved.

#### `FacialEmotionLearner.load`
```python
FacialEmotionLearner.load(self, ensemble_size, path_to_saved_network, file_name_base_network,
file_name_conv_branch, fix_backbone)
```

Loads the model from inside the directory of the path provided, using the metadata .json file included.

Parameters:

- **ensemble_size**: *int, default=9*\
Specifies the number of ensemble branches in the model for which the pretrained weights should be loaded.
- **path_to_saved_network**: *str, default="./trained_models/esr_9"*\
Path of the model to be loaded.
- **file_name_base_network**: *str, default="Net-Base-Shared_Representations.pt"*\
The file name of the base network to be loaded.
- **file_name_conv_branch**: *str, default="Net-Branch_{}.pt"*\
The file name of the ensemble branch network to be loaded.
- **fix_backbone**: *bool*\
If true, all the model weights except the classifier are fixed so that the last layers' weights are fine-tuned on dimensional data.
Otherwise, all the model weights will be trained from scratch.


#### `FacialEmotionLearner.optimize`
```python
FacialEmotionLearner.optimize(self, do_constant_folding)
```

This method is used to optimize a trained model to ONNX format which can be then used for inference.

Parameters:

- **do_constant_folding**: *bool, default=False*\
ONNX format optimization.
If True, the constant-folding optimization is applied to the model during export.


#### `FacialEmotionLearner.download`
```python
@staticmethod
FacialEmotionLearner.download(self, path, mode, url)
```

Downloads data and saves them in the path provided.

Parameters:

- **path**: *str, default=None*\
Local path to save the files, defaults to `self.temp_dir` if None.
- **mode**: *str, default="data"*\
What file to download, can be "data".
- **url**: *str, default=opendr FTP URL*\
URL of the FTP server.


#### Data preparation
Download the [AffectNet](http://mohammadmahoor.com/affectnet/) [[2]](https://www.computer.org/csdl/magazine/mu/2012/03/mmu2012030034/13rRUxjQyrW) dataset, and organize it in the following structure:
```
AffectNet/
Training_Labeled/
0/
1/
...
n/
Training_Unlabeled/
0/
1/
...
n/
Validation/
0/
1/
...
n/
```
In order to do that, you need to run the following function:
```python
from opendr.perception.facial_expression_recognition.image_based_facial_emotion_estimation.algorithm.utils import datasets
datasets.pre_process_affect_net(base_path_to_images, base_path_to_annotations, base_destination_path, set_index)
```
This pre-processes the AffectNet dataset by cropping and resizing the images into 96 x 96 pixels, and organizing them in folders with 500 images each.
Each image is renamed to follow the pattern "[id][emotion_idx][valence times 1000]_[arousal times 1000].jpg".

#### Pre-trained models

The pretrained models on AffectNet Categorical dataset are provided by [[1]](#1) which can be found [here](https://github.com/siqueira-hc/Efficient-Facial-Feature-Learning-with-Wide-Ensemble-based-Convolutional-Neural-Networks/tree/master/model/ml/trained_models/esr_9).
**Please note that the pretrained weights cannot be used for commercial purposes.**

#### Examples

* **Train the ensemble model on AffectNet Categorical dataset and then fine-tune it on the AffectNet dimensional dataset**
The training and evaluation dataset should be present in the path provided.
The `batch_size` argument should be adjusted according to available memory.

```python
from opendr.perception.facial_expression_recognition import FacialEmotionLearner

learner = FacialEmotionLearner(device="cpu", temp_path='./tmp',
batch_size=2, max_training_epoch=1, ensemble_size=1,
name_experiment='esr_9', base_path_experiment='./experiments/',
lr=1e-1, categorical_train=True, dimensional_finetune=True,
base_path_to_dataset='./data', max_tuning_epoch=1)
learner.fit()
learner.save(state_dicts=learner.model.to_state_dict(),
base_path_to_save_model=learner.base_path_experiment,
current_branch_save=8)
```

* **Inference on a batch of images**
```python
from opendr.perception.facial_expression_recognition import FacialEmotionLearner
from torch.utils.data import DataLoader

learner = FacialEmotionLearner(device="cpu", temp_path='./tmp',
batch_size=2, max_training_epoch=1, ensemble_size=1,
name_experiment='esr_9', base_path_experiment='./experiments/',
lr=1e-1, categorical_train=True, dimensional_finetune=True,
base_path_to_dataset='./data', max_tuning_epoch=1)

# Download the validation data
dataset_path = learner.download(mode='data')
val_data = datasets.AffectNetCategorical(idx_set=2,
max_loaded_images_per_label=2,
transforms=None,
is_norm_by_mean_std=False,
base_path_to_affectnet=learner.dataset_path)

val_loader = DataLoader(val_data, batch_size=32, shuffle=False, num_workers=8)
batch = next(iter(val_loader))[0]
learner.load(learner.ensemble_size, path_to_saved_network=learner.base_path_experiment, fix_backbone=True)
ensemble_emotion_results, ensemble_dimension_results = learner.infer(batch[0])
```

* **Optimization example for a previously trained model**
Inference can be run with the trained model after running self.optimize.
```python
from opendr.perception.facial_expression_recognition import FacialEmotionLearner

learner = FacialEmotionLearner(device="cpu", temp_path='./tmp',
batch_size=2, max_training_epoch=1, ensemble_size=1,
name_experiment='esr_9', base_path_experiment='./experiments/',
lr=1e-1, categorical_train=True, dimensional_finetune=True,
base_path_to_dataset='./data', max_tuning_epoch=1)


learner.load(learner.ensemble_size, path_to_saved_network=learner.base_path_experiment, fix_backbone=True)
learner.optimize(do_constant_folding=True)
learner.save(path='./parent_dir/optimized_model', model_name='optimized_pstbln')
```


#### Performance Evaluation

The tests were conducted on the following computational devices:
- Intel(R) Xeon(R) Gold 6230R CPU on server
- Nvidia Jetson TX2
- Nvidia Jetson Xavier AGX
- Nvidia RTX 2080 Ti GPU on server with Intel Xeon Gold processors


Inference time is measured as the time taken to transfer the input to the model (e.g., from CPU to GPU), run inference using the algorithm, and return results to CPU.
The ESR and its extension diversified_ESR denoted as ESR*, which learns diversified feature representations to improve the model generalisation, are implemented in *FacialEmotionLearner*.
The ESR-n and ESR*-n denote the ESR and diversified-ESR models with #n ensemble branches, respectively

The model can receive either single images as input or a video, which can be captured by webcam, and perform the prediction frame-by-frame.

We report speed (single sample per inference) as the mean of 100 runs, and the energy (Joules) on embedded devices.
The noted memory is the maximum allocated memory on GPU during inference.

| Method | Acc. (%) | Params (M) | Mem. (MB) |
|--------------|----------|------------|-----------|
| ESR-9 | 87.17 | 20.35 | 402.99 |
| ESR-15 | 88.59 | 33.67 | 455.61 |
| ESR*-9 | 89.15 | 20.83 | 406.83 |
| ESR*-15 | 89.34 | 34.47 | 460.73 |

The inference speed (evaluations/second) of both learners on various computational devices are as follows:

| Method | CPU | Jetson TX2 | Jetson Xavier | RTX 2080 Ti |
|--------------|-------|------------|---------------|-------------|
| ESR-9 | 22.23 | 27.08 | 28.79 | 117.91 |
| ESR-15 | 13.86 | 17.76 | 18.17 | 91.78 |
| ESR*-9 | 5.24 | 6.60 | 12.45 | 33.40 |
| ESR*-15 | 3.38 | 4.18 | 8.47 | 20.57 |

Energy (Joules) of both learners’ inference on embedded devices is shown in the following:

| Method | Jetson TX2 | Jetson Xavier |
|---------|------------|---------------|
| ESR-9 | 0.96 | 0.67 |
| ESR-15 | 1.16 | 0.93 |
| ESR*-9 | 3.38 | 1.41 |
| ESR*-15 | 6.26 | 2.51 |




## References

<a id="1">[1]</a>
[Siqueira, Henrique, Sven Magg, and Stefan Wermter. "Efficient facial feature learning with wide ensemble-based convolutional neural networks." Proceedings of the AAAI conference on artificial intelligence. Vol. 34. No. 04. 2020.](
https://ojs.aaai.org/index.php/AAAI/article/view/6037)

<a id="2">[2]</a>
[Mollahosseini, Ali, Behzad Hasani, and Mohammad H. Mahoor. "Affectnet: A database for facial expression, valence, and arousal computing in the wild." IEEE Transactions on Affective Computing 10.1 (2017): 18-31.](
https://ieeexplore.ieee.org/abstract/document/8013713)
2 changes: 2 additions & 0 deletions docs/reference/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Neither the copyright holder nor any applicable licensor will be liable for any
- [face_recognition_learner Module](face-recognition.md)
- facial expression recognition:
- [landmark_based_facial_expression_recognition](landmark-based-facial-expression-recognition.md)
- [image_based_facial_emotion_estimation](image_based_facial_emotion_estimation.md)
- pose estimation:
- [lightweight_open_pose Module](lightweight-open-pose.md)
- activity recognition:
Expand Down Expand Up @@ -108,6 +109,7 @@ Neither the copyright holder nor any applicable licensor will be liable for any
- [face_recognition_Demo](/projects/python/perception/face_recognition)
- facial expression recognition:
- [landmark_based_facial_expression_recognition Demo](/projects/python/perception/facial_expression_recognition/landmark_based_facial_expression_recognition)
- [image_based_facial_emotion_estimation Demo](/projects/python/perception/facial_expression_recognition/image_based_facial_emotion_estimation)
- heart anomaly detection:
- [heart anomaly detection Demo](/projects/python/perception/heart_anomaly_detection)
- pose estimation:
Expand Down
7 changes: 4 additions & 3 deletions projects/opendr_ws/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ Currently, apart from tools, opendr_ws contains the following ROS nodes (categor
7. [2D Object Tracking](src/opendr_perception/README.md#2d-object-tracking-ros-nodes)
8. [Panoptic Segmentation](src/opendr_perception/README.md#panoptic-segmentation-ros-node)
9. [Semantic Segmentation](src/opendr_perception/README.md#semantic-segmentation-ros-node)
10. [Landmark-based Facial Expression Recognition](src/opendr_perception/README.md#landmark-based-facial-expression-recognition-ros-node)
11. [Skeleton-based Human Action Recognition](src/opendr_perception/README.md#skeleton-based-human-action-recognition-ros-node)
12. [Video Human Activity Recognition](src/opendr_perception/README.md#video-human-activity-recognition-ros-node)
10. [Image-based Facial Emotion Estimation](src/opendr_perception/README.md#image-based-facial-emotion-estimation-ros-node)
11. [Landmark-based Facial Expression Recognition](src/opendr_perception/README.md#landmark-based-facial-expression-recognition-ros-node)
12. [Skeleton-based Human Action Recognition](src/opendr_perception/README.md#skeleton-based-human-action-recognition-ros-node)
13. [Video Human Activity Recognition](src/opendr_perception/README.md#video-human-activity-recognition-ros-node)
## RGB + Infrared input
1. [End-to-End Multi-Modal Object Detection (GEM)](src/opendr_perception/README.md#2d-object-detection-gem-ros-node)
## RGBD input
Expand Down
1 change: 1 addition & 0 deletions projects/opendr_ws/src/opendr_perception/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ catkin_install_python(PROGRAMS
scripts/object_detection_2d_gem_node.py
scripts/semantic_segmentation_bisenet_node.py
scripts/object_tracking_2d_siamrpn_node.py
scripts/facial_emotion_estimation_node.py
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
Loading