ajbrock / Neural-Photo-Editor
- воскресенье, 25 сентября 2016 г. в 03:15:00
Python
A simple interface for editing natural photos with generative neural networks.
A simple interface for editing natural photos with generative neural networks.
This repository contains code for the paper "Neural Photo Editing with Introspective Adversarial Networks," and the Associated Video.
To run the Neural Photo Editor, you will need:
First, download the pre-trained IAN_simple model here.
This is a slimmed-down version of the IAN without MDC or RGB-Beta blocks, which runs without lag on a laptop GPU with ~1GB of memory (GT730M).
Then, run the command:
python NPE.py
If you wish to use a different model, simply edit the line with "config path" in the NPE.py file. You can make use of any model with an inference mechanism (VAE or ALI-based GAN).
You will need Fuel along with the 64x64 version of celebA. See here for instructions on downloading and preparing it.
If you wish to train a model, the IAN.py file contains the model configuration, and the train_IAN.py file contains the training code, which can be run like this:
python train_IAN.py IAN.py
By default, this code will save (and overwrite!) the weights to a .npz file with the same name as the config.py file (i.e. "IAN.py -> IAN.npz"), and will output a jsonl log of the training with metrics recorded after every chunk.
Use the --resume=True flag when calling to resume training a model--it will automatically pick up from the most recent epoch.
You can generate a sample and reconstruction+interpolation grid with:
python sample_IAN.py IAN.py
Note that you will need matplotlib. to do so.
Occasionally the color picker freaks out and returns "None"s rather than values. Simply re-choose a color to fix this.
More pre-trained models (which will be in the repo rather than a drive folder) and the remainder of the IAN experiments (including SVHN and the full pre-trained IAN used to generate the samples from the paper) coming soon.
This code contains lasagne layers and other goodies adopted from a number of places: