Conversion of optimized tensorRT .pb file to .uff file

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

  1. Optimizing .pb file of TF-GPU using tensorRT
  2. Converting .pb of tensorRT 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

Hi @bhagyashree
UFF Parser has been deprecated from TRT 7 onwards, hence we recommend you to try pb <<ONNX <<TRT conversion.
Also this is recommended to use the latest TRT version.
https://developer.nvidia.com/nvidia-tensorrt-7x-download

Thanks!

@AakankshaS Thanks for the reply. As I have mentioned, I’m using tf-gpu - v1.14, tensorRT- v5.1.5.0 and cuda -v10.0, linux - v16.04 LTS.
The error occurred on these version.

1 Like