【问题标题】:Tensorflow Keras GCP ML engine model servingTensorFlow Keras GCP ML 引擎模型服务
【发布时间】:2018-06-11 10:59:24
【问题描述】:

我正在开发一个带有 tensorflow 估计器 + keras 的图像分类器,在 上重新训练预训练应用程序 inception_v3 的最后一层GCP 机器学习引擎

使用tf.keras.estimator.model_to_estimator导出keras模型,输入函数接收存储在GCP云存储上的图片路径tf.image.decode_jpeg打开图片,返回如下格式@的数据集987654324@

我正在尝试定义 tf.estimator.export.ServingInputReceiver,但在定义它时遇到了一些问题。

该模型使用不带标签的输入函数通过 predict 方法正确地提供预测。 我的想法是重用 input_function 来解码图像,仅将云存储上图像的路径传递给谷歌端点的预测,但我不明白该怎么做。

感谢您的帮助

【问题讨论】:

标签: tensorflow keras google-cloud-platform google-cloud-ml


【解决方案1】:

如果我理解正确,您的问题是如何从云存储中获取文件,考虑到您想以这种方式解码图像:

image_decoded = tf.image.decode_jpeg(image_string)

因此,在这种情况下,您可以使用:

image_string = file_io.FileIO(filename, mode='r')

先导入file_io:

from tensorflow.python.lib.io import file_io

根据the comments on this question about reading input data from GCS,使用 file_read 函数应该提供相同的结果,因为“已经完成了大量工作来抽象文件 io 和文件系统,因此所有 io 功能都可以始终如一地工作”。所以你也可以试试 read_file 函数。

【讨论】:

    猜你喜欢
    • 2017-12-18
    • 2019-10-05
    • 2017-09-24
    • 2018-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-21
    • 2019-04-20
    相关资源
    最近更新 更多