1 Star 6 Fork 0

shibwoen/stm32_tensorflow

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
pb_tflite.py 718 Bytes
一键复制 编辑 原始数据 按行查看 历史
尖头史 提交于 2021-11-20 00:15 +08:00 . shibowen
import tensorflow as tf
import os
# 采用1号GPU,单GPU可注释
os.environ["CUDA_VISIBLE_DEVICES"] = "1"
# 输入pb模型的路径
input_pb_path = "model/pb/pb_model.pb"
# 输出tflie模型的路径
out_tflie_path = "model/tflite/tflite_model.tflite"
# 模型输入节点
input_tensor_name = ["x"]
input_tensor_shape = {input_tensor_name[0]:[1,4]}
# 模型输出节点
out_tensor_name = ['o']
converter = tf.lite.TFLiteConverter.from_frozen_graph(
input_pb_path,
input_tensor_name,
out_tensor_name,
input_tensor_shape)
converter.allow_custom_ops=True
converter.post_training_quantize = True
tflite_model = converter.convert()
open(out_tflie_path, "wb").write(tflite_model)
print('转换结束')
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/shibwoen/stm32_tensorflow.git
git@gitee.com:shibwoen/stm32_tensorflow.git
shibwoen
stm32_tensorflow
stm32_tensorflow
master

搜索帮助