TensorRT: Cannot converted the mask-rcnn model to uff in the sampleUffMaskRCNN sample
Description
I tried to convert the mask-rcnn model to uff at
TensorRT-7.0.0.11/samples/sampleUffMaskRCNN/converted
.
My command is
python3 mrcnn_to_trt_single.py -w ../../../data/mask_rcnn_coco.h5 -o ../../../data/mask_rcnn_coco.uff -p ./config.py
First, I met the error about setting a channel dimension.
raise ValueError('The channel dimension of the inputs '
ValueError: The channel dimension of the inputs should be defined. Found `None`.
I already solved this problem.
However, when I tried it again, I met a new error message below.
The output names of tensorflow graph nodes: ['mrcnn_mask/Reshape_1']
WARNING:tensorflow:From mrcnn_to_trt_single.py:142: convert_variables_to_constants (from tensorflow.python.framework.graph_util_impl) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.compat.v1.graph_util.convert_variables_to_constants`
WARNING:tensorflow:From /home/chieh/.local/lib/python3.6/site-packages/tensorflow/python/framework/graph_util_impl.py:270: extract_sub_graph (from tensorflow.python.framework.graph_util_impl) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.compat.v1.graph_util.extract_sub_graph`
WARNING:tensorflow:From /home/chieh/.local/lib/python3.6/site-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 /home/chieh/.local/lib/python3.6/site-packages/graphsurgeon/_utils.py:2: The name tf.NodeDef is deprecated. Please use tf.compat.v1.NodeDef instead.
Traceback (most recent call last):
File "mrcnn_to_trt_single.py", line 169, in <module>
main()
File "mrcnn_to_trt_single.py", line 128, in main
text=True, list_nodes=list_nodes)
File "mrcnn_to_trt_single.py", line 162, in convert_model
debug_mode = False
File "/home/chieh/.local/lib/python3.6/site-packages/uff/converters/tensorflow/conversion_helpers.py", line 229, in from_tensorflow_frozen_model
return from_tensorflow(graphdef, output_nodes, preprocessor, **kwargs)
File "/home/chieh/.local/lib/python3.6/site-packages/uff/converters/tensorflow/conversion_helpers.py", line 106, in from_tensorflow
pre.preprocess(dynamic_graph)
File "./config.py", line 145, in preprocess
dynamic_graph.remove(timedistributed_remove_list)
File "/home/chieh/.local/lib/python3.6/site-packages/graphsurgeon/DynamicGraph.py", line 470, in remove
nodes = self._force_to_nodes(nodes)
File "/home/chieh/.local/lib/python3.6/site-packages/graphsurgeon/DynamicGraph.py", line 324, in _force_to_nodes
buf = self._force_to_names(buf)
File "/home/chieh/.local/lib/python3.6/site-packages/graphsurgeon/DynamicGraph.py", line 307, in _force_to_names
assert False, "The name %s does not exist" % el
AssertionError: The name mrcnn_class_bn1/Reshape_5/shape does not exist
Even I got rid of those not existing name from the config.py.
timedistributed_remove_list = [
"mrcnn_class_conv1/Reshape/shape", "mrcnn_class_conv1/Reshape", "mrcnn_class_conv1/Reshape_1/shape", "mrcnn_class_conv1/Reshape_1",
"mrcnn_class_bn1/Reshape/shape", "mrcnn_class_bn1/Reshape",
"mrcnn_class_conv2/Reshape/shape", "mrcnn_class_conv2/Reshape", "mrcnn_class_conv2/Reshape_1/shape", "mrcnn_class_conv2/Reshape_1",
"mrcnn_class_bn2/Reshape/shape", "mrcnn_class_bn2/Reshape",
"mrcnn_class_logits/Reshape/shape", "mrcnn_class_logits/Reshape","mrcnn_class_logits/Reshape_1/shape", "mrcnn_class_logits/Reshape_1",
"mrcnn_class/Reshape/shape", "mrcnn_class/Reshape","mrcnn_class/Reshape_1/shape", "mrcnn_class/Reshape_1",
"mrcnn_bbox_fc/Reshape/shape", "mrcnn_bbox_fc/Reshape","mrcnn_bbox_fc/Reshape_1/shape", "mrcnn_bbox_fc/Reshape_1",
"mrcnn_mask_conv1/Reshape/shape", "mrcnn_mask_conv1/Reshape", "mrcnn_mask_conv1/Reshape_1/shape", "mrcnn_mask_conv1/Reshape_1",
"mrcnn_mask_bn1/Reshape/shape", "mrcnn_mask_bn1/Reshape",
"mrcnn_mask_conv2/Reshape/shape", "mrcnn_mask_conv2/Reshape", "mrcnn_mask_conv2/Reshape_1/shape", "mrcnn_mask_conv2/Reshape_1",
"mrcnn_mask_bn2/Reshape/shape", "mrcnn_mask_bn2/Reshape",
"mrcnn_mask_conv3/Reshape/shape", "mrcnn_mask_conv3/Reshape", "mrcnn_mask_conv3/Reshape_1/shape", "mrcnn_mask_conv3/Reshape_1",
"mrcnn_mask_bn3/Reshape/shape", "mrcnn_mask_bn3/Reshape",
"mrcnn_mask_conv4/Reshape/shape", "mrcnn_mask_conv4/Reshape", "mrcnn_mask_conv4/Reshape_1/shape", "mrcnn_mask_conv4/Reshape_1",
"mrcnn_mask_bn4/Reshape/shape", "mrcnn_mask_bn4/Reshape",
"mrcnn_mask_deconv/Reshape/shape", "mrcnn_mask_deconv/Reshape", "mrcnn_mask_deconv/Reshape_1/shape", "mrcnn_mask_deconv/Reshape_1",
"mrcnn_mask/Reshape/shape", "mrcnn_mask/Reshape", "mrcnn_mask/Reshape_1/shape", "mrcnn_mask/Reshape_1"
# "mrcnn_class_bn1/Reshape_5/shape" "mrcnn_class_bn1/Reshape_5" "mrcnn_class_bn2/Reshape_5/shape", "mrcnn_class_bn2/Reshape_5",
# "mrcnn_mask_bn1/Reshape_5/shape", "mrcnn_mask_bn1/Reshape_5" "mrcnn_mask_bn2/Reshape_5/shape", "mrcnn_mask_bn2/Reshape_5",
# "mrcnn_mask_bn3/Reshape_5/shape", "mrcnn_mask_bn3/Reshape_5", "mrcnn_mask_bn4/Reshape_5/shape", "mrcnn_mask_bn4/Reshape_5"
]
I still got the strange error.
Traceback (most recent call last):
File "mrcnn_to_trt_single.py", line 169, in <module>
main()
File "mrcnn_to_trt_single.py", line 128, in main
text=True, list_nodes=list_nodes)
File "mrcnn_to_trt_single.py", line 162, in convert_model
debug_mode = False
File "/home/chieh/.local/lib/python3.6/site-packages/uff/converters/tensorflow/conversion_helpers.py", line 229, in from_tensorflow_frozen_model
return from_tensorflow(graphdef, output_nodes, preprocessor, **kwargs)
File "/home/chieh/.local/lib/python3.6/site-packages/uff/converters/tensorflow/conversion_helpers.py", line 106, in from_tensorflow
pre.preprocess(dynamic_graph)
File "./config.py", line 149, in preprocess
connect(dynamic_graph, timedistributed_connect_pairs)
File "./config.py", line 139, in connect
if node_a_name not in dynamic_graph.node_map[node_b_name].input:
KeyError: 'mrcnn_mask_bn4/batchnorm/mul_1'
I don’t think so that I should get rid of those names from config.py actually. Is there any solution or thought about this problem?
Thank you.
Environment
- TensorRT version: 7.0.0.11 (Downloaded the tar file from NVIDIA website.)
- Cuda version: 10.2
- TensorFlow-gpu: 1.14.0
- Cudnn version: 7.6.5
- GPU: GTX1060
- Ubuntu: 18.04
- Keras : 2.3.1
PS I didn’t use the NVidia docker and NGC.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 22 (2 by maintainers)
Unfortunately, mainly I focus on developing in Python. I have also tried to develop TensorFlow with TensorRT for few month. However, TensorRT announced that they will deprecate
Hence, I was changing to use
uff parser
in the next TRT version, and you knew that TensorFlow is mainly usingUFF parser
to generate a TRT engine in TensorRT. Even I thought to use Tensorflow.pb
to.onnx
then.onnx
to.trt
, but you will find there are many unsupported operations in those converting tools. Too complicated and it will take a lot of time.Pytorch
this way. Pytorch is usingonnx parser
. Sometimes Pytorch is more kind than TensorFlow. Anyway it is just my choice and strategy on TensorRT.If your goal is only using Matterport’s MRCNN, I think it is not a hard thing. Probably you can consider to try this. tensorrt-utils
Maybe you could try with keras 2.1.3 ? There may be difference in implementation of BatchNormalization between versions.