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]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/1f81463a-8301-4e4d-9360-1ff5244adb7f"]
Out[2]=

Obtain the probabilities:

In[3]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/e26f24a5-d3d2-4203-8383-9d821d6fdd70"]
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]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/0f56d118-af3f-4953-9d41-fa9979c07652"]
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