deepdream img np expand_dims(imgaxis= img inception_v preprocess_input(imgreturn img def deprocess_image( )if image_data_format(='channels_first' reshape(( shape[ ] shape[ ]) transpose(( )elsex reshape(( shape[ ] shape[ ] ) / + * np clip( astype('uint 'return util function to convert tensor into valid image undoes preprocessing that was performed by inception_v preprocess_ input because the original inception network was trained to recognize concepts in images of size and given that the process involves scaling the images down by reasonable factorthe deepdream implementation produces much better results on images that are somewhere between and regardlessyou can run the same code on images of any size and any ratio note starting from photograph taken in the small hills between san francisco bay and the google campuswe obtained the deepdream shown in figure figure running he deepdream code on an example image we strongly suggest that you explore what you can do by adjusting which layers you use in your loss layers that are lower in the network contain more-localless-abstract representations and lead to dream patterns that look more geometric layers that are higher up lead to more-recognizable visual patterns based on the most common objects found in imagenetsuch as dog eyesbird feathersand so on you can use licensed to