Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.
6403 Discussions

Error while converting MaskRCnn Tensorflow 2.0 model

Vishnuj
Beginner
547 Views

Hi,

 

According to the steps mentioned here: https://docs.openvino.ai/latest/openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_Object_Detection_API_Models.html

I tried to convert the MaskRCnn model available at:  https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf2_detection_zoo.md

command: 

mo --saved_model_dir /root/sharedfolder/models/mask_rcnn_inception_resnet_v2_1024x1024_coco17_gpu-8/saved_model --transformations_config /root/sharedfolder/models/mask_rcnn_inception_resnet_v2_1024x1024_coco17_gpu-8/mask_rcnn_support_api_v2.4.json --tensorflow_object_detection_api_pipeline_config /root/sharedfolder/models/mask_rcnn_inception_resnet_v2_1024x1024_coco17_gpu-8/pipeline.config" --reverse_input_channels

 

The conversion is giving me this error:

[ ERROR ]  -------------------------------------------------

[ ERROR ]  ----------------- INTERNAL ERROR ----------------

[ ERROR ]  Unexpected exception happened.

[ ERROR ]  Please contact Model Optimizer developers and forward the following information:

[ ERROR ]  Exception occurred during running replacer "ObjectDetectionAPIPreprocessor2Replacement (<class 'openvino.tools.mo.front.tf.ObjectDetectionAPI.ObjectDetectionAPIPreprocessor2Replacement'>)":

[ ERROR ]  Traceback (most recent call last):

  File "/usr/local/lib/python3.6/dist-packages/openvino/tools/mo/utils/class_registration.py", line 276, in apply_transform

    replacer.find_and_replace_pattern(graph)

  File "/usr/local/lib/python3.6/dist-packages/openvino/tools/mo/front/tf/replacement.py", line 36, in find_and_replace_pattern

    self.transform_graph(graph, desc._replacement_desc['custom_attributes'])

  File "/usr/local/lib/python3.6/dist-packages/openvino/tools/mo/front/tf/ObjectDetectionAPI.py", line 837, in transform_graph

    assert len(start_nodes) >= 1

AssertionError

 

The above exception was the direct cause of the following exception:

 

Traceback (most recent call last):

  File "/usr/local/lib/python3.6/dist-packages/openvino/tools/mo/main.py", line 533, in main

    ret_code = driver(argv)

  File "/usr/local/lib/python3.6/dist-packages/openvino/tools/mo/main.py", line 489, in driver

    graph, ngraph_function = prepare_ir(argv)

  File "/usr/local/lib/python3.6/dist-packages/openvino/tools/mo/main.py", line 407, in prepare_ir

    graph = unified_pipeline(argv)

  File "/usr/local/lib/python3.6/dist-packages/openvino/tools/mo/pipeline/unified.py", line 17, in unified_pipeline

    class_registration.ClassType.BACK_REPLACER

  File "/usr/local/lib/python3.6/dist-packages/openvino/tools/mo/utils/class_registration.py", line 328, in apply_replacements

    apply_replacements_list(graph, replacers_order)

  File "/usr/local/lib/python3.6/dist-packages/openvino/tools/mo/utils/class_registration.py", line 318, in apply_replacements_list

    num_transforms=len(replacers_order))

  File "/usr/local/lib/python3.6/dist-packages/openvino/tools/mo/utils/logger.py", line 112, in wrapper

    function(*args, **kwargs)

  File "/usr/local/lib/python3.6/dist-packages/openvino/tools/mo/utils/class_registration.py", line 306, in apply_transform

    )) from err

Exception: Exception occurred during running replacer "ObjectDetectionAPIPreprocessor2Replacement (<class 'openvino.tools.mo.front.tf.ObjectDetectionAPI.ObjectDetectionAPIPreprocessor2Replacement'>)":

 

[ ERROR ]  ---------------- END OF BUG REPORT --------------

[ ERROR ]  -------------------------------------------------

 

Please help me resolve this issue and help me to convert the Tensorflow model.

 

Thanks,

Vishnu

 

0 Kudos
1 Solution
Megat_Intel
Moderator
506 Views

Hi Vishnu,

Thank you for reaching out to us.

 

The error occurs due to using a different transformations config file.

 

The Mask R-CNN Inception ResNet V2 1024x1024 model was trained using TensorFlow 2.2, as stated in TensorFlow 2 Detection Model Zoo.

 

Thus, the correct transformations config file for the model is mask_rcnn_support_api_v2.0.json, which is to be used for Mask R-CNN topologies trained using the TensorFlow* Object Detection API version 2.0 up to 2.3.X inclusively, as mentioned in Convert TensorFlow Object Detection API Models

 

For your information, I have converted the same model using the command below:

mo --saved_model_dir /mask_rcnn_inception_resnet_v2_1024x1024_coco17_gpu-8/saved_model --transformations_config <openvino_dir>/tools/mo/front/tf/mask_rcnn_support_api_v2.0.json --tensorflow_object_detection_api_pipeline_config /mask_rcnn_inception_resnet_v2_1024x1024_coco17_gpu-8/pipeline.config --reverse_input_channels

 

 

Here are my results.

 tf_maskrcnn.png

 

 

Regards,

Megat

 

View solution in original post

0 Kudos
3 Replies
Megat_Intel
Moderator
507 Views

Hi Vishnu,

Thank you for reaching out to us.

 

The error occurs due to using a different transformations config file.

 

The Mask R-CNN Inception ResNet V2 1024x1024 model was trained using TensorFlow 2.2, as stated in TensorFlow 2 Detection Model Zoo.

 

Thus, the correct transformations config file for the model is mask_rcnn_support_api_v2.0.json, which is to be used for Mask R-CNN topologies trained using the TensorFlow* Object Detection API version 2.0 up to 2.3.X inclusively, as mentioned in Convert TensorFlow Object Detection API Models

 

For your information, I have converted the same model using the command below:

mo --saved_model_dir /mask_rcnn_inception_resnet_v2_1024x1024_coco17_gpu-8/saved_model --transformations_config <openvino_dir>/tools/mo/front/tf/mask_rcnn_support_api_v2.0.json --tensorflow_object_detection_api_pipeline_config /mask_rcnn_inception_resnet_v2_1024x1024_coco17_gpu-8/pipeline.config --reverse_input_channels

 

 

Here are my results.

 tf_maskrcnn.png

 

 

Regards,

Megat

 

0 Kudos
Vishnuj
Beginner
463 Views

Hi Megat,

Thanks for your reply. I am able to convert the model successfully. Please let me know is there any code/documentation which I can refer, to run inference on the converted MaskRCNN model.

 

Thanks,

Vishnu

0 Kudos
Megat_Intel
Moderator
436 Views

Hi Vishnu,

You can find the step-by-step instructions to implement a typical inference pipeline with the OpenVINO™ Runtime C++ API here.

 

For your information, this thread will no longer be monitored since this issue has been resolved. If you need any additional information from Intel, please submit a new question.

 

 

Regards,

Megat


0 Kudos
Reply