32 lines
924 B
Python
32 lines
924 B
Python
|
|
import grpc
|
|
|
|
# import base64
|
|
|
|
from . import BeiHangGrpc_pb2_grpc
|
|
from . import BeiHangGrpc_pb2
|
|
|
|
|
|
if __name__ == "__main__":
|
|
IP = '127.0.0.1:9000'
|
|
|
|
channel = grpc.insecure_channel(IP) # 监听频道
|
|
stub = BeiHangGrpc_pb2_grpc.Helmet_RegStub(channel) # 客户端使用Stub类发送请求,参数为频道,为了绑定链接
|
|
image_id = 3
|
|
|
|
# 本地图像输入
|
|
# image_path = "./onnx/image/single3.jpg"
|
|
# with open(image_path, 'rb') as f:
|
|
# image_base64 = str(base64.b64encode(f.read()), encoding='utf-8')
|
|
# request = BeiHangGrpc_pb2.JinYu_Request(zzid=image_id,imgsbase64=image_base64)
|
|
|
|
# URL输入
|
|
imgUrl = "XXXXX.jpg"
|
|
request = BeiHangGrpc_pb2.JinYu_Request(zzid=image_id, imgUrl=imgUrl)
|
|
try:
|
|
response = stub.sendHelmet_Info(request)
|
|
print("network success! \n")
|
|
print(response)
|
|
except Exception:
|
|
print("network error! \n")
|