首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >如何获取从darknet转换而来的.pb模型的输入和输出名称

如何获取从darknet转换而来的.pb模型的输入和输出名称
EN

Stack Overflow用户
提问于 2020-02-02 15:10:38
回答 1查看 850关注 0票数 0

我使用YOLOv3-SPP模型在暗网上训练了一个模型。我需要能够在我的iPhone应用程序中使用此模型,因此我需要将其转换为CoreML。我首先将.weights文件转换为.pb文件。现在我正在尝试使用tfcoreml将其从TensorFlow转换为CoreML。然而,我似乎无法确定我的输入和输出张量名称。我尝试使用tensorboard来可视化模型并确定输入和输出,但由于我对TensorFlow非常陌生,我不知道该使用什么。我使用以下脚本将模型从TensorFlow转换为CoreML:

代码语言:javascript
运行
AI代码解释
复制
import tfcoreml
import os
import tensorflow as tf

frozen_model_file = os.path.abspath('frozen_darknet_yolov3_model.pb')
input_tensor_shapes = {"input/placeholder:0": [1, 32, 32, 9]}
# Output CoreML model path
coreml_model_file = './model.mlmodel'
output_tensor_names = ['output/prediction:0']
def convert():
    # Read the pb model
    with tf.gfile.GFile(frozen_model_file, "rb") as f:
        graph_def = tf.GraphDef()
        graph_def.ParseFromString(f.read())
    # Then, we import the graph_def into a new Graph
    tf.import_graph_def(graph_def, name="")
    # Convert
    tfcoreml.convert(
        tf_model_path=frozen_model_file,
        mlmodel_path=coreml_model_file,
        input_name_shape_dict=input_tensor_shapes,
        output_feature_names=output_tensor_names)
convert()

这就是我的拉力板的样子:

我应该如何设置input_tensor_shapesoutput_tensor_names,这样我就不会收到错误,说我的TensorFlow图不包含具有该名称的张量。

EN

回答 1

Stack Overflow用户

发布于 2020-02-02 16:33:09

我建议使用Netron来查看TensorFlow文件。这使得图表更容易理解。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60027444

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档