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.

How to convert a TF model to IR models?

CaoJS
Beginner
642 Views

Hi All,

I cannot successfully convert my tensorflow model in saved_model format

My model directory is as follows:

CaoJS_0-1682654114453.png

mo version:

 mo --version
Version of Model Optimizer is: 2022.3.0-9052-9752fafe8eb-releases/2022/3

 

I tried to convert using the following command and I faced this error.

mo --saved_model_dir saved_model_0/
[ ERROR ] Cannot infer shapes or values for node "ParseExample/ParseExampleV2".
[ ERROR ] Expected DataType for argument 'dtype' not <class 'str'>.
[ ERROR ]
[ ERROR ] It can happen due to bug in custom shape infer function <function tf_native_tf_node_infer at 0x7fa16da08c10>.
[ ERROR ] Or because the node inputs have incorrect values/shapes.
[ ERROR ] Or because input shapes are incorrect (embedded to the model or passed via --input_shape).
[ ERROR ] Run Model Optimizer with --log_level=DEBUG for more information.
[ ERROR ] Exception occurred during running replacer "REPLACEMENT_ID" (<class 'openvino.tools.mo.middle.PartialInfer.PartialInfer'>): Stopped shape/value propagation at "ParseExample/ParseExampleV2" node.
For more information please refer to Model Optimizer FAQ, question #38. (https://docs.openvino.ai/latest/openvino_docs_MO_DG_prepare_model_Model_Optimizer_FAQ.html?question=38#question-38)
[ INFO ] You can also try to use new TensorFlow Frontend (preview feature as of 2022.3) by adding `--use_new_frontend` option into Model Optimizer command-line.
Find more information about new TensorFlow Frontend at https://docs.openvino.ai/latest/openvino_docs_MO_DG_TensorFlow_Frontend.html

so I added `--use_new_frontend` option into command-line and error still occur, as follows:

mo --saved_model_dir saved_model_0/ --use_new_frontend
[ ERROR ] -------------------------------------------------
[ ERROR ] ----------------- INTERNAL ERROR ----------------
[ ERROR ] Unexpected exception happened.
[ ERROR ] Please contact Model Optimizer developers and forward the following information:
[ ERROR ] Check 'TYPE_MAP().count(tf_type)' failed at src/frontends/tensorflow/src/decoder_proto.cpp:189:
FrontEnd API failed with GeneralFailure: :
Encountered unknown element type DT_STRING on an empty tensor_proto

[ ERROR ] Traceback (most recent call last):
File "/home/odin/caojingsong/openvino_env/lib/python3.8/site-packages/openvino/tools/mo/main.py", line 50, in main
ngraph_function = convert_model(**argv)
File "/home/odin/caojingsong/openvino_env/lib/python3.8/site-packages/openvino/tools/mo/convert.py", line 47, in convert_model
return _convert(**args)
File "/home/odin/caojingsong/openvino_env/lib/python3.8/site-packages/openvino/tools/mo/convert_impl.py", line 937, in _convert
raise e.with_traceback(None)
openvino._pyopenvino.GeneralFailure: Check 'TYPE_MAP().count(tf_type)' failed at src/frontends/tensorflow/src/decoder_proto.cpp:189:
FrontEnd API failed with GeneralFailure: :
Encountered unknown element type DT_STRING on an empty tensor_proto


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

How can I solve this problem?

2 Replies
Hairul_Intel
Moderator
598 Views

Hi CaoJS,

Thank you for reaching out to us.

 

If this is a custom trained model, I'd suggest you to run the Model Optimizer by specifying the following options: --input, --output, --input_shape, --reverse_input_channels and see if the conversion is successful.

 

If the error persists, please share the model files that you're converting with us for further investigation from our side.

 

Refer Model Optimizer Usage guide for more information in converting models using Model Optimizer.

 

 

Regards,

Hairul


0 Kudos
Hairul_Intel
Moderator
544 Views

Hi CaoJS,

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,

Hairul


0 Kudos
Reply