如何解决具有GRPC授权的GCP ML Tensorflow
在为GCP上部署的ML模型设置GRPC时,我需要帮助。我已经部署了该模型,并希望使用GRPC为其提供服务,但无法找到有关如何执行该操作的任何文档。是否有人在下面提供任何信息:-
- 如何激活在ml.googleapis.com上部署的GRPC for TF服务模型?
- 使用具有授权的GRPC服务模型需要采取哪些步骤?
当前有足够的文档来处理JSON请求,但是这些请求变得非常大,我需要一种减小大小的替代方法,这就是为什么需要在其中查找更多文档的原因。现在我出错了
InactiveRpcError of RPC that terminated with:
status = StatusCode.UNKNOWN
details = "Stream removed"
让我知道您是否需要更多信息。
这是我正在使用的代码
from google import auth as google_auth
from google.auth.transport import requests as google_auth_transport_requests
from google.auth.transport import grpc as google_auth_transport_grpc
from tensorflow_serving.apis import predict_pb2
def _make_grpc_request(examples):
scoped_credentials,_ = google_auth.default(scopes=('https://www.googleapis.com/auth/cloud-platform',))
request = google_auth_transport_requests.Request()
channel = google_auth_transport_grpc.secure_authorized_channel(
scoped_credentials,request,'ml.googleapis.com:443')
"""Builds and sends request to TensorFlow model server."""
request = predict_pb2.PredictRequest()
request.model_spec.name = 'nudity2'
request.model_spec.signature_name = 'serving_default'
request.inputs["input"].CopyFrom(
tf.make_tensor_proto(examples))
p_s=PredictionServiceStub(channel)
response = p_s.Predict(request,1000)
response
return response
return _make_grpc_request
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。