【发布时间】:2017-05-06 19:31:23
【问题描述】:
我想在 cloud-ml 中预测 jpeg 图像。
我的训练模型是 inception 模型,我想将输入发送到图的第一层:'DecodeJpeg/contents:0'(我必须发送 jpeg 图像)。我已通过添加retrain.py 将这一层设置为可能的输入:
inputs = {'image_bytes': 'DecodeJpeg/contents:0'}
tf.add_to_collection('inputs', json.dumps(inputs))
然后我将训练结果保存在两个文件(export 和 export.meta)中:
saver.save(sess, os.path.join(output_directory,'export'))
然后我使用这些文件在 cloud-ml 中创建了一个模型。
正如一些帖子(来自谷歌云官方博客的here、here 和here)中所建议的那样,我正在尝试使用
gcloud beta ml predict --json-instances=request.json --model=MODEL
其中实例是以 base64 格式解码的 jpeg 图像:
python -c 'import base64, sys, json; img = base64.b64encode(open(sys.argv[1], "rb").read()); print json.dumps({"key":"0", "image_bytes": {"b64": img}})' image.jpg &> request.json
但是请求返回我:
error: 'Prediction failed: '
我的程序有什么问题?你有什么建议吗? 我特别从this 帖子我假设cloud-ml 在读取带有image_bytes 的请求时会自动将base64 图像转换为jpeg 格式。这是正确的吗?不然怎么办?
【问题讨论】:
-
我可能需要更多信息来更好地帮助您。您介意将您的项目编号、型号和版本名称发送到 cloudml-feedback@google.com 吗?