Search code examples
tensorflowtensorflow2.0faster-rcnnopenvino

Unable to convert tensorflow Mask-Rcnn to IR with Open Vino toolkit


python mo_tf.py 
--saved_model_dir C:\DATASETS\mask50000\exports\saved_model 
--output_dir C:\DATASETS\mask50000 
--reverse_input_channels 
--tensorflow_custom_operations_config extensions\front\tf\mask_rcnn_support_api_v2.0.json
--tensorflow_object_detection_api_pipeline_config C:\DATASETS\mask50000\exports\pipeline.config 
--log_level=DEBUG

I have been trying to convert the model using the above script, but every time I got the error:

"Exception: Exception occurred during running replacer "REPLACEMENT_ID (<class'extensions.front.tf.tensorflow_custom_operations_config_update.TensorflowCustomOperationsConfigUpdate'>)": The function 'update_custom_layer_attributes' must be implemented in the sub-class."

I have exported the graph using exporter_main_v2.py. If more information is needed please inform me.

EDIT: I was able to convert the model by changing the file mask_rcnn_support_api_v2.4.json.

first change: "custom_attributes": { "operation_to_add": "Proposal", "clip_before_nms": false, "clip_after_nms": true } second change: "start_points": [ "StatefulPartitionedCall/concat/concat", "StatefulPartitionedCall/concat_1/concat", "StatefulPartitionedCall/GridAnchorGenerator/Identity", "StatefulPartitionedCall/Cast", "StatefulPartitionedCall/Cast_1", "StatefulPartitionedCall/Shape" ]

that solved the problme.


Solution

  • OpenVINO 2020.4 is not compatible with TensorFlow 2. Support for TF 2.0 Object Detection API models was fully enabled only in OpenVINO 2021.3.

    I’ve successfully converted the model mask_rcnn_inception_resnet_v2_1024x1024_coco17 to IR using the latest OpenVINO release (2021.4.752).

    I share the MO conversion command here:

    python mo_tf.py --saved_model_dir <model_dir>\saved_model --tensorflow_object_detection_api_pipeline_config <pipeline_dir>\pipeline.config --transformations_config <installed_dir>\extensions\front\tf\mask_rcnn_support_api_v2.0.json"