Google Cloud ML Engine:如何创建接收图像 float32 格式的任务

Google Cloud ML Engine: How to create task receiving an image float32 format

我是 Google Cloud ML Engine 的新手。我正在部署我的第一个模型,并训练了一个接收 float32 格式图像的模型。我正在关注 ML Engine 教程,但他们使用 base64 对图像进行编码。有没有办法使用 float32 对其进行编码?或者我可以创建一个 float32 中的任务吗?

python -c 'import base64, sys, json; img = base64.b64encode(open(sys.argv[1], "rb").read()); print json.dumps({"inputs": {"key":"0", "image_bytes": {"b64": im g}}})' flower.jpg &> request.json

有多种方法可以对图像数据进行编码,其中一些方法比其他方法更有效。 this answer 中概述了这些内容。您正在寻找 "Raw Tensor Encoded AS JSON" 部分,它展示了如何导出模型以及如何构建 JSON。还请考虑在 JSON 中使用浮点数的低效率权衡,并考虑替代方法。