在modelarts上部署backend为TensorFlow的keras模型
最近老山在研究在modelarts上部署mask-rcnn,源代码提供的是keras模型。我们可以将keras转化成savedModel模型,在TensorFlow Serving上部署,可参考老山的上篇部署文章。至于输入和输出张量,到已经预先存在model.input和model.output中了。
不多说,直接上代码。
from keras import backend as K
import tensorflow as tf
# 在此之前,先加载keras模型
# 。。。
# 加载完成
with K.get_session() as sess:
export_path = './saved_model'
builder = tf.saved_model.builder.SavedModelBuilder(export_path)
signature_inputs = {
'input_image': tf.saved_model.utils.build_tensor_info(model.input[0]),
'input_image_meta': tf.saved_model.utils.build_tensor_info(model.input[1]),
'input_anchors': tf.saved_model.utils.build_tensor_info(model.input[2]),
}
signature_outputs = {
'mrcnn_detection':tf.saved_model.utils.build_tensor_info(model.output[0]),
'mrcnn_class':tf.saved_model.utils.build_tensor_info(model.output[1]),
'mrcnn_bbox':tf.saved_model.utils.build_tensor_info(model.output[2]),
'mrcnn_mask':tf.saved_model.utils.build_tensor_info(model.output[3]),
'ROI':tf.saved_model.utils.build_tensor_info(model.output[4]),
'rpn_class':tf.saved_model.utils.build_tensor_info(model.output[5]),
'rpn_bbox':tf.saved_model.utils.build_tensor_info(model.output[6]),
}
classification_signature_def = tf.saved_model.signature_def_utils.build_signature_def(
inputs=signature_inputs,
outputs=signature_outputs,
method_name=tf.saved_model.signature_constants.PREDICT_METHOD_NAME)
builder.add_meta_graph_and_variables(
sess,
[tf.saved_model.tag_constants.SERVING],
signature_def_map={
'root': classification_signature_def
},
)
builder.save()
作者:山找海味
在modelarts上部署backend为TensorFlow的keras模型的更多相关文章
- 在modelarts上部署mask-rcnn模型
最近老山完成了对mask-rcnn在modelarts上的部署,部署模型来自于这个项目.部署的过程大体和我的上篇文章使用modelarts部署bert命名实体识别模型相似,许多细节也不在赘述.这篇文章 ...
- Sklearn,TensorFlow,keras模型保存与读取
一.sklearn模型保存与读取 1.保存 from sklearn.externals import joblib from sklearn import svm X = [[0, 0], [1, ...
- Tensorflow 模型线上部署
获取源码,请移步笔者的github: tensorflow-serving-tutorial 由于python的灵活性和完备的生态库,使得其成为实现.验证ML算法的不二之选.但是工业界要将模型部署到生 ...
- 如何一步步在生产环境上部署django和vue
本文由云+社区发表 本文主要讲述了如何一步步在生产环境上部署django和vue,操作系统默认为centos 说明:后文中出现的以下字符串均表示具体的路径或者名称,含义如下: DJANGO_DIR-- ...
- CentOS7服务器上部署深度/机器学习环境推荐首选anaconda3
CentOS7服务器上部署深度/机器学习环境推荐首选anaconda3,亲测~~ 因为可以创建不同的环境版本或虚拟环境 CentOS7服务器安装anaconda3后,CentOS7服务器开启后自动将a ...
- (转)Centos7上部署openstack ocata配置详解
原文:http://www.cnblogs.com/yaohong/p/7601470.html 随笔-124 文章-2 评论-82 Centos7上部署openstack ocata配置详解 ...
- 139、TensorFlow Serving 实现模型的部署(二) TextCnn文本分类模型
昨晚终于实现了Tensorflow模型的部署 使用TensorFlow Serving 1.使用Docker 获取Tensorflow Serving的镜像,Docker在国内的需要将镜像的Repos ...
- 在CentOS上部署kubernetes1.9.0集群
原文链接: https://jimmysong.io/kubernetes-handbook/cloud-native/play-with-kubernetes.html (在CentOS上部署kub ...
- 在k8s上部署日志系统elfk
日志系统elfk 前言 经过上周的技术预研,在本周一通过开会研究,根据公司的现有业务流量和技术栈,决定选择的日志系统方案为:elasticsearch(es)+logstash(lo)+filebea ...
随机推荐
- CSPS_108
二逼出题人写错T1题面&&写伪T3std祭
- 使用Typescript重构axios(四)——实现基础功能:处理post请求参数
0. 系列文章 1.使用Typescript重构axios(一)--写在最前面 2.使用Typescript重构axios(二)--项目起手,跑通流程 3.使用Typescript重构axios(三) ...
- 14 Zabbix4.4.0系统实现监控checkpoint设备
点击返回:自学Zabbix之路 点击返回:自学Zabbix4.0之路 点击返回:自学zabbix集锦 14 Zabbix4.4.0系统实现监控checkpoint设备 1. 前期规划信息 2. 配置 ...
- systemd 服务管理编写
1.编辑服务管理脚本 $ cat /lib/systemd/system/kafka.service [Unit] Description=Kafka Server Documentation=htt ...
- 并发编程-硬件加持的CAS操作够快么?
Talk is cheap CAS(Compare And Swap),即比较并交换.是解决多线程并行情况下使用锁造成性能损耗的一种机制,CAS操作包含三个操作数--内存位置(V).预期原值(A)和新 ...
- pat 1136 A Delayed Palindrome(20 分)
1136 A Delayed Palindrome(20 分) Consider a positive integer N written in standard notation with k+1 ...
- Centos内核参数优化
关于内核参数优化 net.ipv4.tcp_max_tw_buckets = 6000 net.ipv4.ip_local_port_range = 1024 65000 net.ipv4.tcp_ ...
- 使用C#+FFmpeg+DirectX+dxva2硬件解码播放h264流
本文门槛较高,因此行文看起来会乱一些,如果你看到某处能会心一笑请马上联系我开始摆龙门阵 如果你跟随这篇文章实现了播放器,那你会得到一个高效率,低cpu占用(单路720p视频解码播放占用1%左右cpu) ...
- linux后台运行程序--nobup
用途:不挂断地运行命令. 语法:nohup Command [ Arg - ] [ & ] 描述:nohup 命令运行由 Command 参数和任何相关的 Arg 参数指定的命令,忽略所有挂断 ...
- canvas入门,就是这个feel!
钙素 Canvas 是在HTML5中新增的标签用于在网页实时生成图像,并且可以操作图像内容,基本上它是一个可以用JavaScript操作的位图.也就是说我们将通过JS完成画图而不是css. canva ...