为TensorFlow Serving REST API生成实例或输入 [英] Generate instances or inputs for TensorFlow Serving REST API
问题描述
我准备尝试基于已保存的模型试用TensorFlow Serving REST API,并且想知道是否存在一种简单的方法来生成需要与之一起发送的JSON实例(基于行)或输入(列)我的请求.
I'm ready to try out my TensorFlow Serving REST API based on a saved model, and was wondering if there was an easy way to generate the JSON instances (row-based) or inputs (columnar) I need to send with my request.
我的模型中有数千个功能,我不希望手动输入JSON.有没有一种方法可以使用现有数据来提供可用于预测API的序列化数据?
I have several thousand features in my model and I would hate to manually type in a JSON. Is there a way I can use existing data to come up with serialized data I can throw at the predict API?
我在整个管道(包括tf.Transform)中都使用了TFX,所以我不确定是否可以使用TFX内建的整洁方法.
I'm using TFX for the entire pipeline (incl. tf.Transform), so I'm not sure if there is a neat way built into TFX I can use.
saved_model_cli
的输出是这样的:
The given SavedModel SignatureDef contains the following input(s):
inputs['examples'] tensor_info:
dtype: DT_STRING
shape: (-1)
name: input_example_tensor:0
没有告诉我太多.
推荐答案
您可以使用Python REST客户端以编程方式进行调用,而无需手动编写请求.这是tensorflow_serving github中的示例代码:
You can use a Python REST client to make the call programatically, instead of manually composing the request. This is a sample code in tensorflow_serving github:
https://github.com/tensorflow/serving/blob/master/tensorflow_serving/example/resnet_client.py
这篇关于为TensorFlow Serving REST API生成实例或输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!