使用实例密钥进行带Tensorflow的批量预测 [英] Using Instance Keys for Batch Prediction w/Tensorflow

查看:95
本文介绍了使用实例密钥进行带Tensorflow的批量预测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试弄清楚如何使用Google Cloud进行批量预测.具体来说,我正在寻求对象检测,从更快的RCNN张量流ckpt到图形/保存的模型.

I am trying to figure out how to do batch prediction using Google Cloud. Specifically, I'm looking to do object detection, getting from a faster-RCNN tensorflow ckpt to a graph/saved model.

我的问题是我需要能够为输入图像恢复某种ID,也许是索引或文件名.由于此链接提到了使用实例密钥,以及唯一的

My issue is that I need to be able to recover some kind of ID for my input images, perhaps an index or a filename. I'm not entirely sure how to do this in my situation, since this link mentions using instance keys, and the only relevant examples I've found regarding instance keys use JSON as the input format. As I am supposed to use TFRecords for input to my saved model, this would seem to be an issue. I also consulted the prediction guide, but was still confused.

简而言之,对于我应该编辑哪些文件(export_inference_graph.py?)来保留输入图像的某些索引/顺序以进行批量预测,是否有人有任何提示?我正在使用对象检测API供参考.谢谢!

In short, does anybody have any tips as to what file(s) I should edit (export_inference_graph.py?) to preserve some sort of indices/ordering of my input images for batch prediction? I am using the Object Detection API for reference. Thanks!

推荐答案

批量预测本身不支持实例键.您必须更改推理图,才能从输入中输出某些内容作为键.这意味着您需要找到一种在输入中包括键的方法,例如图像ID或索引.一种方法是将输入从TFrecord更改为json并添加一个id作为键.例如,您现在输入的内容将是:

Batch Prediction doesn't support instance keys by itself. You have to change the inference graph to output something from input as keys. That means you need to find a way to include keys in your inputs such as image id or index. One way you can do it is to change your input from TFrecord to json and add a id as keys. E.g, your input now would be like:

{键":1,图像":{"b64":"base64encodedstringabce"}{"key":2,"image":{"b64":"base64encodedstringfg1d"}

{"key": 1, "image": {"b64": "base64encodedstringabce"} {"key": 2, "image": {"b64": "base64encodedstringfg1d"}

这当然会使您的输入更大.另一种方法是,如果在TFRecord中使用tf.Example原型,则可以添加额外的功能.它的值将是从输入到输出的直通字段.

This would of course make your input much larger. Another way is that if you use tf.Example proto in your TFRecord, you can add an extra feature. Its value would be a passthrough field from input to the output.

这是一种更改推理以将要素从输入传递到输出的方法. https://github.com/GoogleCloudPlatform/cloudml-samples/pull/158

Here is a way to change the inference to pass a feature from input to output. https://github.com/GoogleCloudPlatform/cloudml-samples/pull/158

这篇关于使用实例密钥进行带Tensorflow的批量预测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆