Google Cloud ML scipy.misc.imread返回< PIL.JpegImagePlugin.JpegImageFile> [英] Google Cloud ML scipy.misc.imread returning <PIL.JpegImagePlugin.JpegImageFile>
问题描述
导入tensorflow为tf
导入scipy.misc
from tensorflow.python.lib.io import file_io
file = file_io.FileIO('gs://BUCKET/data/celebA/000007.jpg',mode ='r')
img = scipy.misc.imread(file)
如果我在Cloud Console中运行该代码段,返回一个适当的数组。但是,当相同片段在Cloud ML中运行时,img对象是
< PIL.JpegImagePlugin.JpegImageFile image mode = RGB size = 178x218 at 0x7F1F8F26DA10>
这个stackoverflow答案建议在安装PIL时没有安装libjpeg。 Cloud ML Runtime版本列表显示,对于Tensorflow 0.12,libjpeg-dev是一个已安装的debian软件包。
我能够在Cloud ML上重现此问题,是Tensorflow 0.12.1中file_io版本的问题,如果安装了Tensorflow 1.0,则会消失。
如果可以,请升级到TF的1.0版本。
如果您需要0.12版本,Cloud ML0.12运行时使用TF的官方0.12.1版本,但您可以上传自己的版本以安装if你喜欢。我没有准确追踪问题的解决时间,但是从2月2日起 Nightly Tensorflow似乎工作。
I am running the following snippet:
import tensorflow as tf
import scipy.misc
from tensorflow.python.lib.io import file_io
file = file_io.FileIO('gs://BUCKET/data/celebA/000007.jpg', mode='r')
img = scipy.misc.imread(file)
If I run that snippet in Cloud Console, I get back a proper array. But when that same snippet runs in Cloud ML, the img object is
<PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=178x218 at 0x7F1F8F26DA10>
This stackoverflow answer suggests that libjpeg was not installed when PIL was installed. The Cloud ML Runtime Version list shows that for Tensorflow 0.12, libjpeg-dev is an installed debian package.
I was able to reproduce this issue on Cloud ML, and it seems to be an issue with the version of file_io in Tensorflow 0.12.1, and goes away if Tensorflow 1.0 is installed.
If you can, upgrade to the 1.0 build of TF.
If you need a 0.12 version, the Cloud ML "0.12" runtime uses the official 0.12.1 build of TF, but you can upload your own version to install if you like. I did not track down exactly when the issue was fixed but a Nightly Tensorflow build from Feb 2nd seemed to work.
这篇关于Google Cloud ML scipy.misc.imread返回< PIL.JpegImagePlugin.JpegImageFile>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!