我嘗試將凍結的 SSD mobilenet v2 模型轉換為 TFLITE 格式以供 Android 使用。這是我所有的步驟:我使用來自模型動物園的ssd_mobilenet_v2_coco_2018_03_29模型使用TF Object Detection API的 train.py 文件重新訓練。(好的)使用同樣由 TF Object Detection API 提供的export_inference_graph.py將訓練好的 model.ckpt 導出到凍結的模型文件。(好的)使用 GPU 測試 Python 中的凍結圖,并且僅允許使用 CPU。有用。(好的)缺點是,我嘗試使用以下代碼: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首先,我嘗試不向函數添加輸入形狀參數,但沒有奏效。從那時起我讀到你可以在那里寫任何無關緊要的東西。直到這一行的輸出: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我無法在此處復制控制臺輸出,因此它超過了 30000 個字符的限制,但您可以在這里看到它:https : //pastebin.com/UyT2x2Vk請在這一點上提供幫助,我該怎么做才能使其正常工作:(我的配置:Ubuntu 16.04,Tensorflow-GPU 1.12
1 回答

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