This repo hosts the code associated with the O'Reilly article, "Using Tensorflow to Generate Images with PixelRNNs: How to generate novel images using neural networks".
In this article, we walk through creating a generative model to produce realistic-looking images using recurrent neural networks in Tensorflow. Specifically, we use a PixelRNN architecture trained on MNIST to generate images that look like handwritten digits.
In order to run this notebook, you will need to install TensorFlow v1.0, Jupyter, and NumPy.
The notebook also uses TQDM to display nice progress bars during training.
There are two easy ways to install these libraries and their dependencies:
-
Download and unzip this entire repo from GitHub, either interactively, or by entering
git clone https://github.com/philkuz/PixelRNN.git
-
Open your terminal and use
cd
to navigate into the top directory of the repo on your machine -
To build the Dockerfile, enter
docker build -t pixelrnn_dockerfile .
If you get a permissions error on running this command, you may need to run it with
sudo
:sudo docker build -t pixelrnn_dockerfile .
-
Run Docker from the Dockerfile you've just built
docker run -it -p 8888:8888 -p 6006:6006 pixelrnn_dockerfile bash
or
sudo docker run -it -p 8888:8888 -p 6006:6006 pixelrnn_dockerfile bash
if you run into permission problems.
-
Launch Jupyter by entering
jupyter notebook
and, using your browser, navigate to the URL shown in the terminal output (usually http://localhost:8888/)
NumPy can be tricky to install manually, so we recommend using the managed Anaconda Python distribution, which includes NumPy, Matplotlib, and Jupyter in a single installation. The Docker-based method above is much easier, but if you have a compatible NVIDIA GPU, manual installation makes it possible to use GPU acceleration to speed up training.
-
Follow the installation instructions for Anaconda Python. We recommend using Python 3.6.
-
Follow the platform-specific TensorFlow installation instructions. Be sure to follow the "Installing with Anaconda" process, and create a Conda environment named
tensorflow
. -
If you aren't still inside your Conda TensorFlow environment, enter it by typing
source activate tensorflow
-
Install TQDM by entering
pip install tqdm
-
Download and unzip this entire repo from GitHub, either interactively, or by entering
git clone https://github.com/philkuz/PixelRNN.git
-
Use
cd
to navigate into the top directory of the repo on your machine -
Launch Jupyter by entering
jupyter notebook
and, using your browser, navigate to the URL shown in the terminal output (usually http://localhost:8888/)