胡說(shuō)叔叔
2021-11-16 14:53:40
我嘗試將凍結(jié)的 SSD mobilenet v2 模型轉(zhuǎn)換為 TFLITE 格式以供 Android 使用。這是我所有的步驟:我使用來(lái)自模型動(dòng)物園的ssd_mobilenet_v2_coco_2018_03_29模型使用TF Object Detection API的 train.py 文件重新訓(xùn)練。(好的)使用同樣由 TF Object Detection API 提供的export_inference_graph.py將訓(xùn)練好的 model.ckpt 導(dǎo)出到凍結(jié)的模型文件。(好的)使用 GPU 測(cè)試 Python 中的凍結(jié)圖,并且僅允許使用 CPU。有用。(好的)缺點(diǎn)是,我嘗試使用以下代碼:import tensorflow as tftf.enable_eager_execution()saved_model_dir = 'inference_graph/saved_model/'converter = tf.contrib.lite.TFLiteConverter.from_saved_model(saved_model_dir,input_arrays=input_arrays,output_arrays=output_arrays,input_shapes={"image_tensor": [1, 832, 832, 3]})converter.post_training_quantize = True首先,我嘗試不向函數(shù)添加輸入形狀參數(shù),但沒(méi)有奏效。從那時(shí)起我讀到你可以在那里寫(xiě)任何無(wú)關(guān)緊要的東西。直到這一行的輸出:INFO:tensorflow:Saver not created because there are no variables in the graph to restoreINFO:tensorflow:The specified SavedModel has no variables; no checkpoints were restored.INFO:tensorflow:The given SavedModel MetaGraphDef contains SignatureDefs with the following keys: {'serving_default'}INFO:tensorflow:input tensors info: INFO:tensorflow:Tensor's key in saved_model's tensor_map: inputsINFO:tensorflow: tensor name: image_tensor:0, shape: (-1, -1, -1, 3), type: DT_UINT8INFO:tensorflow:output tensors info: INFO:tensorflow:Tensor's key in saved_model's tensor_map: num_detectionsINFO:tensorflow: tensor name: num_detections:0, shape: (-1), type: DT_FLOATINFO:tensorflow:Tensor's key in saved_model's tensor_map: detection_boxesINFO:tensorflow: tensor name: detection_boxes:0, shape: (-1, 100, 4), type: DT_FLOATINFO:tensorflow:Tensor's key in saved_model's tensor_map: detection_scores我無(wú)法在此處復(fù)制控制臺(tái)輸出,因此它超過(guò)了 30000 個(gè)字符的限制,但您可以在這里看到它:https : //pastebin.com/UyT2x2Vk請(qǐng)?jiān)谶@一點(diǎn)上提供幫助,我該怎么做才能使其正常工作:(我的配置:Ubuntu 16.04,Tensorflow-GPU 1.12
1 回答

白衣染霜花
TA貢獻(xiàn)1796條經(jīng)驗(yàn) 獲得超10個(gè)贊
基本上問(wèn)題在于他們的主要腳本不支持 SSD 模型。我不是bazel
用來(lái)做這個(gè)的,而是tflite_convert
實(shí)用的。
小心使用export_tflite_ssd_graph.py
腳本,在使用它之前閱讀它的所有選項(xiàng)(主要是救了我一命的 --max_detections)。
希望這可以幫助。
編輯:您的第 2 步無(wú)效。如果 save_model 包含 SSD,則無(wú)法將其轉(zhuǎn)換為 tflite 模型。您需要使用export_tflite_ssd_graph.py
腳本導(dǎo)出經(jīng)過(guò)訓(xùn)練的 model.ckpt并使用.pb
創(chuàng)建的文件使用tflite_convert
工具將其轉(zhuǎn)換為 tflite 。
添加回答
舉報(bào)
0/150
提交
取消