Official DeepNude Algorithm [v.1.]

The originalĀ DeepNude SoftwareĀ and all its safety measures have been violated and exposed by hackers. Two days after the launch, theĀ reverse engineeringĀ of the app was already on github. It is complete and runnable. So it no longer makes sense to hide the source code. The purpose of this repo is only to add technical information about the algorithm and is aimed at specialists and programmers, who have asked us to share the technical aspects of this creative tool.

DeepNude uses an interesting method to solve a typical AI problem, so it could be useful for researchers and developers working in other fields such asĀ fashion,Ā cinemaĀ andĀ visual effects.

Iā€™m sure that githubā€™s community can take the best from this controversial algorithm, and inspire other and better creative tools.

This repo contains only the core algorithm, not the user interface.

How DeepNude Algorithm works?

DeepNude uses a slightly modified version of theĀ pix2pixHDĀ GAN architecture. If you are interested in the details of the network you can study this amazing project provided by NVIDIA.

A GAN network can be trained using bothĀ pairedĀ andĀ unpairedĀ dataset. Paired datasets get better results and are the only choice if you want to get photorealistic results, but there are cases in which these datasets do not exist and they are impossible to create. DeepNude is a case like this. A database in which a person appears both naked and dressed, in the same position, is extremely difficult to achieve, if not impossible.

We overcome the problem using aĀ divide-et-imperaĀ approach. Instead of relying on a single network, we divided the problem into 3 simpler sub-problems:

  1. Generation of a mask that selects clothes.
  2. Generation of a abstract representation of anatomical attributes.
  3. Generation of the fake nude photo.

Original problem:

Divide-et-impera problem:

This approach makes the construction of the sub-datasets accessible and feasible. Web scrapers can download thousands of images from the web, dressed and nude, and through photoshop you can apply the appropriate masks and details to build the dataset that solve a particular sub problem. Working on stylized and abstract graphic fields the construction of these datasets becomes a mere problem of hours working on photoshop to mask photos and apply geometric elements. Although it is possible to use some automations, the creation of these datasets still require great and repetitive manual effort.

Computer Vision Optimization

To optimize the result, simple computer vision transformations are performed before each GAN phase, using OpenCV. The nature and meaning of these transformations are not very important, and have been discovered after numerous trial and error attempts.

Considering these additional transformations, and including the final insertion of watermarks, the phases of the algorithm are the following:

  • dress -> correctĀ [OPENCV]
  • correct -> maskĀ [GAN]
  • mask -> maskrefĀ [OPENCV]
  • maskref -> maskdetĀ [GAN]
  • maskdet -> maskfinĀ [OPENCV]
  • maskfin -> nudeĀ [GAN]
  • nude -> watermarkĀ [OPENCV]

Preparing environment

Before launch the script install these packages in yourĀ Python3Ā environment:

  • numpy
  • Pillow
  • setuptools
  • six
  • torch
  • torchvision
  • wheel
  • opencv-python

Install Models

To run the script you need the pythorch models: the large files (700MB) that are on the net (cm.lib,Ā mm.lib,Ā mn.lib). Put these file in a dir named:Ā checkpoints.

Launch the script

 python3 main.py

The script will transformĀ input.pngĀ toĀ output.png. The input.png should be 512pixel*512pixel.

Source ā€“ https://github.com/axuew/deepnude_official-master

How to lunch DeepNude Algorithm online

Use any of this tools ā€“ https://nudify.info/best-deepnude-app-examples/ every piece is tested and evaluated by us. We have already spent more than 200 hours testing them.

Leave a Reply

Your email address will not be published. Required fields are marked *

Exit mobile version