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

model optimizer from tensorflow throws internal error

bbberk
Beginner
2,485 Views

I have my custom tensorflow model and trying to convert it to IR format with the commands below but I get same errors. My model is trained with RGB images with the size of W:206 H:130.

model/roi_train_model folder has meta and pb files.

model_path = Path("model/roi_train_model")

mo --saved_model_dir roi_train_model --input_shape [1, 130, 206, 3] --compress_to_fp16 --model_name modelnew --framework tf

mo --saved_model_dir "model\roi_train_model" --input_shape "[1, 130, 206, 3]" --reverse_input_channels --model_name "roi_train_model" --compress_to_fp16 --output_dir out


[ 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 "REPLACEMENT_ID (<class 'openvino.tools.mo.back.ConvolutionNormalizer.ConvolutionWithGroupsResolver'>)":
[ ERROR ] Traceback (most recent call last):
File "C:\Users\BerkGungor\openvino_env\lib\site-packages\openvino\tools\mo\utils\class_registration.py", line 286, in apply_transform
for_graph_and_each_sub_graph_recursively(graph, replacer.find_and_replace_pattern)
File "C:\Users\BerkGungor\openvino_env\lib\site-packages\openvino\tools\mo\middle\pattern_match.py", line 46, in for_graph_and_each_sub_graph_recursively
func(graph)
File "C:\Users\BerkGungor\openvino_env\lib\site-packages\openvino\tools\mo\back\ConvolutionNormalizer.py", line 135, in find_and_replace_pattern
V7ConvolutionWithGroupsResolver().find_and_replace_pattern(graph)
File "C:\Users\BerkGungor\openvino_env\lib\site-packages\openvino\tools\mo\back\ConvolutionNormalizer.py", line 99, in find_and_replace_pattern
resolve_convolution_with_group(node, group, ir_version='V7')
File "C:\Users\BerkGungor\openvino_env\lib\site-packages\openvino\tools\mo\back\ConvolutionNormalizer.py", line 31, in resolve_convolution_with_group
assert weights_shape[0] % group == 0
AssertionError

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

Traceback (most recent call last):
File "C:\Users\BerkGungor\openvino_env\Lib\site-packages\openvino\tools\mo\main.py", line 50, in main
ngraph_function = convert_model(**argv)
File "C:\Users\BerkGungor\openvino_env\lib\site-packages\openvino\tools\mo\convert.py", line 47, in convert_model
return _convert(**args)
File "C:\Users\BerkGungor\openvino_env\lib\site-packages\openvino\tools\mo\convert_impl.py", line 937, in _convert
raise e.with_traceback(None)
Exception: Exception occurred during running replacer "REPLACEMENT_ID (<class 'openvino.tools.mo.back.ConvolutionNormalizer.ConvolutionWithGroupsResolver'>)":

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

4 Replies
IntelSupport
Community Manager
2,463 Views

Hi Bbberk,

 

Thanks for reaching out.

The --input_shape argument value must base on the order of dimensions and it depends on the framework input layout of a model. For a TensorFlow model, the layout is [N,C,H,W].


Try using the command below to convert your model.

mo --input_model model.pb --input_shape [1,3,130,206] --reverse_input_channels

 

 

Regards,

Aznie


0 Kudos
bbberk
Beginner
2,446 Views

Hi,

 

Thanks for the reply.  I got the below error now. Do i have to convert my model to a frozen graph or sth ?

 

mo --input_model saved_model.pb --input_shape [1,3,130,206] --reverse_input_channels
[ FRAMEWORK ERROR ] Cannot load input model: TensorFlow cannot read the model file:

"\openvino_notebooks\notebooks\101-tensorflow-to-openvino\model\roi_train_model\saved_model.pb" is incorrect TensorFlow model file.
The file should contain one of the following TensorFlow graphs:
1. frozen graph in text or binary format
2. inference graph for freezing with checkpoint (--input_checkpoint) in text or binary format
3. meta graph

Make sure that --input_model_is_text is provided for a model in text format. By default, a model is interpreted in binary format. Framework error details: Error parsing message with type 'tensorflow.GraphDef'.

0 Kudos
IntelSupport
Community Manager
2,417 Views

Hi Bbberk,

 

You have to freeze your model before converting it into Intermediate Representation (IR). Since you are converting a SavedModel, your directory should have these components:

 

1. A SavedModel Protocol Buffer 

  • your saved_model.pb/.pbtxt 
    • graph definitions as MetaGraphDef

2. Assets

  • contains auxiliary files such as vocabularies

3. Extra Assets

  • Subfolder where higher-level libraries and users can add their own assets that coexist with the model but aren't loaded by the graph.

4. Variables

  • Includes outputs from Tensorflow Saver

 

However, if you are using TensorFlow 1 model, you may convert your Non-Frozen model into IR by following the ways in the Converting Non- Frozen Model Format documentation.

 

 

Regards,

Aznie

 

0 Kudos
IntelSupport
Community Manager
2,305 Views

Hi Bbberk,

 

This thread will no longer be monitored since we have provided a solution. If you need any additional information from Intel, please submit a new question.



Regards,

Aznie


0 Kudos
Reply