# Image Synthesis from Yahoo's open_nsfw

Warning: This post contains abstract depictions of nudity and may be unsuitable for the workplace

Yahoo's recently open sourced neural network, open_nsfw, is a fine tuned Residual Network which scores images on a scale of

Defining NSFW material is subjective and the task of identifying these images is non-trivial. Moreover, what may be objectionable in one context can be suitable in another.

What makes an image NSFW, according to Yahoo? I explore this question with a clever new visualization technique by Nguyen et al.. Like Google's Deep Dream, this visualization trick works by maximally activating certain neurons of the classifier. Unlike deep dream, we optimize these activations by performing descent on a parameterization of the manifold of natural images. This parametrization takes the form of a Generative Network,

The "space of natural images", according to

### NSFW Images

Following Nguyen et al., we perform projected gradient descent on the following problem

to obtain the maximal activation for

### SFW Images

On there other end of the spectrum, optimizing for SFW images seem redundant, as you might just expect it to be the absence of NSFW content. If this were the case, one would expect to observe most images scoring close to

in the exact same way as above.

Images which maximize the this score all have a distinct pastoral quality – depictions of hills, streams and generally pleasant scenery. This is likely an artifact of the negative examples used in the training set.

### Synthesizing Pareidolia

Lets take this even further by stripping a layer off this network. The final score,

to get the final score. Since most pornography does not take place with a Thomas Kinkade painting in the background, so this is a fair heuristic for most real world problems. But what happens if we try to excite both neurons simultaneously? This amounts to minimizing

Surprisingly, from my experiments, for

Spurred on by the success above, I explore the possibility of the generation of images for which activations span two different networks. Nguyen et al. has achieved great results on the MIT scene recognition model places-CNN . What happens when we maximize neurons of places-CNN and open_nsfw together?

We will refer to the places-CNN classifier's belief that an image

(The above equation isn't strictly correct, and needs one more tweak for this to work. For details of the optimization, I refer you to the code)

This program produces the most remarkable results. The images generated range from the garishly explicit to the subtle. But the subtle images are the most fascinating as to my surprise they are only seemingly innocent. These are not adversarial examples per-say. The NSFW elements are all present, just hidden in plain sight. Once you see the true nature of these images, something clicks and it becomes impossible to unsee. I've picked a few of my favorite results for show here.

##### Volcano

The generative capacity of convolutional neural nets are, quite simply, remarkable.

If you liked this project, say hi here. And you can view my badly commented code for the second part of this project here. You will need this library, and of course, open_nsfw to run it. I trust you'll figure the rest out.

If you really want to, you can follow me on twitter.

This is my website