keras .h5转移动端的.tflite文件

论坛 期权论坛 脚本     
匿名技术用户   2021-1-6 02:13   153   0

以前tensorflow有bug 在winodws下无法转,但现在好像没有问题了,代码如下

将keras 下的mobilenet_v2转成了tflite

from keras.backend import clear_session
import numpy as np
import tensorflow as tf
clear_session()
np.set_printoptions(suppress=True)
input_graph_name = "../models/weights.best_mobilenet224.h5"
output_graph_name = input_graph_name[:-3] + '.tflite'
converter = tf.lite.TFLiteConverter.from_keras_model_file(model_file=input_graph_name)
converter.post_training_quantize = True
#在windows平台这个函数有问题,无法正常使用
tflite_model = converter.convert()
open(output_graph_name, "wb").write(tflite_model)
print ("generate:",output_graph_name)
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP