[英]how do i convert pb file to tf lite?
我正在使用 Inception v3 進行圖像分類,我重新訓練了 model,它生成了 2 個文件“retrained_graph.pb”和“retrained_lables”。
在 android 中使用它我想將它轉換為 tflite 文件所以我使用了這個代碼
import tensorflow as tf
from tensorflow import lite
converter = lite.TFLiteConverter.from_frozen_graph(
'retrained_graph.pb' ,'DecodeJpeg/contents', 'final_result')
tflite_model = converter.convert()
open("test.tflite", "wb").write(tflite_model)
我收到此錯誤
回溯(最近一次通話最后):
文件“tfconvert.py”,第 4 行,在 'retrained_graph.pb'、'DecodeJpeg/contents'、'final_result')
文件“C:\Users\Thakkar\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow_core\lite\python\lite.py”,第 705 行,from_frozen_graph sess.graph,input_arrays)文件“C :\Users\Thakkar\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow_core\lite\python\util.py",第 122 行,在 get_tensors_from_tensor_names",".join(invalid_tensors))) ValueError:找到了無效的張量 'D,e,c,o,d,e,J,p,e,g,/,c,o,n,t,e,n,t,s'。
您需要修復此處給出的 TFLite 轉換器代碼
converter = lite.TFLiteConverter.from_frozen_graph(
graph_def_file='retrained_graph.pb' ,
input_arrays=['DecodeJpeg/contents'],
output_arrays=['final_result']
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.