Skip to content

Instantly share code, notes, and snippets.

@iandouglas
Created July 13, 2015 01:02
Show Gist options
  • Select an option

  • Save iandouglas/489f25362b3bb9c4d40f to your computer and use it in GitHub Desktop.

Select an option

Save iandouglas/489f25362b3bb9c4d40f to your computer and use it in GitHub Desktop.
deep dream
import shutil
!mkdir dreamed
frame_i = 0
for i in xrange(firstnum, secondnum):
img = np.float32(PIL.Image.open('/src/'+ str(i) +'.jpg'))
showarray(img)
frame = img
h, w = frame.shape[:2]
s = 0.05 # scale coefficient
frame = deepdream(net, img, end='inception_4c/output')
PIL.Image.fromarray(np.uint8(frame)).save("dreamed/" + str(i) + ".jpg")
frame = nd.affine_transform(frame, [1-s, 1-s, 1], [h/s/2, w/s/2, 0], order=1)
frame_i += 1
shutil.copy('dreamed/' + str(i) + '.jpg', '/src/done')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment