加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
tf_sevring_warmup.py 970 Bytes
一键复制 编辑 原始数据 按行查看 历史
verages 提交于 2021-07-08 15:26 . Add files via upload
# coding=utf-8
import tensorflow as tf
from tensorflow_serving.apis import predict_pb2
from tensorflow_serving.apis import prediction_log_pb2
from data import img_data
from config import image_path
def main():
# Build a batch of images.
image_data = img_data(image_path)
imag_data = []
for i in range(len(image_data)):
imag_data.append(image_data[i].numpy().tolist())
with tf.io.TFRecordWriter("tf_serving_warmup_requests") as writer:
request = predict_pb2.PredictRequest()
request.model_spec.name = 'model1'
request.model_spec.signature_name = 'serving_default'
request.inputs['input_1'].CopyFrom(
tf.make_tensor_proto(imag_data, shape=[len(imag_data),224,224,3]))
log = prediction_log_pb2.PredictionLog(
predict_log=prediction_log_pb2.PredictLog(request=request))
writer.write(log.SerializeToString())
if __name__ == "__main__":
main()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化