Warning: the article contains abstract images of naked bodies and may not be suitable for viewing in the workplace.
Some examples of abstract art generated using the open_nsfw neural network.
Recently, Yahoo
opened the open_nsfw neural network
source code . This is a specially trained residual learning neural network (
ResNet ), which classifies images by exposing them to an “indecency rating” from 0 to 1. The program is designed to automatically detect NSFW images, that is, unsuitable for viewing in the workplace. Simply put, to identify pornography. Naturally, the goal is to filter such images - removing them from open access.
')
Probably, the company Yahoo did not anticipate
exactly how resourceful hackers will apply its intellectual development.
Formally, graduate student Gabriel Goh of the University of California, Davis did nothing reprehensible. The guy specializes in machine learning, probability theory and convex minimization. He just wondered what the Yahoo neural network understands by NSFW. Which images exactly get the maximum rating by its classifier.
To get an answer to this question, Gabriel applied a relatively new visualization technique, most recently
developed for neural networks of machine vision by a group of researchers with the participation of Ana Nguyen, Alexey Dosovitsky and others. Their work has not yet been published in the official journal, but is already in the public domain. This technique involves a deep study of how a neural network works. Researchers can visually visualize which specific signs in the images learned to select each neuron. One of the known ways to achieve this is to use the technique of maximizing activation (AM). It synthesizes such incoming values ​​(that is, such an image) that maximize the neuron. In a
published scientific paper, researchers showed how you can dramatically increase the quality of AM, using a powerful tool - a neural network-image generator!
The so-called deep generator network (DGN) generates a large number of synthetic images. They look almost like real photographs, thereby determining the learned functions of each neuron of the studied neural network with high accuracy and in a repeatable manner. The advantage of the DGN generator is that it tests relatively well the neural networks of different architectures trained on different data sets. That is, it is a fairly universal research tool.
In many ways, the work of this DGN is similar to the work of the
Deep Dream generator, developed by experts from the research department of Google Research a year and a half ago. But DGN, apparently, works much better and more efficiently due to additional preliminary training on a set of natural photos, although they are not related to the data set on which the studied neural network was working or working. Then the DGN generator generates a variety of synthetic images, changing the parameters of natural photos. Such a method, in fact, works as a generative adversary network in which neural networks
fight each other .
By the way, DGN can be used in general for another purpose - as the author of synthetic images. Works of art that meet the specified criteria.
In our case, the given criterion is the maximum rating on the NSFW scale. It is difficult to call it such an outstanding art, but the task is quite specific. If the task is set, you need to solve it.
So, the “space of natural images”, according to the logic of the generative adversary neural network, looks almost like abstract art. Randomly generated images naturally naturally get low NSFW scores.
For example, this picture has only 0.06.
Here, a little more pornography - 0.07.
Well, after that we run DGN according to the method described in the scientific work of Nguyen, Dosovitsky and others. Moreover, the authors kindly
uploaded the source code for DGN
on Github .
So, DGN is launched with the following condition for obtaining the maximum NSFW index, that is, maximizing the function D (x).
And that's it, now you can enjoy countless maximum pornographic images with an index of 1.00.
It must be said that abstract synthetic images in most solaushes look really quite realistic. Although it is clear that these are not some real objects, but simply generated sets of pixels with completely unknown content.
Here are some of them.


The graduate student continued the experiment - and set the opposite task for DGN: to generate pictures with the minimum value of the NSFW index.
That is, not just a guaranteed lack of pornography, but something more is
anti-pornography .
Most interestingly, in the Yahoo neural network, the value of D (x) is calculated from the relative activation power of not one, but two independent neurons — one NSFW, as one might expect, and the second — SFW. That is, the neural network is a little “excited” even on completely safe images, such as rounded hills and so on.
Knowing this information, it is possible to generate soft erotic pictures in which pornography is guaranteed to be absent, but which nevertheless “excite” the neural network, focused on searching for porn.
The researcher played with the coefficients in the equation in order to find the optimal combination of neurons of pornography and anti-porn for the best artistic effect, but at the same time for obtaining the maximum porno-index 1.
Here are these amazing pictures.
Stunned by the beauty of these results, the author launched DGN not on the same open_nsfw neural network, but also on the other
places-CNN neural network, which classifies photos according to the location of the shooting. Thus, he received pictures that get maximum results
at the same time and at the place of shooting (beach, canyon, concert, etc.), and the minimum / maximum result for the NSFW index.
Beach
Concert
Desert
The museum
Volcano
Truly, there is a rich field for experimentation.
The author sadly admits that the elements of the NSFW can, in principle, be revealed in
all the photographs. It's all about the ability to recognize them. If you look, on the basis of what originals these samples are created, then you will not be able to “see” these elements even on original photographs from concerts, from museums, etc.
If you study the open_nsfw neural network for a long time, who knows, maybe you will start to see elements of NSFW everywhere around?