Wolfram Research

FER-2013

The Facial Expression Recognition 2013 (FER-2013) Dataset

Originator: Pierre-Luc Carrier and Aaron Courville

Classify facial expressions from 35,685 examples of 48x48 pixel grayscale images of faces. Images are categorized based on the emotion shown in the facial expressions (happiness, neutral, sadness, anger, surprise, disgust, fear).

Examples

Basic Examples

Retrieve the resource:

In[1]:=
ResourceObject["FER-2013"]
Out[1]=

Retrieve a sample of the data:

In[2]:=
RandomSample[ResourceData["FER-2013"], 25]
Out[2]=

Analysis

Select one image of each facial expression:

In[3]:=
sample = Cases[ResourceData["FER-2013"], 
     HoldPattern[_ -> #]][[-1]] & /@ {Entity["Emotion", 
    "Happiness::d8973"], Entity["Emotion", "Neutral::7468h"], 
   Entity["Emotion", "Sadness::t2566"], 
   Entity["Emotion", "Anger::bb6bt"], 
   Entity["Emotion", "Surprise::dj3w9"], 
   Entity["Emotion", "Disgust::s4t7h"], 
   Entity["Emotion", "Fear::7k5tk"]}
Out[3]=

Use a built-in classifier:

In[4]:=
classifier = Classify["FacialExpression"]
Out[4]=

Test the built-in classifier on a set of images:

In[5]:=
classifier[Keys[sample]]
Out[5]=

Create a larger test set:

In[6]:=
test = RandomSample[ResourceData["FER-2013"], 300];

Measure the accuracy of the classifier on the test set:

In[7]:=
cm = ClassifierMeasurements[classifier, test]
Out[7]=

Visualize that accuracy of the classifier:

In[8]:=
cm["ConfusionMatrixPlot"]
Out[8]=

Wolfram Research, "FER-2013" from the Wolfram Data Repository (2018) 

Data Resource History

Source Metadata

Publisher Information