从.pb文件中查找输入和输出张量

时间:2020-06-14 11:55:01

标签: python-3.x tensorflow computer-vision tensorflow-lite

多亏了roboflow.ai,我创建了.pb模型,现在我试图将.pb文件转换为.tflite,以便可以在希望开发的Android应用中使用它。我正在努力进行转换,因为我必须放入“输入”和“输出”张量。

我找到了一个脚本,给我输入张量为'image_tensor',但给我输出张量为:

'Postprocessor/BatchMultiClassNonMaxSuppression/map/while/Switch', 'raw_detection_boxes', 'MultipleGridAnchorGenerator/assert_equal_1/Assert/Assert', 'detection_boxes', 'detection_scores', 'Postprocessor/BatchMultiClassNonMaxSuppression/map/while/MultiClassNonMaxSuppression/SortByField/TopKV2', 'detection_multiclass_scores', 'Postprocessor/BatchMultiClassNonMaxSuppression/map/while/MultiClassNonMaxSuppression/SortByField/Assert/Assert', 'Postprocessor/BatchMultiClassNonMaxSuppression/map/while/Switch_1', 'Postprocessor/BatchMultiClassNonMaxSuppression/map/while/MultiClassNonMaxSuppression/SortByField_1/Assert/Assert', 'detection_classes', 'num_detections', 'Postprocessor/BatchMultiClassNonMaxSuppression/map/while/MultiClassNonMaxSuppression/SortByField_1/TopKV2', 'Preprocessor/map/while/Switch_1', 'Preprocessor/map/while/Switch', 'raw_detection_scores'

我已经尝试了所有这些方法以及这些方法的不同组合,但是我不确定应该使用什么(或者甚至是正确的方法)。

我正在尝试将其放入以下代码中:

import tensorflow as tf

localpb = 'retrained_graph_eyes1za.pb'
tflite_file = 'retrained_graph_eyes1za.lite'

print("{} -> {}".format(localpb, tflite_file))

converter = tf.lite.TFLiteConverter.from_frozen_graph(
    localpb, 
    ['input'], 
    ['final_result']
)

tflite_model = converter.convert()

open(tflite_file,'wb').write(tflite_model)

interpreter = tf.lite.Interpreter(model_content=tflite_model)
interpreter.allocate_tensors()

我正在使用TensorFlow v1x,因为这是roboflow.ai的建议。

有帮助吗?

0 个答案:

没有答案
相关问题