Studio 5

Google DeepDream Inception Image Processing

Google Deep Dream Generator

Installation of Google Deep Dream program is quite complicated. But there are online implmentations that let us upload an image, and utilize cloud computing servics to generate Deep Dream inceptions with them.

Go to the website for Google Deep Dream Generator: https://deepdreamgenerator.com//

1) Create an Account by clicking "Sign Up" in the top menu. If you already have an account, just "Log In".

2) Prepare your Image. Patience is the key. The code itself can take hours to run for all the layers of neural network to work its magic on your image. Start by choosing an image or two to work with, prefereably of small file size and low-resolution. You can take any image into Photoshop and reduce the number of pixels and save it to a new file name. You can also use Google Image Search, select "Tools", and select "Size" of "Icon" or "Medium", then download a small image.

3) Generate a Deep Dream by clicking the orange "Generate" at the top menu.

4) You can use a Pre-set "Deep Style" for your first attempt, but really you want to explore the settings and the different Incption layers. So try clicking the "Deep Dream" button on the style page, and the "Settings" drop-down menu that appears.

5) Try experimenting with different layers and settings. It takes a while to process each one, but you can setup few while you wait. Also, smaller images will process much faster.

6) Upload your best images to the blog!

RESOURCES

Source code if you want to take a look at it: https://github.com/google/deepdream

Documentation for Google Deep Dream Installation. This page has detailed instructions. Read through thoroughly and execute the steps. http://ryankennedy.io/running-the-deep-dream/

Installation Guide for Docker: https://docs.docker.com/docker-for-mac/

Overview of Steps

in case the above documentation is difficult to follow:

1. Download and Install https://download.docker.com/mac/stable/Docker.dmg

2. Open terminal and Run:

docker pull ryankennedyio/deepdream

3. Now we boot the container using this command

docker run -d -p 443:8888 -e "PASSWORD=password" -v /path/to/this/repository:/src ryankennedyio/deepdream

Special note:

path/to/this/repository
should be the location where you want to play with input images. In this case, that would be
/Users/ryankennedy/Pictures

This directory is being shared with the Docker container, so that you can access your input pictures.

•It could be possible that the port you are trying to access is already allocated. In that case, try using 4430 instead of 443.

•To check port allocation. Type into the terminal: docker ps

Example :

docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

f83ecdbb39e2 ryankennedyio/deepdream "/notebook.sh" About an hour ago Up 34 minutes 0.0.0.0:4430->8888/tcp confident_brown

b368985b4ac0 ryankennedyio/deepdream "/notebook.sh" 2 hours ago Up About an hour 0.0.0.0:443->8888/tcp clever_wozniak

Rahuls-Air:Pictures rahulgeorge33$ docker

Usage:docker COMMAND

We see that two ID's have been created for deepdream f83ecdbb39e2, b368985b4ac0. So, we need to stop one of them so that the docker is allocated to a single port. Below I have stopped both the dockers for fresh install.

docker stop

"docker stop" requires at least 1 argument(s).

See 'docker stop --help'.

Usage: docker stop [OPTIONS] CONTAINER [CONTAINER...]

Stop one or more running containers

docker stop b368985b4ac0

docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

f83ecdbb39e2 ryankennedyio/deepdream "/notebook.sh" About an hour ago Up 36 minutes 0.0.0.0:4430->8888/tcp confident_brown

docker stop f83ecdbb39e2

f83ecdbb39e2

4. Run the command below to boot the container once the ports are correctly allocated.

docker run -d -p 4430:8888 -e "PASSWORD=password" -v //Users/rahulgeorge33/Pictures:/src ryankennedyio/deepdream

5. Once this command has been completed successfully, Open Google Chrome and type in https://localhost:4430/ . This will generate python notebook (dream.ipnyb). Click on this link and you will see chunks of code Google Deep Dream program already imported. Benefit of using Python notebook is that, it is an easier way for execution as you can run the code in chunks as opposed to running 200 lines of code at once.

6. Now we input our image to test the deep dream code. Note: Make sure the path mentioned in the repository is correct and the image is mentioned in the exact folder or the docker will fail to bind. Provide the image name on this line of the code.

Code: img = np.float32(PIL.Image.open('/src/input1.jpg'))

showarray(img)

Replace ‘input1.jpg’ with your ‘image name’.

An example of how the path should be in the repository-

Location at the terminal:

//Users/rahulgeorge33/Pictures:/src

showarray(img)

Code: img = np.float32(PIL.Image.open('/src/input1.jpg'))

8. Run every instance (chunk of code) by clicking (Shift + Enter). You will see the processed image with each iteration. It takes quite some time to get the output image so, relax. Grab a coffee, and wait patiently for the deep dream to work. For me, the last iteration of the image took a LONG time (5+ hours). The final result is worth the wait though. To challenge the result further, you can play around with the parameters in the code, get some deep dreaming done and create your own customized images.

Goodluck!