1

当我将我的 tensorflow 模型(保存为 .pb 文件)转换为 uff 文件时,错误日志如下:

Using output node final/lanenet_loss/instance_seg
Using output node final/lanenet_loss/binary_seg
Converting to UFF graph
Warning: No conversion function registered for layer: Slice yet.
Converting as custom op Slice final/lanenet_loss/Slice
name: "final/lanenet_loss/Slice"
op: "Slice"
input: "final/lanenet_loss/Shape_1"
input: "final/lanenet_loss/Slice/begin"
input: "final/lanenet_loss/Slice/size"
attr {
  key: "Index"
  value {
    type: DT_INT32
  }
}
attr {
  key: "T"
  value {
    type: DT_INT32
  }
}

Traceback (most recent call last):
  File "tfpb_to_uff.py", line 16, in <module>
    uff_model = uff.from_tensorflow(graphdef=output_graph_def, output_filename=output_path, output_nodes=["final/lanenet_loss/instance_seg", "final/lanenet_loss/binary_seg"], text=True)
  File "/home/dream/.local/lib/python3.5/site-packages/uff/converters/tensorflow/conversion_helpers.py", line 75, in from_tensorflow
    name="main")
  File "/home/dream/.local/lib/python3.5/site-packages/uff/converters/tensorflow/converter.py", line 64, in convert_tf2uff_graph
    uff_graph, input_replacements)
  File "/home/dream/.local/lib/python3.5/site-packages/uff/converters/tensorflow/converter.py", line 51, in convert_tf2uff_node
    op, name, tf_node, inputs, uff_graph, tf_nodes=tf_nodes)
  File "/home/dream/.local/lib/python3.5/site-packages/uff/converters/tensorflow/converter.py", line 28, in convert_layer
    fields = cls.parse_tf_attrs(tf_node.attr)
  File "/home/dream/.local/lib/python3.5/site-packages/uff/converters/tensorflow/converter.py", line 177, in parse_tf_attrs
    for key, val in attrs.items()}
  File "/home/dream/.local/lib/python3.5/site-packages/uff/converters/tensorflow/converter.py", line 177, in <dictcomp>
    for key, val in attrs.items()}
  File "/home/dream/.local/lib/python3.5/site-packages/uff/converters/tensorflow/converter.py", line 172, in parse_tf_attr_value
    return cls.convert_tf2uff_field(code, val)
  File "/home/dream/.local/lib/python3.5/site-packages/uff/converters/tensorflow/converter.py", line 146, in convert_tf2uff_field
    return TensorFlowToUFFConverter.convert_tf2numpy_dtype(val)
  File "/home/dream/.local/lib/python3.5/site-packages/uff/converters/tensorflow/converter.py", line 74, in convert_tf2numpy_dtype
    return np.dtype(dt[dtype])
TypeError: list indices must be integers or slices, not AttrValue

这意味着 TensorRT 目前不支持 layer: 'Slice'。所以我打算在我的代码中修改这一层。但是,我无法在我的代码中找到“切片”层,即使我通过函数 sess.graph.get_operation_by_name 获取有关“切片”的信息:

graph list name: "final/lanenet_loss/Slice"
op: "Slice"
input: "final/lanenet_loss/Shape_1"
input: "final/lanenet_loss/Slice/begin"
input: "final/lanenet_loss/Slice/size"
attr {
  key: "Index"
  value {
    type: DT_INT32
  }
}
attr {
  key: "T"
  value {
    type: DT_INT32
  }
}

如何在我的代码行中找到“切片”层,以便我可以通过 TensorRT 自定义层对其进行修改?

4

1 回答 1

2

因为你是从 Tensorflow 解析的,所以最好看看 TensorRT 支持哪些。从 TensorRT 4 开始,支持以下这些层:

  • 占位符
  • 常量
  • Add, Sub, Mul, Div, 最小值和最大值
  • 偏置添加
  • 负数、Abs、Sqrt、Rsqrt、Pow、Exp 和 Log
  • FusedBatchNorm
  • ReLU、TanH、Sigmoid
  • 软最大
  • 意思是
  • 康卡特V2
  • 重塑
  • 转置
  • 二维卷积
  • DepthwiseConv2dNative
  • 转置2D
  • 最大池
  • 平均池
  • 如果后跟以下 TensorFlow 层之一,则支持 Pad:Conv2D、DepthwiseConv2dNative、MaxPool 和 AvgPool

从我在您的日志中看到的您正在尝试部署 LaneNet,它是本文的 LaneNet吗?

如果是这样的话,它似乎是 H-Net 的一个变体,还没有读过它,但根据这篇论文,架构如下:

LaneNet 架构

所以我看到 Convs、Relus、Maxpool 和 Linear,所有这些都受支持,不知道那个 BN,也许检查一下它指的是哪个层,如果它不在支持的网络列表中,你会必须从头开始实施。祝你好运!

于 2018-08-17T14:12:51.473 回答