1 Star 6 Fork 0

shibwoen/stm32_tensorflow

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
ckpt_pb.py 806 Bytes
一键复制 编辑 原始数据 按行查看 历史
尖头史 提交于 2021-11-20 00:15 +08:00 . shibowen
import tensorflow as tf
import os
from tensorflow.python.framework import graph_util
# 采用4号GPU,单GPU可注释
os.environ["CUDA_VISIBLE_DEVICES"] = "4"
# 输入ckpt模型路径
input_ckpt_path = 'model/ckpt/model-9000'
# 输出pb模型的路径
out_pb_path = "model/pb/pb_model.pb"
# 初始化
output_node_names = "o"
saver = tf.train.import_meta_graph(input_ckpt_path+'.meta', clear_devices=True)
with tf.Session() as sess:
saver.restore(sess, input_ckpt_path)
output_graph_def = tf.compat.v1.graph_util.convert_variables_to_constants(
sess=sess,
input_graph_def=sess.graph_def,
output_node_names=output_node_names.split(","))
with tf.io.gfile.GFile(out_pb_path, "wb") as f:
f.write(output_graph_def.SerializeToString())
print('转换结束')
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/shibwoen/stm32_tensorflow.git
git@gitee.com:shibwoen/stm32_tensorflow.git
shibwoen
stm32_tensorflow
stm32_tensorflow
master

搜索帮助