簡體   English   中英

如何將對象檢測模型(在其凍結圖形中)轉換為.tflite,而不需要任何輸入和輸出數組的知識

[英]How to convert an object detection model, in it's frozen graph, to a .tflite, without any knowledge of input and output arrays

所以我有一個從“ https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md ”下載的對象檢測模型; 模型的名稱是“faster_rcnn_resnet101_fgvc”。 我試圖將模型轉換為.tflite格式(因為我有凍結圖“frozen_inference_graph.pb”),使用https://www.tensorflow.org/lite/guide/ops_select中給出的python代碼:

import tensorflow as tf

graph_def_file = "/path/to/Downloads/mobilenet_v1_1.0_224/frozen_graph.pb"
input_arrays = ["input"]
output_arrays = ["MobilenetV1/Predictions/Softmax"]

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)

運行這個給了我一個錯誤:

ValueError: Invalid tensors 'input' were found.

有沒有辦法找到模型的輸入和輸出節點? 我只有凍結圖,GraphDef和檢查點。

要查找可以使用的模型的輸入和輸出節點saved_model_cli

!saved_model_cli show --all --dir faster_rcnn_resnet101_fgvc_2018_07_19/saved_model/

它將顯示有關您的模型的詳細信息。

MetaGraphDef with tag-set: 'serve' contains the following SignatureDefs:

signature_def['serving_default']:
  The given SavedModel SignatureDef contains the following input(s):
    inputs['inputs'] tensor_info:
        dtype: DT_UINT8
        shape: (-1, -1, -1, 3)
        name: image_tensor:0
  The given SavedModel SignatureDef contains the following output(s):
    outputs['detection_boxes'] tensor_info:
        dtype: DT_FLOAT
        shape: (-1, 5, 4)
        name: detection_boxes:0
    outputs['detection_classes'] tensor_info:
        dtype: DT_FLOAT
        shape: (-1, 5)
        name: detection_classes:0
    outputs['detection_scores'] tensor_info:
        dtype: DT_FLOAT
        shape: (-1, 5)
        name: detection_scores:0
    outputs['num_detections'] tensor_info:
        dtype: DT_FLOAT
        shape: (-1)
        name: num_detections:0
  Method name is: tensorflow/serving/predict

在您的情況下,輸入圖層名稱是"image_tensor"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM