Python 如何将base64映像发送到gRPC tf服务服务器而不是http请求?

Python 如何将base64映像发送到gRPC tf服务服务器而不是http请求?,python,tensorflow,grpc,tfx,Python,Tensorflow,Grpc,Tfx,当我在tf中服务对象检测模型并通过http请求访问它时,我有一个工作代码。其代码为: import requests import base64 import json URL = "http://10.10.1.38:8501/v1/models/test_model:predict" headers = {"content-type": "application/json"} image = "test111.jpg" image_content = base64.b64encode(o

当我在tf中服务对象检测模型并通过http请求访问它时,我有一个工作代码。其代码为:

import requests
import base64
import json

URL = "http://10.10.1.38:8501/v1/models/test_model:predict" 
headers = {"content-type": "application/json"}
image = "test111.jpg"
image_content = base64.b64encode(open(image,'rb').read())
encodedStr = str(image_content, "utf-8")
body = {"signature_name": "predict_images","inputs": [{"b64":encodedStr}]}
response = requests.post(URL, data=json.dumps(body), headers = headers) 
我也希望这样做,但使用gRPC客户端代码

其代码为:

import grpc
from tensorflow_serving.apis import predict_pb2
from tensorflow_serving.apis import prediction_service_pb2_grpc

image = "test111.jpg"
image_content = base64.b64encode(open(image,'rb').read())
encodedStr = str(image_content, "utf-8")

server = 'localhost:8500'
channel = grpc.insecure_channel(server)
stub = prediction_service_pb2_grpc.PredictionServiceStub(channel)
request = predict_pb2.PredictRequest()
request.model_spec.name = 'test_model'
request.model_spec.signature_name = 'predict_images'
request.inputs['inputs'].CopyFrom(tf.contrib.util.make_tensor_proto(encodedStr, shape=[1]))
result_future = stub.Predict(request,40.)
但这是一个错误:

_Rendezvous: <_Rendezvous of RPC that terminated with:
status = StatusCode.INVALID_ARGUMENT
details = "assertion failed: [Unable to decode bytes as JPEG, PNG, GIF, or BMP]
[[{{node map/while/decode_image/cond_jpeg/cond_png/cond_gif/Assert_1/Assert}}]]"
debug_error_string = "{"created":"@1579785768.913000000","description":"Error received from peer","file":"src/core/lib/surface/call.cc","file_line":1017,"grpc_message":"assertion failed: [Unable to decode bytes as JPEG, PNG, GIF, or BMP]\n\t [[{{node map/while/decode_image/cond_jpeg/cond_png/cond_gif/Assert_1/Assert}}]]","grpc_status":3}"
>
\u集合地点:

我面临同样的问题,你能帮忙吗?我也面临同样的问题,你能帮忙吗。