This project is a web interface for Google DeepDream, implementing with TensorFlow and Flask. It helps you easily deploy the fantastic service on your server.
Here is a demo. (Tsinghua University network users only)
DeepDream is a Convolutional Neural Network (CNN) image generation technique. Through it, we can visualize individual feature channels and their combinations to explore the space of patterns learned by the neural network. Here we also apply Laplacian Pyramid Gradient Normalization to produce smooth and colorful visuals at low cost. For more details, please read Google Research Blog and TensorFlow tutorial.
- Python 2.7 or 3.5
- TensorFlow (>= r0.7)
- NumPy
- PIL
- Flask (also with Flask-Bootstrap)
Before running the code, put the neural network model in models/
folder.
(Check this document for help.)
Make sure the model file is ready first!
You can simply use dream.py
to generate DeepDream-like images in the command line.
python dream.py -l layer_name -i image_file -o output_file
Feel free to play with other optional arguments:
python dream.py -h
Number of layers: 59
Total number of feature channels: 7548
usage: dream.py [-h] [-l LAYER] [-i IMAGE] [-o OUTPUT] [--lap LAP_N]
[--iter ITER_N] [--step STEP] [--octave OCTAVE_N]
[--scale OCTAVE_SCALE]
optional arguments:
-h, --help show this help message and exit
-l LAYER, --layer LAYER
layer name
-i IMAGE, --image IMAGE
source image
-o OUTPUT, --output OUTPUT
output file
--lap LAP_N lap_n (0 for not using Laplacian pyramid)
--iter ITER_N iter_n
--step STEP step
--octave OCTAVE_N octave_n
--scale OCTAVE_SCALE octave_scale
If you use the default (Google's) model, all of the layer names are listed here.
example.py
will show you how to use those functions in a Python environment.
Running the following command will create a web service on your server.
python webapp.py