Yahoo Open NSFW Model V1

Determine whether an image contains pornographic content

Released in 2016 by Yahoo, this net is a binary classifier (safe/not safe) fine-tuned from the pre-trained ResNet-50 model. It determines whether an image is not suitable/safe for work (NSFW), due to the presence of nudity and/or pornographic content. The original model was chosen to provide a good tradeoff between accuracy and computational weight.

Number of layers: 177 | Parameter count: 5,944,514 | Trained size: 24 MB |

Training Set Information

Examples

Resource retrieval

Get the pre-trained net:

In[1]:=
NetModel["Yahoo Open NSFW Model V1"]
Out[1]=

Basic usage

Apply the trained net to an input image:

In[2]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/479791ef-28d2-4c7e-b097-3646cb064a04"]
Out[2]=

Obtain the probabilities for each class for two images:

In[3]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/a556f73d-df3e-42d8-9e31-ccb1da45389a"]
Out[3]=

Net information

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

In[4]:=
NetInformation[
 NetModel["Yahoo Open NSFW Model V1"], "ArraysElementCounts"]
Out[4]=

Obtain the total number of parameters:

In[5]:=
NetInformation[
 NetModel["Yahoo Open NSFW Model V1"], "ArraysTotalElementCount"]
Out[5]=

Obtain the layer type counts:

In[6]:=
NetInformation[
 NetModel["Yahoo Open NSFW Model V1"], "LayerTypeCounts"]
Out[6]=

Display the summary graphic:

In[7]:=
NetInformation[NetModel["Yahoo Open NSFW Model V1"], "SummaryGraphic"]
Out[7]=

Export to MXNet

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

In[8]:=
jsonPath = Export[FileNameJoin[{$TemporaryDirectory, "net.json"}], NetModel["Yahoo Open NSFW Model V1"], "MXNet"]
Out[8]=

Export also creates a net.params file containing parameters:

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

Get the size of the parameter file:

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

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

In[11]:=
ResourceObject["Yahoo Open NSFW Model V1"]["ByteCount"]
Out[11]=

Requirements

Wolfram Language 11.2 (September 2017) or above

Resource History

Reference