Tensorflow model to tensorrf uff model convert error

TensorRT 5 is being used, converting tensortlow-model to uff.
Tensorflow version 1.12.0. Once executed, Python shows an operational error:

>>> import uff
>>> uff.from_tensorflow_frozen_model( "frozen_inference_graph.pb" , [ 'detection_scores','detection_boxes' ,'detection_classes' ,'num_detections' ] , output_filename="tensorrt.uff", text=True)

NOTE: UFF has been tested with TensorFlow 1.12.0. Other versions are not guaranteed to work
UFF Version 0.6.3
=== Automatically deduced input nodes ===
[name: "image_tensor"
op: "Placeholder"
attr {
   key: "dtype"
   value {
      type: DT_UINT8
   }
}
attr {
   key: "shape"
   value {
      shape {
         dim {
            size: -1
         }
         dim {
            size: -1
         }
         dim {
            size: -1
         }
         dim {
            size: 3
         }
      }
   }
}
]
=========================================

Using output node detection_scores
Using output node detection_boxes
Using output node detection_classes
Using output node num_detections
Converting to UFF graph
Warning: No conversion function registered for layer: Cast yet.
Converting SecondStagePostprocessor/ToFloat_1 as custom op: Cast
Warning: No conversion function registered for layer: TensorArrayGatherV3 yet.
Converting SecondStagePostprocessor/BatchMultiClassNonMaxSuppression/map/TensorArrayStack_4/TensorArrayGatherV3 as custom op: TensorArrayGatherV3
Warning: No conversion function registered for layer: Exit yet.
Converting SecondStagePostprocessor/BatchMultiClassNonMaxSuppression/map/while/Exit_6 as custom op: Exit
Warning: No conversion function registered for layer: Switch yet.
Converting SecondStagePostprocessor/BatchMultiClassNonMaxSuppression/map/while/Switch_6 as custom op: Switch
Warning: No conversion function registered for layer: LoopCond yet.
Converting SecondStagePostprocessor/BatchMultiClassNonMaxSuppression/map/while/LoopCond as custom op: LoopCond
Warning: No conversion function registered for layer: LogicalAnd yet.
Converting SecondStagePostprocessor/BatchMultiClassNonMaxSuppression/map/while/LogicalAnd as custom op: LogicalAnd
Warning: No conversion function registered for layer: Less yet.
Converting SecondStagePostprocessor/BatchMultiClassNonMaxSuppression/map/while/Less_1 as custom op: Less
Warning: No conversion function registered for layer: Enter yet.
Converting SecondStagePostprocessor/BatchMultiClassNonMaxSuppression/map/while/Less/Enter as custom op: Enter
DEBUG: convert reshape to flatten node
Warning: keepdims is ignored by the UFF Parser and defaults to True
Warning: No conversion function registered for layer: CropAndResize yet.
Converting CropAndResize/CropAndResize as custom op: CropAndResize
Warning: No conversion function registered for layer: Range yet.
Converting CropAndResize/range as custom op: Range
Warning: No conversion function registered for layer: TensorArrayGatherV3 yet.
Converting map/TensorArrayStack/TensorArrayGatherV3 as custom op: TensorArrayGatherV3
Warning: No conversion function registered for layer: Exit yet.
Converting map/while/Exit_2 as custom op: Exit
Warning: No conversion function registered for layer: Switch yet.
Converting map/while/Switch_2 as custom op: Switch
Warning: No conversion function registered for layer: LoopCond yet.
Converting map/while/LoopCond as custom op: LoopCond
Warning: No conversion function registered for layer: LogicalAnd yet.
Converting map/while/LogicalAnd as custom op: LogicalAnd
Warning: No conversion function registered for layer: Less yet.
Converting map/while/Less_1 as custom op: Less
Warning: No conversion function registered for layer: Enter yet.
Converting map/while/Less/Enter as custom op: Enter
Warning: No conversion function registered for layer: TensorArrayGatherV3 yet.
Converting BatchMultiClassNonMaxSuppression/map/TensorArrayStack/TensorArrayGatherV3 as custom op: TensorArrayGatherV3
Warning: No conversion function registered for layer: Exit yet.
Converting BatchMultiClassNonMaxSuppression/map/while/Exit_2 as custom op: Exit
Warning: No conversion function registered for layer: Switch yet.
Converting BatchMultiClassNonMaxSuppression/map/while/Switch_2 as custom op: Switch
Warning: No conversion function registered for layer: LoopCond yet.
Converting BatchMultiClassNonMaxSuppression/map/while/LoopCond as custom op: LoopCond
Warning: No conversion function registered for layer: LogicalAnd yet.
Converting BatchMultiClassNonMaxSuppression/map/while/LogicalAnd as custom op: LogicalAnd
Warning: No conversion function registered for layer: Less yet.
Converting BatchMultiClassNonMaxSuppression/map/while/Less_1 as custom op: Less
Warning: No conversion function registered for layer: Enter yet.
Converting BatchMultiClassNonMaxSuppression/map/while/Less/Enter as custom op: Enter
Warning: No conversion function registered for layer: TensorArrayGatherV3 yet.
Converting Preprocessor/map/TensorArrayStack/TensorArrayGatherV3 as custom op: TensorArrayGatherV3
Warning: No conversion function registered for layer: Exit yet.
Converting Preprocessor/map/while/Exit_2 as custom op: Exit
Warning: No conversion function registered for layer: Switch yet.
Converting Preprocessor/map/while/Switch_2 as custom op: Switch
Warning: No conversion function registered for layer: LoopCond yet.
Converting Preprocessor/map/while/LoopCond as custom op: LoopCond
Warning: No conversion function registered for layer: LogicalAnd yet.
Converting Preprocessor/map/while/LogicalAnd as custom op: LogicalAnd
Warning: No conversion function registered for layer: Less yet.
Converting Preprocessor/map/while/Less_1 as custom op: Less
Warning: No conversion function registered for layer: Enter yet.
Converting Preprocessor/map/while/Less/Enter as custom op: Enter
Warning: No conversion function registered for layer: Cast yet.
Converting ToFloat_3 as custom op: Cast
Warning: No conversion function registered for layer: Merge yet.
Converting Preprocessor/map/while/Merge_1 as custom op: Merge
Warning: No conversion function registered for layer: NextIteration yet.
Converting Preprocessor/map/while/NextIteration_1 as custom op: NextIteration
Warning: No conversion function registered for layer: Switch yet.
Converting Preprocessor/map/while/Switch as custom op: Switch
Warning: No conversion function registered for layer: Merge yet.
Converting Preprocessor/map/while/Merge as custom op: Merge
Warning: No conversion function registered for layer: NextIteration yet.
Converting Preprocessor/map/while/NextIteration as custom op: NextIteration
Warning: No conversion function registered for layer: Enter yet.
Converting Preprocessor/map/while/Enter as custom op: Enter
Warning: No conversion function registered for layer: Switch yet.
Converting Preprocessor/map/while/Switch_1 as custom op: Switch
Warning: No conversion function registered for layer: Enter yet.
Converting Preprocessor/map/while/Enter_1 as custom op: Enter
Warning: No conversion function registered for layer: Less yet.
Converting Preprocessor/map/while/Less as custom op: Less
Warning: No conversion function registered for layer: Merge yet.
Converting Preprocessor/map/while/Merge_2 as custom op: Merge
Warning: No conversion function registered for layer: NextIteration yet.
Converting Preprocessor/map/while/NextIteration_2 as custom op: NextIteration
Warning: No conversion function registered for layer: TensorArrayWriteV3 yet.
Converting Preprocessor/map/while/TensorArrayWrite/TensorArrayWriteV3 as custom op: TensorArrayWriteV3
Warning: No conversion function registered for layer: ResizeBilinear yet.
Converting Preprocessor/map/while/ResizeToRange/resize/ResizeBilinear as custom op: ResizeBilinear
Warning: No conversion function registered for layer: TensorArrayReadV3 yet.
Converting Preprocessor/map/while/TensorArrayReadV3 as custom op: TensorArrayReadV3
Warning: No conversion function registered for layer: Enter yet.
Converting Preprocessor/map/while/TensorArrayReadV3/Enter_1 as custom op: Enter
Warning: No conversion function registered for layer: TensorArrayScatterV3 yet.
Converting Preprocessor/map/TensorArrayUnstack/TensorArrayScatter/TensorArrayScatterV3 as custom op: TensorArrayScatterV3
Warning: No conversion function registered for layer: TensorArrayV3 yet.
Converting Preprocessor/map/TensorArray as custom op: TensorArrayV3
Warning: No conversion function registered for layer: Range yet.
Converting Preprocessor/map/TensorArrayUnstack/range as custom op: Range
Warning: No conversion function registered for layer: Enter yet.
Converting Preprocessor/map/while/TensorArrayReadV3/Enter as custom op: Enter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.6/dist-packages/uff/converters/tensorflow/conversion_helpers.py", line 233, in from_tensorflow_frozen_model
return from_tensorflow(graphdef, output_nodes, preprocessor, **kwargs)
File "/usr/lib/python3.6/dist-packages/uff/converters/tensorflow/conversion_helpers.py", line 181, in from_tensorflow
debug_mode=debug_mode)
File "/usr/lib/python3.6/dist-packages/uff/converters/tensorflow/converter.py", line 94, in convert_tf2uff_graph
uff_graph, input_replacements, debug_mode=debug_mode)
File "/usr/lib/python3.6/dist-packages/uff/converters/tensorflow/converter.py", line 79, in convert_tf2uff_node
op, name, tf_node, inputs, uff_graph, tf_nodes=tf_nodes, debug_mode=debug_mode)
File "/usr/lib/python3.6/dist-packages/uff/converters/tensorflow/converter.py", line 41, in convert_layer
fields = cls.parse_tf_attrs(tf_node.attr)
File "/usr/lib/python3.6/dist-packages/uff/converters/tensorflow/converter.py", line 222, in parse_tf_attrs
return {key: cls.parse_tf_attr_value(val) for key, val in attrs.items() if val is not None and val.WhichOneof('value') is not None}
File "/usr/lib/python3.6/dist-packages/uff/converters/tensorflow/converter.py", line 222, in <dictcomp>
return {key: cls.parse_tf_attr_value(val) for key, val in attrs.items() if val is not None and val.WhichOneof('value') is not None}
File "/usr/lib/python3.6/dist-packages/uff/converters/tensorflow/converter.py", line 218, in parse_tf_attr_value
return cls.convert_tf2uff_field(code, val)
File "/usr/lib/python3.6/dist-packages/uff/converters/tensorflow/converter.py", line 190, in convert_tf2uff_field
return TensorFlowToUFFConverter.convert_tf2numpy_dtype(val)
File "/usr/lib/python3.6/dist-packages/uff/converters/tensorflow/converter.py", line 103, in convert_tf2numpy_dtype
return tf.as_dtype(dtype).as_numpy_dtype
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py", line 128, in as_numpy_dtype
return _TF_TO_NP[self._type_enum]
KeyError: 20

Hi,

Not all TensorFlow operation is supported by TensorRT.
You can find our support matrix here:
[url]https://docs.nvidia.com/deeplearning/sdk/tensorrt-support-matrix/index.html#supported-ops[/url]

For your use-case, it’s recommended to use TF-TRT.
TF-TRT will automatically fallback to TensorFlow implementation for a non-supported layer.
[url]https://github.com/NVIDIA-AI-IOT/tf_trt_models[/url]

Thanks.

TF-TRT creates TensorFlow model( pd file) but our software utilizes C++ API Tensor RT.

  1. How can we use the indicated model obtained by using TF-TRT in C++ API? Is there an example of such use?

  2. Is it possible to convert TensorFlow model or CKPT-file to UFF model or ONNX model

Hi,

It is much complicated with the C++ interface.

1. Convert your .pb file into uff via uffparser.
Please mark the non-supported layer as plugin.

2. Implement the non-supported layer with C++

3. Launch TensorRT with the plugin implementation and uff model.

Here is a relevant sample for your reference:
[url]Sample Support Guide :: NVIDIA Deep Learning TensorRT Documentation

Thanks.

Jagry,

Did you solve your problem? I am trying to use the same model and ran into the same problem.

I have tried tensorflow trt solution in python, which got a terrible delay(about 3 times slower than the original tensorflow inference), I think it wouldn’t be better even you “Implement the non-supported layer with C++”.

I’m facing the same error.
My TensorFlow-GPU version is 1.14 and tensorRt version is 5.1.5.0. I’m facing the same error while converting .pb to .uff
Steps followed were:

  1. Optimizing .pb file of TF-GPU using tensorRT
  2. Converting .pb of TRT to .uff

for conversion script used is as follow:
uff.from_tensorflow_frozen_model(frozen_file=“/home/neureol/Desktop/humanhead/box_inference/box8_inference_graph/frozen_8.pb”,
output_nodes=[‘detection_boxes’, ‘detection_classes’, ‘detection_scores’, ‘num_detections’],
output_filename=“/home/neureol/Desktop/humanhead/box_inference/box8_inference_graph/frozen_8.uff”)

And need help in fixing the following error:

WARNING:tensorflow:From /home/neureol/anaconda3/envs/test/lib/python3.7/site-packages/uff/converters/tensorflow/conversion_helpers.py:231: The name tf.gfile.GFile is deprecated. Please use tf.io.gfile.GFile instead.

NOTE: UFF has been tested with TensorFlow 1.12.0. Other versions are not guaranteed to work
WARNING: The version of TensorFlow installed on this system is not guaranteed to work with UFF.
WARNING:tensorflow:From /home/neureol/anaconda3/envs/test/lib/python3.7/site-packages/graphsurgeon/_utils.py:2: The name tf.NodeDef is deprecated. Please use tf.compat.v1.NodeDef instead.

UFF Version 0.6.3
=== Automatically deduced input nodes ===
[name: “image_tensor”
op: “Placeholder”
attr {
key: “dtype”
value {
type: DT_UINT8
}
}
attr {
key: “shape”
value {
shape {
dim {
size: -1
}
dim {
size: -1
}
dim {
size: -1
}
dim {
size: 3
}
}
}
}
]

Using output node detection_boxes
Using output node detection_classes
Using output node detection_scores
Using output node num_detections
Converting to UFF graph
Warning: No conversion function registered for layer: Cast yet.
Converting Postprocessor/Cast_4 as custom op: Cast
WARNING:tensorflow:From /home/neureol/anaconda3/envs/test/lib/python3.7/site-packages/uff/converters/tensorflow/converter.py:179: The name tf.AttrValue is deprecated. Please use tf.compat.v1.AttrValue instead.

Warning: No conversion function registered for layer: TensorArrayGatherV3 yet.
Converting Postprocessor/BatchMultiClassNonMaxSuppression/map/TensorArrayStack_6/TensorArrayGatherV3 as custom op: TensorArrayGatherV3
Warning: No conversion function registered for layer: Exit yet.
Converting Postprocessor/BatchMultiClassNonMaxSuppression/map/while/Exit_8 as custom op: Exit
Warning: No conversion function registered for layer: Switch yet.
Converting Postprocessor/BatchMultiClassNonMaxSuppression/map/while/Switch_8 as custom op: Switch
Warning: No conversion function registered for layer: LoopCond yet.
Converting Postprocessor/BatchMultiClassNonMaxSuppression/map/while/LoopCond as custom op: LoopCond
Warning: No conversion function registered for layer: LogicalAnd yet.
Converting Postprocessor/BatchMultiClassNonMaxSuppression/map/while/LogicalAnd as custom op: LogicalAnd
Warning: No conversion function registered for layer: Less yet.
Converting Postprocessor/BatchMultiClassNonMaxSuppression/map/while/Less_1 as custom op: Less
Warning: No conversion function registered for layer: Enter yet.
Converting Postprocessor/BatchMultiClassNonMaxSuppression/map/while/Less/Enter as custom op: Enter
Warning: No conversion function registered for layer: TensorArrayGatherV3 yet.
Converting Preprocessor/map/TensorArrayStack/TensorArrayGatherV3 as custom op: TensorArrayGatherV3
Warning: No conversion function registered for layer: Exit yet.
Converting Preprocessor/map/while/Exit_2 as custom op: Exit
Warning: No conversion function registered for layer: Switch yet.
Converting Preprocessor/map/while/Switch_2 as custom op: Switch
Warning: No conversion function registered for layer: LoopCond yet.
Converting Preprocessor/map/while/LoopCond as custom op: LoopCond
Warning: No conversion function registered for layer: LogicalAnd yet.
Converting Preprocessor/map/while/LogicalAnd as custom op: LogicalAnd
Warning: No conversion function registered for layer: Less yet.
Converting Preprocessor/map/while/Less_1 as custom op: Less
Warning: No conversion function registered for layer: Enter yet.
Converting Preprocessor/map/while/Less/Enter as custom op: Enter
Warning: No conversion function registered for layer: Cast yet.
Converting Cast as custom op: Cast
Warning: No conversion function registered for layer: Merge yet.
Converting Preprocessor/map/while/Merge_1 as custom op: Merge
Warning: No conversion function registered for layer: NextIteration yet.
Converting Preprocessor/map/while/NextIteration_1 as custom op: NextIteration
Warning: No conversion function registered for layer: Switch yet.
Converting Preprocessor/map/while/Switch as custom op: Switch
Warning: No conversion function registered for layer: Merge yet.
Converting Preprocessor/map/while/Merge as custom op: Merge
Warning: No conversion function registered for layer: NextIteration yet.
Converting Preprocessor/map/while/NextIteration as custom op: NextIteration
Warning: No conversion function registered for layer: Enter yet.
Converting Preprocessor/map/while/Enter as custom op: Enter
Warning: No conversion function registered for layer: Switch yet.
Converting Preprocessor/map/while/Switch_1 as custom op: Switch
Warning: No conversion function registered for layer: Enter yet.
Converting Preprocessor/map/while/Enter_1 as custom op: Enter
Warning: No conversion function registered for layer: Less yet.
Converting Preprocessor/map/while/Less as custom op: Less
Warning: No conversion function registered for layer: Merge yet.
Converting Preprocessor/map/while/Merge_2 as custom op: Merge
Warning: No conversion function registered for layer: NextIteration yet.
Converting Preprocessor/map/while/NextIteration_2 as custom op: NextIteration
Warning: No conversion function registered for layer: TensorArrayWriteV3 yet.
Converting Preprocessor/map/while/TensorArrayWrite/TensorArrayWriteV3 as custom op: TensorArrayWriteV3
Warning: No conversion function registered for layer: ResizeBilinear yet.
Converting Preprocessor/map/while/ResizeImage/resize/ResizeBilinear as custom op: ResizeBilinear
Warning: No conversion function registered for layer: TensorArrayReadV3 yet.
Converting Preprocessor/map/while/TensorArrayReadV3 as custom op: TensorArrayReadV3
Warning: No conversion function registered for layer: Enter yet.
Converting Preprocessor/map/while/TensorArrayReadV3/Enter_1 as custom op: Enter
Warning: No conversion function registered for layer: TensorArrayScatterV3 yet.
Converting Preprocessor/map/TensorArrayUnstack/TensorArrayScatter/TensorArrayScatterV3 as custom op: TensorArrayScatterV3
Warning: No conversion function registered for layer: TensorArrayV3 yet.
Converting Preprocessor/map/TensorArray as custom op: TensorArrayV3
Warning: No conversion function registered for layer: Range yet.
Converting Preprocessor/map/TensorArrayUnstack/range as custom op: Range
Warning: No conversion function registered for layer: Enter yet.
Converting Preprocessor/map/while/TensorArrayReadV3/Enter as custom op: Enter


KeyError Traceback (most recent call last)
in
1 uff.from_tensorflow_frozen_model(frozen_file=“/home/neureol/Desktop/humanhead/box_inference/box8_inference_graph/frozen_8.pb”,
2 output_nodes=[‘detection_boxes’, ‘detection_classes’, ‘detection_scores’, ‘num_detections’],
----> 3 output_filename=“/home/neureol/Desktop/humanhead/box_inference/box8_inference_graph/frozen_8.uff”)

~/anaconda3/envs/test/lib/python3.7/site-packages/uff/converters/tensorflow/conversion_helpers.py in from_tensorflow_frozen_model(frozen_file, output_nodes, preprocessor, **kwargs)
231 with tf.gfile.GFile(frozen_file, “rb”) as frozen_pb:
232 graphdef.ParseFromString(frozen_pb.read())
→ 233 return from_tensorflow(graphdef, output_nodes, preprocessor, **kwargs)

~/anaconda3/envs/test/lib/python3.7/site-packages/uff/converters/tensorflow/conversion_helpers.py in from_tensorflow(graphdef, output_nodes, preprocessor, **kwargs)
179 input_replacements=input_replacements,
180 name=“main”,
→ 181 debug_mode=debug_mode)
182
183 uff_metagraph_proto = uff_metagraph.to_uff()

~/anaconda3/envs/test/lib/python3.7/site-packages/uff/converters/tensorflow/converter.py in convert_tf2uff_graph(cls, tf_graphdef, uff_metagraph, output_nodes, input_replacements, name, debug_mode)
92 while len(nodes_to_convert):
93 nodes_to_convert += cls.convert_tf2uff_node(nodes_to_convert.pop(), tf_nodes,
—> 94 uff_graph, input_replacements, debug_mode=debug_mode)
95 if debug_mode:
96 _debug_print(“Marking {:} as outputs”.format(output_nodes))

~/anaconda3/envs/test/lib/python3.7/site-packages/uff/converters/tensorflow/converter.py in convert_tf2uff_node(cls, name, tf_nodes, uff_graph, input_replacements, debug_mode)
77 op = tf_node.op
78 uff_node = cls.convert_layer(
—> 79 op, name, tf_node, inputs, uff_graph, tf_nodes=tf_nodes, debug_mode=debug_mode)
80 return uff_node
81

~/anaconda3/envs/test/lib/python3.7/site-packages/uff/converters/tensorflow/converter.py in convert_layer(cls, op, name, tf_node, inputs, uff_graph, debug_mode, **kwargs)
39 # if debug_mode:
40 # _debug_print(tf_node)
—> 41 fields = cls.parse_tf_attrs(tf_node.attr)
42 uff_graph.custom_node(op, inputs, name, fields if fields else None)
43 return inputs

~/anaconda3/envs/test/lib/python3.7/site-packages/uff/converters/tensorflow/converter.py in parse_tf_attrs(cls, attrs)
220 @classmethod
221 def parse_tf_attrs(cls, attrs):
→ 222 return {key: cls.parse_tf_attr_value(val) for key, val in attrs.items() if val is not None and val.WhichOneof(‘value’) is not None}
223
224 @classmethod

~/anaconda3/envs/test/lib/python3.7/site-packages/uff/converters/tensorflow/converter.py in (.0)
220 @classmethod
221 def parse_tf_attrs(cls, attrs):
→ 222 return {key: cls.parse_tf_attr_value(val) for key, val in attrs.items() if val is not None and val.WhichOneof(‘value’) is not None}
223
224 @classmethod

~/anaconda3/envs/test/lib/python3.7/site-packages/uff/converters/tensorflow/converter.py in parse_tf_attr_value(cls, val)
216 def parse_tf_attr_value(cls, val):
217 code = val.WhichOneof(‘value’)
→ 218 return cls.convert_tf2uff_field(code, val)
219
220 @classmethod

~/anaconda3/envs/test/lib/python3.7/site-packages/uff/converters/tensorflow/converter.py in convert_tf2uff_field(cls, code, val)
188 return bool(val)
189 elif code == ‘type’:
→ 190 return TensorFlowToUFFConverter.convert_tf2numpy_dtype(val)
191 elif code == ‘list’:
192 fields = val.ListFields()

~/anaconda3/envs/test/lib/python3.7/site-packages/uff/converters/tensorflow/converter.py in convert_tf2numpy_dtype(cls, dtype)
101 @classmethod
102 def convert_tf2numpy_dtype(cls, dtype):
→ 103 return tf.as_dtype(dtype).as_numpy_dtype
104
105 @classmethod

~/anaconda3/envs/test/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py in as_numpy_dtype(self)
124 def as_numpy_dtype(self):
125 “”“Returns a numpy.dtype based on this DType.”“”
→ 126 return _TF_TO_NP[self._type_enum]
127
128 @property

KeyError: 20

same problem,
tf 1.14
model ssd-inception-v2
trt 1.5
os centos-docker-to-ubuntu
convert method:python uff package.

the nv sample use the ssd-inception-v2,same as mine,why an error occur in my case?

==================================

root@929a8483d52a:~# python3 tf2uff.py -pb frozen_inference_graph.pb
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:516: FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / ‘(1,)type’.
_np_qint8 = np.dtype([(“qint8”, np.int8, 1)])
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:517: FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / ‘(1,)type’.
_np_quint8 = np.dtype([(“quint8”, np.uint8, 1)])
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:518: FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / ‘(1,)type’.
_np_qint16 = np.dtype([(“qint16”, np.int16, 1)])
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:519: FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / ‘(1,)type’.
_np_quint16 = np.dtype([(“quint16”, np.uint16, 1)])
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:520: FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / ‘(1,)type’.
_np_qint32 = np.dtype([(“qint32”, np.int32, 1)])
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:525: FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / ‘(1,)type’.
np_resource = np.dtype([(“resource”, np.ubyte, 1)])
/usr/local/lib/python3.6/dist-packages/tensorboard/compat/tensorflow_stub/dtypes.py:541: FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / ‘(1,)type’.
_np_qint8 = np.dtype([(“qint8”, np.int8, 1)])
/usr/local/lib/python3.6/dist-packages/tensorboard/compat/tensorflow_stub/dtypes.py:542: FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / ‘(1,)type’.
_np_quint8 = np.dtype([(“quint8”, np.uint8, 1)])
/usr/local/lib/python3.6/dist-packages/tensorboard/compat/tensorflow_stub/dtypes.py:543: FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / ‘(1,)type’.
_np_qint16 = np.dtype([(“qint16”, np.int16, 1)])
/usr/local/lib/python3.6/dist-packages/tensorboard/compat/tensorflow_stub/dtypes.py:544: FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / ‘(1,)type’.
_np_quint16 = np.dtype([(“quint16”, np.uint16, 1)])
/usr/local/lib/python3.6/dist-packages/tensorboard/compat/tensorflow_stub/dtypes.py:545: FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / ‘(1,)type’.
_np_qint32 = np.dtype([(“qint32”, np.int32, 1)])
/usr/local/lib/python3.6/dist-packages/tensorboard/compat/tensorflow_stub/dtypes.py:550: FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / ‘(1,)type’.
np_resource = np.dtype([(“resource”, np.ubyte, 1)])
WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/uff/converters/tensorflow/conversion_helpers.py:18: The name tf.GraphDef is deprecated. Please use tf.compat.v1.GraphDef instead.

Input TF-Frozen-Graph: frozen_inference_graph.pb
The UFF will be written to: frozen_inference_graph.uff
WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/uff/converters/tensorflow/conversion_helpers.py:227: The name tf.gfile.GFile is deprecated. Please use tf.io.gfile.GFile instead.

WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/graphsurgeon/_utils.py:2: The name tf.NodeDef is deprecated. Please use tf.compat.v1.NodeDef instead.

UFF Version 0.6.5
=== Automatically deduced input nodes ===
[name: “image_tensor”
op: “Placeholder”
attr {
key: “dtype”
value {
type: DT_UINT8
}
}
attr {
key: “shape”
value {
shape {
dim {
size: -1
}
dim {
size: -1
}
dim {
size: -1
}
dim {
size: 3
}
}
}
}
]

=== Automatically deduced output nodes ===
[name: “detection_boxes”
op: “Identity”
input: “Postprocessor/BatchMultiClassNonMaxSuppression/map/TensorArrayStack/TensorArrayGatherV3”
attr {
key: “T”
value {
type: DT_FLOAT
}
}
, name: “detection_scores”
op: “Identity”
input: “Postprocessor/BatchMultiClassNonMaxSuppression/map/TensorArrayStack_1/TensorArrayGatherV3”
attr {
key: “T”
value {
type: DT_FLOAT
}
}
, name: “detection_classes”
op: “Identity”
input: “add”
attr {
key: “T”
value {
type: DT_FLOAT
}
}
, name: “num_detections”
op: “Identity”
input: “Postprocessor/ToFloat_3”
attr {
key: “T”
value {
type: DT_FLOAT
}
}
]

Using output node detection_boxes
Using output node detection_scores
Using output node detection_classes
Using output node num_detections
Converting to UFF graph
Warning: No conversion function registered for layer: Cast yet.
Converting Postprocessor/ToFloat_3 as custom op: Cast
WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/uff/converters/tensorflow/converter.py:179: The name tf.AttrValue is deprecated. Please use tf.compat.v1.AttrValue instead.

Warning: No conversion function registered for layer: TensorArrayGatherV3 yet.
Converting Postprocessor/BatchMultiClassNonMaxSuppression/map/TensorArrayStack_4/TensorArrayGatherV3 as custom op: TensorArrayGatherV3
Warning: No conversion function registered for layer: Exit yet.
Converting Postprocessor/BatchMultiClassNonMaxSuppression/map/while/Exit_6 as custom op: Exit
Warning: No conversion function registered for layer: Switch yet.
Converting Postprocessor/BatchMultiClassNonMaxSuppression/map/while/Switch_6 as custom op: Switch
Warning: No conversion function registered for layer: LoopCond yet.
Converting Postprocessor/BatchMultiClassNonMaxSuppression/map/while/LoopCond as custom op: LoopCond
Warning: No conversion function registered for layer: LogicalAnd yet.
Converting Postprocessor/BatchMultiClassNonMaxSuppression/map/while/LogicalAnd as custom op: LogicalAnd
Warning: No conversion function registered for layer: Less yet.
Converting Postprocessor/BatchMultiClassNonMaxSuppression/map/while/Less_1 as custom op: Less
Warning: No conversion function registered for layer: Enter yet.
Converting Postprocessor/BatchMultiClassNonMaxSuppression/map/while/Less/Enter as custom op: Enter
Warning: No conversion function registered for layer: TensorArrayGatherV3 yet.
Converting Preprocessor/map/TensorArrayStack/TensorArrayGatherV3 as custom op: TensorArrayGatherV3
Warning: No conversion function registered for layer: Exit yet.
Converting Preprocessor/map/while/Exit_2 as custom op: Exit
Warning: No conversion function registered for layer: Switch yet.
Converting Preprocessor/map/while/Switch_2 as custom op: Switch
Warning: No conversion function registered for layer: LoopCond yet.
Converting Preprocessor/map/while/LoopCond as custom op: LoopCond
Warning: No conversion function registered for layer: LogicalAnd yet.
Converting Preprocessor/map/while/LogicalAnd as custom op: LogicalAnd
Warning: No conversion function registered for layer: Less yet.
Converting Preprocessor/map/while/Less_1 as custom op: Less
Warning: No conversion function registered for layer: Enter yet.
Converting Preprocessor/map/while/Less/Enter as custom op: Enter
Warning: No conversion function registered for layer: Cast yet.
Converting ToFloat as custom op: Cast
Warning: No conversion function registered for layer: Merge yet.
Converting Preprocessor/map/while/Merge_1 as custom op: Merge
Warning: No conversion function registered for layer: NextIteration yet.
Converting Preprocessor/map/while/NextIteration_1 as custom op: NextIteration
Warning: No conversion function registered for layer: Switch yet.
Converting Preprocessor/map/while/Switch as custom op: Switch
Warning: No conversion function registered for layer: Merge yet.
Converting Preprocessor/map/while/Merge as custom op: Merge
Warning: No conversion function registered for layer: NextIteration yet.
Converting Preprocessor/map/while/NextIteration as custom op: NextIteration
Warning: No conversion function registered for layer: Enter yet.
Converting Preprocessor/map/while/Enter as custom op: Enter
Warning: No conversion function registered for layer: Switch yet.
Converting Preprocessor/map/while/Switch_1 as custom op: Switch
Warning: No conversion function registered for layer: Enter yet.
Converting Preprocessor/map/while/Enter_1 as custom op: Enter
Warning: No conversion function registered for layer: Less yet.
Converting Preprocessor/map/while/Less as custom op: Less
Warning: No conversion function registered for layer: Merge yet.
Converting Preprocessor/map/while/Merge_2 as custom op: Merge
Warning: No conversion function registered for layer: NextIteration yet.
Converting Preprocessor/map/while/NextIteration_2 as custom op: NextIteration
Warning: No conversion function registered for layer: TensorArrayWriteV3 yet.
Converting Preprocessor/map/while/TensorArrayWrite/TensorArrayWriteV3 as custom op: TensorArrayWriteV3
Warning: No conversion function registered for layer: ResizeBilinear yet.
Converting Preprocessor/map/while/ResizeImage/resize_images/ResizeBilinear as custom op: ResizeBilinear
Warning: No conversion function registered for layer: TensorArrayReadV3 yet.
Converting Preprocessor/map/while/TensorArrayReadV3 as custom op: TensorArrayReadV3
Warning: No conversion function registered for layer: Enter yet.
Converting Preprocessor/map/while/TensorArrayReadV3/Enter_1 as custom op: Enter
Warning: No conversion function registered for layer: TensorArrayScatterV3 yet.
Converting Preprocessor/map/TensorArrayUnstack/TensorArrayScatter/TensorArrayScatterV3 as custom op: TensorArrayScatterV3
Warning: No conversion function registered for layer: TensorArrayV3 yet.
Converting Preprocessor/map/TensorArray as custom op: TensorArrayV3
Warning: No conversion function registered for layer: Range yet.
Converting Preprocessor/map/TensorArrayUnstack/range as custom op: Range
Warning: No conversion function registered for layer: Enter yet.
Converting Preprocessor/map/while/TensorArrayReadV3/Enter as custom op: Enter
Traceback (most recent call last):
File “tf2uff.py”, line 46, in
uff.from_tensorflow_frozen_model(frozen_file=args.frozenmodel, output_filename=output_uff_fullfname)
File “/usr/local/lib/python3.6/dist-packages/uff/converters/tensorflow/conversion_helpers.py”, line 229, in from_tensorflow_frozen_model
return from_tensorflow(graphdef, output_nodes, preprocessor, **kwargs)
File “/usr/local/lib/python3.6/dist-packages/uff/converters/tensorflow/conversion_helpers.py”, line 178, in from_tensorflow
debug_mode=debug_mode)
File “/usr/local/lib/python3.6/dist-packages/uff/converters/tensorflow/converter.py”, line 94, in convert_tf2uff_graph
uff_graph, input_replacements, debug_mode=debug_mode)
File “/usr/local/lib/python3.6/dist-packages/uff/converters/tensorflow/converter.py”, line 79, in convert_tf2uff_node
op, name, tf_node, inputs, uff_graph, tf_nodes=tf_nodes, debug_mode=debug_mode)
File “/usr/local/lib/python3.6/dist-packages/uff/converters/tensorflow/converter.py”, line 41, in convert_layer
fields = cls.parse_tf_attrs(tf_node.attr)
File “/usr/local/lib/python3.6/dist-packages/uff/converters/tensorflow/converter.py”, line 222, in parse_tf_attrs
return {key: cls.parse_tf_attr_value(val) for key, val in attrs.items() if val is not None and val.WhichOneof(‘value’) is not None}
File “/usr/local/lib/python3.6/dist-packages/uff/converters/tensorflow/converter.py”, line 222, in
return {key: cls.parse_tf_attr_value(val) for key, val in attrs.items() if val is not None and val.WhichOneof(‘value’) is not None}
File “/usr/local/lib/python3.6/dist-packages/uff/converters/tensorflow/converter.py”, line 218, in parse_tf_attr_value
return cls.convert_tf2uff_field(code, val)
File “/usr/local/lib/python3.6/dist-packages/uff/converters/tensorflow/converter.py”, line 190, in convert_tf2uff_field
return TensorFlowToUFFConverter.convert_tf2numpy_dtype(val)
File “/usr/local/lib/python3.6/dist-packages/uff/converters/tensorflow/converter.py”, line 103, in convert_tf2numpy_dtype
return tf.as_dtype(dtype).as_numpy_dtype
File “/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py”, line 126, in as_numpy_dtype
return _TF_TO_NP[self._type_enum]
KeyError: 20
root@929a8483d52a:~#

Blockquote

Hi @AastaLLL, how can we convert the pre-trained Zoo TensorFlow-model (.pb file) into uff via uffparser marking the non-supported layer as plugin?. I am using the script convert_to_uff.py, is this the right tool?. Also the sample you pointed states that it implements the network in TensorRT from the scratch?. I only need to convert the model to uff format, then run it with TensorRT C++ API via trtexec. What do you recommend?

Hi virsg,

Please help to open a new topic for your issue. Thanks