如何将重新训练的模型转换为tflite格式? [英] How to convert a retrained model to tflite format?
本文介绍了如何将重新训练的模型转换为tflite格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在MobileNet上训练了图像分类器模型,我有这些文件.
I have retrained an image classifier model on MobileNet, I have these files.
此外,我使用了toco压缩重新训练的模型,以将模型转换为.lite
格式,但是我需要使用.tflite
格式.无论如何,我可以从现有文件中获取tflite格式吗?
Further, I used toco to compress the retrained model to convert the model to .lite
format, but I need it in .tflite
format. Is there anyway I can get to tflite format from existing files?
推荐答案
这是一个简单的python脚本,可用于将.pb格式的图形转换为tflite.
Here is a simple python script which you can use to convert .pb format graph into tflite.
import tensorflow as tf
graph_def_file = "output_graph.pb" ##Your frozen graph
input_arrays = ["input"] ##Input Node
output_arrays = ["final_result"] ##Output Node
converter = tf.lite.TFLiteConverter.from_frozen_graph(graph_def_file, input_arrays, output_arrays)
tflite_model = converter.convert()
open("converted_model.tflite","wb").write(tflite_model)
这篇关于如何将重新训练的模型转换为tflite格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文