pythonpython-imaging-librarycaffedeep-dream

Deepdream python script not showing images


I have followed the guide at Link up until the

_=deepdream(net, img)

step. Now it runs without errors but it doesn't show the images. This is the output:

<IPython.core.display.Image object>
0 0 inception_4c/output (210, 373, 3)
<IPython.core.display.Image object>
0 1 inception_4c/output (210, 373, 3)
<IPython.core.display.Image object>
0 2 inception_4c/output (210, 373, 3)

It continues with similar output.

I can show a file with this code:

im = PIL.Image.open('sky1024px.jpg')
im.show()

But it doesn't work with the code that the guide provides. Only thing it seems strange is that f (StringIO) contains "garbage" when I print it using f.getvalue().

Any insight on why is it not showing the images?

EDIT: If I change the line (in showarray method)

PIL.Image.fromarray(a).save(f, fmt)

to

PIL.Image.fromarray(a).save('/home/jose/Downloads/deepdream/test', fmt)

It doesn't show the image but at least it is saving it in the specified folder.

EDIT 2: Changing the line

display(Image(data=f.getvalue()))

with

im = PIL.Image.open('/home/jose/Downloads/deepdream/test')

shows the image. Now the problem is that I can't close it so it shows one on top of the others.


Solution

  • Changing the line

    display(Image(data=f.getvalue()))
    

    with

    im = PIL.Image.open('/home/jose/Downloads/deepdream/test')
    

    shows the image. Now the problem is that I can't close it so it shows one on top of the others.