Wolfram Research

Gender Prediction VGG-16 Trained on IMDB-WIKI Data

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

Released in 2015 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

Get the pre-trained net:

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

Basic usage

Guess the gender of a person from a photograph:

In[2]:=
CloudGet["https://www.wolframcloud.com/objects/a81d45df-35f7-4b81-b4e6-49295f0a92ff"] (* Evaluate this cell to copy the example input from a cloud object *)
Out[2]=

Obtain the probabilities:

In[3]:=
CloudGet["https://www.wolframcloud.com/objects/b80e776b-40d3-4bd9-9025-c3827b283779"] (* Evaluate this cell to copy the example input from a cloud object *)
Out[3]=

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[4]:=
CloudGet["https://www.wolframcloud.com/objects/0a047e25-8177-45f3-92e0-f7323e199f7c"] (* Evaluate this cell to copy the example input from a cloud object *)
In[5]:=
NetModel["Gender Prediction VGG-16 Trained on IMDB-WIKI Data"][img]
Out[5]=

Crop the photograph:

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

Guess the gender of a person from the cropped image:

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

Net information

Inspect the number of parameters of all arrays in the net:

In[8]:=
NetInformation[
 NetModel["Gender Prediction VGG-16 Trained on IMDB-WIKI Data"], \
"ArraysElementCounts"]
Out[8]=

Obtain the total number of parameters:

In[9]:=
NetInformation[
 NetModel["Gender Prediction VGG-16 Trained on IMDB-WIKI Data"], \
"ArraysTotalElementCount"]
Out[9]=

Obtain the layer type counts:

In[10]:=
NetInformation[
 NetModel["Gender Prediction VGG-16 Trained on IMDB-WIKI Data"], \
"LayerTypeCounts"]
Out[10]=

Display the summary graphic:

In[11]:=
NetInformation[
 NetModel["Gender Prediction VGG-16 Trained on IMDB-WIKI Data"], \
"SummaryGraphic"]
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["Gender Prediction VGG-16 Trained on IMDB-WIKI 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[
  "Gender Prediction VGG-16 Trained on IMDB-WIKI 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

Resource History

Reference