Wolfram Computation Meets Knowledge

Gender Prediction VGG-16 Trained on IMDB-WIKI Data

Predict a person's gender 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.

Number of layers: 40 | Parameter count: 134,268,738 | Trained size: 538 MB

Training Set Information

Examples

Resource retrieval

Retrieve the resource object:

In[1]:=
ResourceObject["Gender Prediction VGG-16 Trained on IMDB-WIKI Data"]
Out[1]=

Get the pre-trained net:

In[2]:=
NetModel["Gender Prediction VGG-16 Trained on IMDB-WIKI Data"]
Out[2]=

Basic usage

Guess the gender of a person from a photograph:

In[3]:=
Out[3]=

Obtain the probabilities:

In[4]:=
Out[4]=

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

In[5]:=
In[6]:=
NetModel["Gender Prediction VGG-16 Trained on IMDB-WIKI Data"][img]
Out[6]=

Crop the photograph:

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

Guess the gender of a person from the cropped image:

In[8]:=
NetModel["Gender Prediction VGG-16 Trained on IMDB-WIKI Data"][crop]
Out[8]=

Export to MXNet

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

In[9]:=
jsonPath = 
 Export[FileNameJoin[{$TemporaryDirectory, "net.json"}], 
  NetModel["Gender Prediction VGG-16 Trained on IMDB-WIKI Data"], 
  "MXNet"]
Out[9]=

Export also creates a net.params file containing parameters:

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

Get the size of the parameter file:

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

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

In[12]:=
ResourceObject[
  "Gender Prediction VGG-16 Trained on IMDB-WIKI Data"]["ByteCount"]
Out[12]=

Represent the MXNet net as a graph:

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

Requirements

Wolfram Language 11.2 (September 2017) or above

Reference