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.
6502 Discussions

Model Optimizer error: ConstSwitchResolver.ConstSwitchEraser

G___Lukas
Beginner
563 Views

Hi guys,

i trained a SSD textbox detector in tensorflow by following this steps: https://github.com/mvoelk/ssd_detectors/blob/master/TBPP_train.ipynb . It uses their SSD512 network (https://github.com/mvoelk/ssd_detectors/blob/master/ssd_model.py#L211) to predict bounding boxes around text snippes in an image.

I converted the trained keras model to a tensorflow .pb file and now i am trying to convert this graph with the Model Optimizer with this arguments:

python mo_tf.py --input_model model/tf_model.pb --output_dir model/ --input_shape [1,512,512,3] --input "input_1" --output "predictions/concat" --log_level=DEBUG

Here is the trained model tf_model.pb:

https://www.dropbox.com/s/pjitdr0eea8zl6d/tf_model.pb?dl=0

 

Unfortunately, i got the following error:

16237
16238
16239
16240
16241
I0903 12:32:30.234732  3004 class_registration.py:267] Run replacer <class 'extensions.middle.ConstSwitchResolver.ConstSwitchEraser'>
E0903 12:32:30.291608  3004 main.py:313] -------------------------------------------------
E0903 12:32:30.291608  3004 main.py:314] ----------------- INTERNAL ERROR ----------------
E0903 12:32:30.292580  3004 main.py:315] Unexpected exception happened.
E0903 12:32:30.292580  3004 main.py:316] Please contact Model Optimizer developers and forward the following information:
E0903 12:32:30.293576  3004 main.py:317] Exception occurred during running replacer "REPLACEMENT_ID (<class 'extensions.middle.ConstSwitchResolver.ConstSwitchEraser'>)": 0
E0903 12:32:30.295570  3004 main.py:318] Traceback (most recent call last):
  File "C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\model_optimizer\mo\utils\class_registration.py", line 273, in apply_replacements
    for_graph_and_each_sub_graph_recursively(graph, replacer.find_and_replace_pattern)
  File "C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\model_optimizer\mo\middle\pattern_match.py", line 58, in for_graph_and_each_sub_graph_recursively
    func(graph)
  File "C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\model_optimizer\extensions\middle\ConstSwitchResolver.py", line 39, in find_and_replace_pattern
    remove_op_node_with_data_node(graph, switch_op_node)
  File "C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\model_optimizer\mo\middle\passes\eliminate.py", line 227, in remove_op_node_with_data_node
    input_data_node = node_to_remove.in_node()
  File "C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\model_optimizer\mo\graph\graph.py", line 174, in in_node
    return self.in_nodes(control_flow=control_flow)[key]
KeyError: 0

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

Traceback (most recent call last):
  File "C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\model_optimizer\mo\main.py", line 302, in main
    return driver(argv)
  File "C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\model_optimizer\mo\main.py", line 251, in driver
    is_binary=not argv.input_model_is_text)
  File "C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\model_optimizer\mo\pipeline\tf.py", line 134, in tf2nx
    class_registration.apply_replacements(graph, class_registration.ClassType.MIDDLE_REPLACER)
  File "C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\model_optimizer\mo\utils\class_registration.py", line 299, in apply_replacements
    )) from err
Exception: Exception occurred during running replacer "REPLACEMENT_ID (<class 'extensions.middle.ConstSwitchResolver.ConstSwitchEraser'>)": 0

E0903 12:32:30.296602  3004 main.py:319] ---------------- END OF BUG REPORT --------------
E0903 12:32:30.297564  3004 main.py:320] -------------------------------------------------

 

There are some Tensorflow Object detection API configs for SSD models, which do not help me because of the different implementation. Can someone help me with this problem ?

Best regards

 

 

 

 

0 Kudos
2 Replies
HemanthKum_G_Intel
563 Views

Hi Lukas,

I think the model has to frozen before passing to Model Optimizer. Check the solution provided by my colleague in https://software.intel.com/en-us/forums/computer-vision/topic/783716

0 Kudos
Shubha_R_Intel
Employee
563 Views

Dear G., Lukas,

First kindly make sure that the model is frozen. as Hemanth suggested. Please also post your log with --log_level DEBUG. The main thing I am wondering about, are there any -1 in your shapes preceding the error ? If so, Model Optimizer would be unable to infer shapes. If you see such -1 in the shape values (N,C,H,W)  or rather in Tensorflow's case, (N,H,W,C) then it's a problem - you need to fix that in your model before you move forward.

Let us know,

Thanks,

shubha

 

0 Kudos
Reply