Deepdream python 脚本不显示图像

Deepdream python script not showing images

我一直遵循 Link 的指南,直到

_=deepdream(net, img)

步骤。现在它运行没有错误,但它不显示图像。这是输出:

<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)

它继续类似的输出。

我可以用这段代码显示一个文件:

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

但它不适用于指南提供的代码。唯一奇怪的是 f (StringIO) 在我使用 f.getvalue().

打印时包含 "garbage"

对为什么不显示图像有任何见解吗?

编辑: 如果我更改行(在 showarray 方法中)

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

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

它不显示图像,但至少将其保存在指定的文件夹中。

编辑 2: 换行

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

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

显示图像。现在的问题是我无法关闭它,所以它会在其他上面显示一个。

换行

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

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

显示图像。现在的问题是我无法关闭它,所以它会在其他上面显示一个。