r/deepdream • • Jul 06 '15

Smiley implodes (testing pixelated shapes)

http://imgur.com/2F4IBhj
576 Upvotes

22 comments sorted by

View all comments

Show parent comments

14

u/zcxhcrjvkbnpnm Jul 06 '15

I installed the package by ryankennedy following his instructions and it kind of worked. The last example of code provided in that Python Notebook launches a loop where the image is zoomed in slightly after each iteration and each frame is saved into a file.

I think the only alteration I made to that code was to change the file paths so that it loaded my image instead of the default one and saved the output frames in the same directory (/src/) instead of creating a new one somewhere.

Here's how the code looked (to be run after launching the four topmost code blocks in the Python Notebook, which are necessary to, umm, initialize the system):

frame = np.float32(PIL.Image.open('/src/smiley.jpg'))
frame_i = 0

h, w = frame.shape[:2]
s = 0.05 # scale coefficient

for i in xrange(100):
    frame = deepdream(net, frame)
    PIL.Image.fromarray(np.uint8(frame)).save("/src/smiley-%04d.png"%frame_i)
    frame = nd.affine_transform(frame, [1-s,1-s,1], [h*s/2,w*s/2,0], order=1)
    frame_i += 1

After it rendered about a hundred frames, I joined them into a video using Photoshop (I'm sure it's not the most efficient/accessible solution, but I'm a Photoshop user so I couldn't think of anything quicker). Then I uploaded the video to imgur.

2

u/potatoclump Jul 07 '15

you are great, thanks. i have been using his code package for still images i guess i just hadn't gotten to the last bit yet.. my fault. thanks again!