【发布时间】:2020-06-03 10:49:06
【问题描述】:
我需要将图像(numpy 数组)、有关图像的其他元信息(例如高度、宽度等)从 python grpc 客户端传递到 python grpc 服务器。
我需要运行这个方法。
import numpy as np
def predict(img, w, h):
# some operations
return img.shape[2], np.mean(img)
我查看了文档,但 protobuf 中的 numpy 数组没有兼容的数据类型。
https://developers.google.com/protocol-buffers/docs/proto3
image_procedure.proto
syntax = "proto3";
// input image, width, height
message Image {
image_type image = 1;
int32 width = 2;
int32 height = 3;
}
// output prediction
message Prediction {
int32 channel = 4;
float mean = 5;
}
// service
service ImageProcedure {
rpc ImageMeanWH(Image) returns (Prediction) {}
}
如何将图像和其他相关数据发送到服务器并获得响应?
【问题讨论】: