tensorflow

  • 注意点 1- 返回数据的解析

    1
    2
    scores = r.outputs['scores'].float_val
    lables = r.outputs['labels'].string_val
  • 注意点 2- 异常捕获

1
2
3
4
5
6
7
8
9
try:
r = classify(path + filename, server, port, timeout)
except grpc.RpcError as err:
status = 'error'
if err.code() == grpc.StatusCode.UNAVAILABLE:
msg = 'connect failed.'
except Exception as err:
status = 'error'
msg = 'grpc error: ' + err.code()
  • code = UNAVAILABLE 时,一般多是请求的地址有误,如端口错误,signature 错误等.