Wolfram Computation Meets Knowledge

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

Retrieve the resource object:

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

Get the pre-trained net:

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

Basic usage

Apply the trained net to an input image:

In[3]:=
Out[3]=

Obtain the probabilities for each class for two images:

In[4]:=
Out[4]=

Export to MXNet

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

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

Export also creates a net.params file containing parameters:

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

Get the size of the parameter file:

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

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

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

Requirements

Wolfram Language 11.2 (September 2017) or above

Reference