Gcloud FileNotFound-ML引擎

时间:2018-07-03 08:42:59

标签: tensorflow google-cloud-storage google-cloud-ml

我正在尝试对Google Cloud ML Engine进行预测。我已将输入上传到Google Cloud Storage的存储桶中。我正在使用以下标志:

--file='gs://MyBucket/Photo/example3.jpg'

我也尝试过:

--file=gs://MyBucket/Photo/example3.jpg

在我的python应用程序中,我以这种方式打开图像:

image = misc.imread(filename)

但是该任务会产生以下错误:

 "FileNotFoundError: [Errno 2] No such file or directory: 'gs://MyBucket/Photo/example3.jpg'"  

我不知道Google Cloud Storage权限或打开图像的方式是否有问题。

提前谢谢!

1 个答案:

答案 0 :(得分:0)

要从Google云存储中读取图像文件,请使用tensorflow代码,因为本地Python无法从blob存储中读取图像:

image_contents = tf.read_file(filename)
image = tf.image.decode_jpeg(image_contents, channels=3)
image = tf.image.convert_image_dtype(image, dtype=tf.float32) # 0-1