Wolfram Computation Meets Knowledge

Age Estimation VGG-16 Trained on IMDB-WIKI and Looking at People Data

Predict a person's age from an image of their face

Originally released in 2016 as a pre-trained model for the launch of the IMDB-WIKI dataset by the Computer Vision Lab at ETH Zurich, this model is based on the VGG-16 architecture and is designed to run on cropped images of faces only. The model was also fine-tuned on the dataset for the Looking at People Apparent Age competition. An ensemble of these models won first place at the challenge.

Number of layers: 40 | Parameter count: 134,674,341 | Trained size: 540 MB

Training Set Information

Examples

Resource retrieval

Retrieve the resource object:

In[1]:=
ResourceObject["Age Estimation VGG-16 Trained on IMDB-WIKI and \
Looking at People Data"]
Out[1]=

Get the pre-trained net:

In[2]:=
NetModel["Age Estimation VGG-16 Trained on IMDB-WIKI and Looking at \
People Data"]
Out[2]=

Basic usage

Guess the age of a person from a photograph. First, obtain the trained net:

In[3]:=
Out[3]=

Obtain the probability distribution over all possible ages:

In[4]:=
Out[4]=

Plot the probability distribution over possible ages:

In[5]:=
ListPlot[probabilities, Filling -> Axis, PlotRange -> All]
Out[5]=

The recommended estimator of the age is the mean of the probability mass function:

In[6]:=
Mean@WeightedData[Range[0, 100], probabilities]
Out[6]=

By default, the mode is used as the estimator:

In[7]:=
MaximalBy[Value][probabilities]
Out[7]=

This net is designed to work with cropped images of faces only. If the photograph is not a facial image, the results may be unexpected:

In[8]:=
In[9]:=
NetModel["Age Estimation VGG-16 Trained on IMDB-WIKI and Looking at \
People Data"][img]
Out[9]=

Crop the photograph:

In[10]:=
crop = ImageTrim[img, #] & /@ FindFaces[img]
Out[10]=

Guess the age of a person from the cropped image:

In[11]:=
NetModel["Age Estimation VGG-16 Trained on IMDB-WIKI and Looking at \
People Data"][crop]
Out[11]=

Export to MXNet

Export the net into a format that can be opened in MXNet:

In[12]:=
jsonPath = 
 Export[FileNameJoin[{$TemporaryDirectory, "net.json"}], 
  NetModel["Age Estimation VGG-16 Trained on IMDB-WIKI and Looking at \
People Data"], "MXNet"]
Out[12]=

Export also creates a net.params file containing parameters:

In[13]:=
paramPath = FileNameJoin[{DirectoryName[jsonPath], "net.params"}]
Out[13]=

Get the size of the parameter file:

In[14]:=
FileByteCount[paramPath]
Out[14]=

The size is similar to the byte count of the resource object:

In[15]:=
ResourceObject[
  "Age Estimation VGG-16 Trained on IMDB-WIKI and Looking at People \
Data"]["ByteCount"]
Out[15]=

Represent the MXNet net as a graph:

In[16]:=
Import[jsonPath, {"MXNet", "NodeGraphPlot"}]
Out[16]=

Requirements

Wolfram Language 11.2 (September 2017) or above

Reference