Paper commentary
AffectNet: A Database for Facial Expression, Valence, and Arousal Computing in the Wild
AffectNet collects a million web faces labeled with emotion categories and valence-arousal
- Problem Existing facial expression databases are small, mostly posed, or labeled with only one emotion model. Few in-the-wild sets carry both categories and continuous valence and arousal values.
- Method AffectNet is a database built by querying three search engines with 1250 emotion keywords in six languages. Annotators label about half the images with seven expressions plus valence and arousal.
- Results AffectNet holds more than 1,000,000 images, and weighted loss scored 0.62 skew-normalized F1 versus 0.52 for imbalanced learning.
Why in-the-wild affect data stays scarce
Expression models tend to fail once lighting, camera view and head pose leave the lab. Most older databases hold posed expressions, and posed faces differ from natural ones in configuration, intensity and timing. Wild collections exist, but each covers only one affect model, stays small, or contains very few disgust examples.
Valence and arousal describe emotion on a continuous scale, so they can separate subtle displays that a fixed category list cannot. Continuous labels cost more to collect, because annotators must be trained to place each face on that scale. Aff-Wild is the closest in-the-wild resource, but it covers only 500 subjects. The gap the authors target is one large in-the-wild set that carries both label models.
Collecting over a million web faces
The authors queried Google, Bing and Yahoo with 1250 emotion-related keywords in six languages. English keywords paired emotion words with gender, age or ethnicity terms, giving nearly 362 strings. Direct translation missed the intended emotions, so native speakers wrote the queries in their own languages and checked result quality by eye.
Negative terms such as drawing and cartoon were added to exclude non-human images, and stock photo sites were filtered out.
OpenCV located faces, and a regression-based alignment method placed 66 landmark points on each one. About 1,800,000 distinct URLs were stored for each query, and images with at least one landmarked face were kept. That left more than 1,000,000 images, with an average face size of 425 × 425 pixels and a standard deviation of 349 × 349. On a 50,000-image sample, the Microsoft face API estimated 49% men and an average age of 33.01 years.
Labeling 450,000 faces by hand
Of the images, 450,000 were labeled manually in both models. Before labeling, each annotator went through a tutorial and three training sessions of 200 images, with feedback. Each image was labeled once, because of time and budget limits.
Annotators chose one of eleven categories, from Neutral, Happy and Sad to None, Uncertain and Non-face. None covers expressions such as sleepy or focused that fit no basic emotion, yet those images still receive valence and arousal values. Uncertain and Non-face images get no valence or arousal value. Valence and arousal are placed on a circle in a 2D Cartesian plane, and the tool refuses points outside the circumplex.
A warning appears when a point falls outside the region set for the chosen emotion, and flagged images are reviewed later. Happy is the largest class with 146,198 images, while Contempt has 5,135.
To check reliability, 36,000 images were labeled independently by two annotators. They agreed on the category for 60.7% of the images. Agreement on valence was higher than on arousal, which the authors attribute to arousal being more subjective in still images. The authors take this as a sign that AffectNet is hard, since human RMSE exceeds the automated RMSE reported on earlier databases.
Two AlexNet baselines and their training
The categorical baseline learns features with a CNN and compares four ways of coping with a skewed training set. Both baselines use AlexNet: five convolution layers with max-pooling and normalization, followed by three fully connected layers. Faces are cropped and resized to 256 × 256 pixels, with no facial registration. Training uses random 224 × 224 crops with horizontal flips, 20 epochs and batch size 256.
The four options are imbalanced learning, down-sampling to at most 15,000 per class, up-sampling to the Happy count, and weighted loss. Weighted loss scales each class's log-probability by a penalty factor \(H_{l,i}\), so misclassifying a rare class costs more. The loss is \(E=-\sum_{i=1}^{K} H_{l,i}\log(\hat p_i)\), where K is the number of classes and \(\hat p_i\) is the softmax probability of class i.
When H is the identity, this reduces to ordinary cross-entropy. The diagonal H sets each class's weight to \(f_i/f_{min}\), its sample count over the count of the rarest class, which is Disgust here.
The dimensional baseline trains two separate AlexNets, one for valence and one for arousal. Each replaces the final layer with a single linear regression neuron, so the output lies in [-1, 1]. Training minimizes the Euclidean (L2) loss between predicted and true values, with learning rate 0.001. Training stops when validation error plateaus, at about 16 epochs.
For comparison, the authors trained an SVM and an SVR on HOG features with cell size 8. PCA keeping 95% of the variance cut the 36,864 HOG dimensions to 6,697.
Categorical results and the imbalance fix
The test set is imbalanced, so the authors report both original and skew-normalized scores. Skew normalization randomly under-samples the test classes and averages scores over 200 trials. This matters because the test set holds more than 11,000 happy images but only 1,000 contemptuous ones.
On skew-normalized F1, weighted loss scored 0.62, compared to 0.52 for imbalanced learning and 0.57 for down-sampling. The gain is largest on rare classes: top-1 F1 for Contempt rose from 0.08 with imbalanced learning to 0.59 with weighted loss. This follows from the weighting, since errors on under-represented classes are penalized more heavily.
Up-sampling replicated Contempt and Disgust almost 20 times, and the network overfit those samples. Imbalanced learning performed worst on Contempt and Disgust. The weighted-loss confusion matrix is weaker on Neutral and Happy, with 53.3 and 72.8 on the diagonal. The authors blame this on the network not being penalized enough for errors on those two classes.
The Microsoft Cognitive Services emotion API scored 0.94 accuracy on Neutral and 0.85 on Happy. On Fear, Disgust and Contempt it scored 0.25, 0.27 and 0.04. Its skew-normalized accuracy was 0.48, compared to 0.63 for weighted loss. The authors use this to argue that AffectNet is hard even for an off-the-shelf system.
Valence and arousal results
So the CNN wins clearly on valence, while on arousal the two RMSE values nearly tie. On CCC, the CNN reached 0.541 for valence, compared to 0.340 for SVR.
The authors credit the wide variety of AffectNet samples for letting the CNN learn better features than hand-crafted HOG. Training and validation error were tracked over 16K iterations, about 16 epochs.
Limitations
Most labels come from a single annotator, because only 36,000 images were labeled twice. The agreement figures therefore cover only that subset, and the paper does not measure label noise on the rest.
The test set is heavily imbalanced, with more than 11,000 happy images and only 1,000 contemptuous ones. For valence and arousal test labels, one of two annotations was picked at random. On category disagreements, the intended query won in 29.5% of the images.
The dimensional baseline is AlexNet alone, and no other architecture is tested. The authors believe a better weight matrix, built from mini-batch counts or data-driven rules, could help well-represented classes, but they did not test it.
Paper info
- Authors
- Mollahosseini, Ali, Hasani, Behzad, Mahoor, Mohammad H.
- Venue
- arXiv · Preprint
- First published
- 2017-8-14
- Added
- 2026-11-12
- Updated
- 2017-10-9
- Version
- v4
- arXiv
- 1708.03985
- DOI
- 10.1109/taffc.2017.2740923
- Category
- cs.CV
- Original paper terms
- arXiv non-exclusive 1.0
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Mollahosseini, Ali, Hasani, Behzad, Mahoor, Mohammad H. (2017). AffectNet: A Database for Facial Expression, Valence, and Arousal Computing in the Wild. arXiv:1708.03985v4. https://doi.org/10.1109/taffc.2017.2740923
BibTeX
@article{ali2017affectnet,
title = {{AffectNet: A Database for Facial Expression, Valence, and Arousal Computing in the Wild}},
author = {Mollahosseini, Ali and Hasani, Behzad and Mahoor, Mohammad H.},
year = {2017},
eprint = {1708.03985},
archivePrefix = {arXiv},
doi = {10.1109/taffc.2017.2740923},
url = {https://arxiv.org/abs/1708.03985v4}
}