2018-02-09 17:46:53 +00:00
# DeepMindBreak
2018-02-10 04:06:25 +00:00
*Decensoring Hentai with Deep Neural Networks*
2018-02-11 05:50:40 +00:00
This project applies an implementation of [Globally and Locally Consistent Image Completion ](http://hi.cs.waseda.ac.jp/%7Eiizuka/projects/completion/data/completion_sig2017.pdf ) to the problem of hentai decensorship. Using a deep fully convolutional neural network, DeepMindBreak can replace censored artwork in hentai with plausible reconstructions. The user needs to only specify the censored regions.
2018-02-10 03:36:07 +00:00
2018-02-12 04:29:10 +00:00
# **THIS PROJECT IS STILL IN DEVELOPMENT. DO NOT BE DISAPPOINTED IF THE RESULTS AREN'T AS GOOD AS YOU EXPECT.**
2018-02-11 21:41:07 +00:00
2018-02-11 19:12:38 +00:00
![Censored, decensored ](/readme_images/collage.png )
2018-02-11 18:57:44 +00:00
2018-02-10 03:36:07 +00:00
# Limitations
2018-02-11 05:50:40 +00:00
This project is LIMITED in capability. It is a proof of concept of ongoing research.
2018-02-10 03:36:07 +00:00
2018-02-17 03:36:33 +00:00
The decensorship is intended to ONLY work on color hentai images that have minor bar censorship of the penis or vagina.
2018-02-10 03:36:07 +00:00
It does NOT work with:
- Black and white images
2018-02-11 19:16:39 +00:00
- Monochrome images
- Hentai containing screentones (e.g. printed hentai)
2018-02-10 03:36:07 +00:00
- Real life porn
- Mosaic censorship
- Censorship of nipples
2018-02-11 19:16:39 +00:00
- Censorship of anus
2018-02-10 03:37:39 +00:00
- Animated gifs/videos
2018-02-10 00:48:37 +00:00
2018-02-11 05:50:40 +00:00
In particular, if a vagina or penis is completely censored out, inpainting will be ineffective.
2018-02-10 03:55:29 +00:00
2018-02-10 00:48:37 +00:00
# Dependencies
2018-02-12 17:30:15 +00:00
- Python 2/3
2018-02-10 00:48:37 +00:00
- TensorFlow 1.5
2018-02-10 03:16:21 +00:00
- Pillow
2018-02-10 04:01:07 +00:00
- tqdm
2018-02-17 19:42:59 +00:00
- scipy
2018-03-15 20:32:56 +00:00
- pyamg
2018-02-11 05:50:40 +00:00
- matplotlib (only for running test.py)
2018-02-10 00:48:37 +00:00
2018-03-15 20:35:33 +00:00
No GPU required! Tested on Ubuntu 16.04 and Windows. (Tensorflow on Windows is compatible with Python 3 and not Python 2.)
2018-02-12 16:00:34 +00:00
2018-02-12 17:30:15 +00:00
Poisson blending is disabled by default since it has little effect on output quality.
Pillow, tqdm, scipy, pyamg, and matplotlib can all be installed using pip.
2018-02-12 16:00:34 +00:00
2018-02-10 00:48:37 +00:00
# Model
2018-03-15 01:35:53 +00:00
Pretrained models can be downloaded from https://drive.google.com/open?id=1KveQ0aaye3tdlB7JR9bFEqMk1Lqp8GyC.
2018-02-10 00:48:37 +00:00
2018-02-11 20:12:57 +00:00
Unzip the contents into the /models/ folder.
2018-06-21 00:18:53 +00:00
# Usage (Outdated. Will be rewritten.)
2018-02-12 14:01:14 +00:00
2018-06-21 00:18:53 +00:00
## I. Decensoring hentai
2018-02-10 01:51:41 +00:00
2018-02-11 20:12:57 +00:00
![Guide ](/readme_images/guide.png )
2018-02-10 03:16:21 +00:00
The decensorship process is fairly involved. A user interface will eventually be released to streamline the process.
2018-02-10 01:51:41 +00:00
2018-03-08 20:11:51 +00:00
Using image editing software like Photoshop or GIMP, paint the areas you want to decensor the color with RGB values of (0,255,0). You can change the mask color in config. For each censored region, crop 128 x 128 size images containing the censored regions from your images and save them as new ".png" images.
2018-02-10 03:16:21 +00:00
2018-04-11 22:12:28 +00:00
Move the cropped images to the "decensor_input" directory. Decensor the images by running
2018-02-10 03:16:21 +00:00
```
$ python decensor.py
```
2018-04-11 22:12:28 +00:00
Decensored images will be saved to the "decensor_output" directory. Paste the decensored images back into the original image.
2018-02-10 03:16:21 +00:00
2018-02-11 05:50:40 +00:00
## II. Train the pretrained model on custom dataset
2018-02-10 02:03:26 +00:00
2018-02-25 14:56:51 +00:00
You must have a GPU for training since training on a CPU will take weeks.
Your custom dataset should be 128 x 128 images of uncensored vaginas and penises cropped from hentai. The more images, the better: I used 70,000 images for training. Censoring these images yourself is unnecessary.
2018-02-26 15:47:10 +00:00
Put your custom dataset for training in the "training_data/images" directory and convert images to npy format.
2018-02-10 02:03:26 +00:00
```
2018-02-11 05:51:23 +00:00
$ cd training_data
2018-02-10 02:03:26 +00:00
$ python to_npy.py
```
2018-02-25 14:56:51 +00:00
To train, run
2018-02-10 03:19:30 +00:00
```
$ python train.py
```
2018-02-27 02:07:13 +00:00
If desired, you can train the pretrained model on your custom dataset by running
```
$ python train.py --continue_training=True
```
2018-02-25 14:56:51 +00:00
2018-02-22 03:38:08 +00:00
Training can be done separately for mosaics with train_mosaic.py, but decensor.py is not yet compatible with mosaic decensorship models.
2018-02-10 00:48:37 +00:00
# To do
2018-02-12 17:49:58 +00:00
- ~~Add Python 3 compatibility~~
2018-02-22 03:38:08 +00:00
- ~~Add random rotations in cropping rectangles~~
2018-03-15 01:35:53 +00:00
- ~~Retrain for arbitrary shape censors~~
2018-02-10 00:48:37 +00:00
- Add a user interface
- Incorporate GAN loss into training
2018-02-17 04:44:32 +00:00
- Update the model to the new version
2018-02-10 00:48:37 +00:00
2018-02-26 15:47:46 +00:00
Contributions are welcome! Special thanks to StartleStars for contributing code for mosaic decensorship.
2018-02-10 02:25:48 +00:00
2018-02-10 00:48:37 +00:00
# License
2018-03-19 16:21:36 +00:00
This code is for personal use and research use only.
2018-02-11 19:00:58 +00:00
Example image by dannychoo under [CC BY-NC-SA 2.0 License ](https://creativecommons.org/licenses/by-nc-sa/2.0/ ). The example image is modified from the original, which can be found [here ](https://www.flickr.com/photos/dannychoo/16081096643/in/photostream/ ).
2018-03-08 19:45:19 +00:00
Model is licensed under CC BY-NC-SA 4.0 License.
2018-02-10 01:44:21 +00:00
2018-03-08 19:45:19 +00:00
Code is licensed under CC BY-NC-SA 4.0 License and is modified from tadax's project [Globally and Locally Consistent Image Completion with TensorFlow ](https://github.com/tadax/glcic ) and shinseung428's project [https://github.com/shinseung428/GlobalLocalImageCompletion_TF], which are implementations of the paper [Globally and Locally Consistent Image Completion ](http://hi.cs.waseda.ac.jp/%7Eiizuka/projects/completion/data/completion_sig2017.pdf ). It also has a modified version of parosky's project [poissonblending ](https://github.com/parosky/poissonblending ).
2018-02-10 06:58:40 +00:00
2018-03-15 20:29:31 +00:00
```
# Copyright (c) 2018, deeppomf. All rights reserved.
#
2018-03-15 20:35:33 +00:00
# This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike
2018-03-15 20:29:31 +00:00
# 4.0 International License. To view a copy of this license, visit
# https://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
```
2018-03-15 20:00:13 +00:00
```
2018-03-15 20:32:56 +00:00
# Copyright (c) 2018 tadax, Seung Shin, parosky
2018-03-15 19:56:42 +00:00
#
2018-03-15 20:32:56 +00:00
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
2018-03-15 19:56:42 +00:00
#
2018-03-15 20:32:56 +00:00
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
2018-03-15 19:56:42 +00:00
#
2018-03-15 20:32:56 +00:00
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
2018-03-19 16:21:36 +00:00
```