1

当我将这里的所有代码写入一个.py文件,然后运行它时,我得到以下输出:

can't determine number of CPU cores: assuming 4
I tensorflow/core/common_runtime/local_device.cc:25] Local device intra op         parallelism threads: 4
can't determine number of CPU cores: assuming 4
I tensorflow/core/common_runtime/local_session.cc:45] Local session inter op     parallelism threads: 4
<IPython.core.display.Image object>
<IPython.core.display.Image object>
<IPython.core.display.Image object>
<IPython.core.display.Image object>
<IPython.core.display.Image object>
<IPython.core.display.Image object>
<IPython.core.display.Image object>
<IPython.core.display.Image object>
<IPython.core.display.Image object>
<IPython.core.display.Image object>
<IPython.core.display.Image object>
<IPython.core.display.Image object>
<IPython.core.display.Image object>
<IPython.core.display.Image object>
<IPython.core.display.Image object>
<IPython.core.display.Image object>
<IPython.core.display.Image object>
<IPython.core.display.Image object>
<IPython.core.display.Image object>
<IPython.core.display.Image object>
<IPython.core.display.Image object>

但是,它实际上并不显示图像。我怎样才能看到实际的图像?

4

1 回答 1

2

本教程中的这段代码是为粘贴到 IPython 中而设计的。如果您在笔记本中运行它,<IPython.core.display.Image object>字符串将被替换为模拟当前状态的图像。

另一种方法是生成包含相同数据的图像文件。例如,您可以替换以下代码:

f = StringIO()
PIL.Image.fromarray(a).save(f, fmt)
display(Image(data=f.getvalue()))

...使用一些将图像写入文件的代码:

with open("/tmp/image.jpg", "w") as f:
  PIL.Image.fromarray(a).save(f, "jpeg")

...然后/tmp/image.jpg在您喜欢的图像查看器中打开文件。

于 2015-11-13T18:01:43.910 回答