0

I have truncated version of vgg16 in .pb format. I am unable to convert to IR using OpenVino Model Optimizer getting following error:

[ ANALYSIS INFO ] It looks like there is IteratorGetNext as input Run the Model Optimizer with: --input "IteratorGetNext:0[-1 224 224 3]" And replace all negative values with positive values [ ERROR ] Exception occurred during running replacer "REPLACEMENT_ID" (): Graph contains 0 node after executing . It considered as error because resulting IR will be empty which is not usual

python3 /opt/intel/openvino_2020.3.194/deployment_tools/model_optimizer/mo_tf.py --input_model model.pb

With *.meta

python3 /opt/intel/openvino_2020.3.194/deployment_tools/model_optimizer/mo_tf.py --input_meta_graph model.meta --log_level DEBUG


[ 2020-06-11 10:59:34,182 ] [ DEBUG ] [ main:213 ]  Placeholder shapes : None
'extensions.back.ScalarConstNormalize.RangeInputNormalize'>
|  310 |  True   | <class 'extensions.back.AvgPool.AvgPool'>
|  311 |  True   | <class 'extensions.back.ReverseInputChannels.ApplyReverseChannels'>
|  312 |  True   | <class 'extensions.back.split_normalizer.SplitNormalizer'>
|  313 |  True   | <class 'extensions.back.ParameterToPlaceholder.ParameterToInput'>
|  314 |  True   | <class 'extensions.back.GroupedConvWeightsNormalize.GroupedConvWeightsNormalize'>
|  315 |  True   | <class 'extensions.back.ConvolutionNormalizer.DeconvolutionNormalizer'>
|  316 |  True   | <class 'extensions.back.StridedSliceMasksNormalizer.StridedSliceMasksNormalizer'>
|  317 |  True   | <class 'extensions.back.ConvolutionNormalizer.ConvolutionWithGroupsResolver'>
|  318 |  True   | <class 'extensions.back.ReshapeMutation.ReshapeMutation'>
|  319 |  True   | <class 'extensions.back.ForceStrictPrecision.ForceStrictPrecision'>
|  320 |  True   | <class 'extensions.back.I64ToI32.I64ToI32'>
|  321 |  True   | <class 'extensions.back.ReshapeMutation.DisableReshapeMutationInTensorIterator'>
|  322 |  True   | <class 'extensions.back.ActivationsNormalizer.ActivationsNormalizer'>
|  323 |  True   | <class 'extensions.back.pass_separator.BackFinish'>
|  324 |  False  | <class 'extensions.back.SpecialNodesFinalization.RemoveConstOps'>
|  325 |  False  | <class 'extensions.back.SpecialNodesFinalization.CreateConstNodesReplacement'>
|  326 |  True   | <class 'extensions.back.kaldi_remove_memory_output.KaldiRemoveMemoryOutputBackReplacementPattern'>
|  327 |  False  | <class 'extensions.back.SpecialNodesFinalization.RemoveOutputOps'>
|  328 |  True   | <class 'extensions.back.blob_normalizer.BlobNormalizer'>
|  329 |  False  | <class 'extensions.middle.MulFakeQuantizeFuse.MulFakeQuantizeFuse'>
|  330 |  False  | <class 'extensions.middle.AddFakeQuantizeFuse.AddFakeQuantizeFuse'>
[ 2020-06-11 10:59:34,900 ] [ DEBUG ] [ class_registration:282 ]  Run replacer <class 'extensions.load.tf.loader.TFLoader'>
[ INFO ]  Restoring parameters from %s
[ WARNING ]  From %s: %s (from %s) is deprecated and will be removed %s.
Instructions for updating:
%s
[ WARNING ]  From %s: %s (from %s) is deprecated and will be removed %s.
Instructions for updating:
%s
[ FRAMEWORK ERROR ]  Cannot load input model: Attempting to use uninitialized value metrics/accuracy/total
     [[{{node _retval_metrics/accuracy/total_0_54}}]]
[ 2020-06-11 10:59:35,760 ] [ DEBUG ] [ main:328 ]  Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/tensorflow_core/python/client/session.py", line 1365, in _do_call
    return fn(*args)
  File "/usr/local/lib/python3.7/site-packages/tensorflow_core/python/client/session.py", line 1350, in _run_fn
    target_list, run_metadata)
  File "/usr/local/lib/python3.7/site-packages/tensorflow_core/python/client/session.py", line 1443, in _call_tf_sessionrun
    run_metadata)
tensorflow.python.framework.errors_impl.FailedPreconditionError: Attempting to use uninitialized value metrics/accuracy/total
     [[{{node _retval_metrics/accuracy/total_0_54}}]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/intel/openvino_2020.3.194/deployment_tools/model_optimizer/mo/front/tf/loader.py", line 220, in load_tf_graph_def
    outputs)
  File "/usr/local/lib/python3.7/site-packages/tensorflow_core/python/util/deprecation.py", line 324, in new_func
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/tensorflow_core/python/framework/graph_util_impl.py", line 330, in convert_variables_to_constants
    returned_variables = sess.run(variable_names)
  File "/usr/local/lib/python3.7/site-packages/tensorflow_core/python/client/session.py", line 956, in run
    run_metadata_ptr)
  File "/usr/local/lib/python3.7/site-packages/tensorflow_core/python/client/session.py", line 1180, in _run
    feed_dict_tensor, options, run_metadata)
  File "/usr/local/lib/python3.7/site-packages/tensorflow_core/python/client/session.py", line 1359, in _do_run
    run_metadata)
  File "/usr/local/lib/python3.7/site-packages/tensorflow_core/python/client/session.py", line 1384, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.FailedPreconditionError: Attempting to use uninitialized value metrics/accuracy/total
     [[{{node _retval_metrics/accuracy/total_0_54}}]]

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

Traceback (most recent call last):
  File "/opt/intel/openvino_2020.3.194/deployment_tools/model_optimizer/mo/utils/class_registration.py", line 288, in apply_transform
    for_graph_and_each_sub_graph_recursively(graph, replacer.find_and_replace_pattern)
  File "/opt/intel/openvino_2020.3.194/deployment_tools/model_optimizer/mo/middle/pattern_match.py", line 58, in for_graph_and_each_sub_graph_recursively
    func(graph)
  File "/opt/intel/openvino_2020.3.194/deployment_tools/model_optimizer/extensions/load/loader.py", line 27, in find_and_replace_pattern
    self.load(graph)
  File "/opt/intel/openvino_2020.3.194/deployment_tools/model_optimizer/extensions/load/tf/loader.py", line 58, in load
    saved_model_tags=argv.saved_model_tags)
  File "/opt/intel/openvino_2020.3.194/deployment_tools/model_optimizer/mo/front/tf/loader.py", line 231, in load_tf_graph_def
    raise FrameworkError('Cannot load input model: {}', e) from e
mo.utils.error.FrameworkError: Cannot load input model: Attempting to use uninitialized value metrics/accuracy/total
     [[{{node _retval_metrics/accuracy/total_0_54}}]]

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

Traceback (most recent call last):
  File "/opt/intel/openvino_2020.3.194/deployment_tools/model_optimizer/mo/main.py", line 312, in main
    ret_code = driver(argv)
  File "/opt/intel/openvino_2020.3.194/deployment_tools/model_optimizer/mo/main.py", line 273, in driver
    ret_res = emit_ir(prepare_ir(argv), argv)
  File "/opt/intel/openvino_2020.3.194/deployment_tools/model_optimizer/mo/main.py", line 238, in prepare_ir
    graph = unified_pipeline(argv)
  File "/opt/intel/openvino_2020.3.194/deployment_tools/model_optimizer/mo/pipeline/unified.py", line 29, in unified_pipeline
    class_registration.ClassType.BACK_REPLACER
  File "/opt/intel/openvino_2020.3.194/deployment_tools/model_optimizer/mo/utils/class_registration.py", line 334, in apply_replacements
    apply_replacements_list(graph, replacers_order)
  File "/opt/intel/openvino_2020.3.194/deployment_tools/model_optimizer/mo/utils/class_registration.py", line 324, in apply_replacements_list
    num_transforms=len(replacers_order))
  File "/opt/intel/openvino_2020.3.194/deployment_tools/model_optimizer/mo/utils/logger.py", line 124, in wrapper
    function(*args, **kwargs)
  File "/opt/intel/openvino_2020.3.194/deployment_tools/model_optimizer/mo/utils/class_registration.py", line 306, in apply_transform
    raise FrameworkError('{}'.format(str(err))) from err
mo.utils.error.FrameworkError: Cannot load input model: Attempting to use uninitialized value metrics/accuracy/total
     [[{{node _retval_metrics/accuracy/total_0_54}}]]
Muhammad
  • 720
  • 6
  • 13

1 Answers1

1

The problem is that models trained in TensorFlow have some shapes undefined. In your case, it looks like batch of the input is not defined. To fix it, please add an additional argument to the command line: -b 1. The option sets batch to 1. It should fix this particular issue.

After that, I guess, you may encounter other issues so I would leave the following link: Converting a TensorFlow Model. There are some tips about how to convert TensorFlow model to IR.

Artemy Skrebkov
  • 346
  • 1
  • 8
  • After inserting `-b 1` it gives this error now: Cannot load input model: NodeDef expected inputs 'float' do not match 0 inputs specified; Op output:out_type; attr=T:type; attr=out_type:type,default=DT_INT32,allowed=[DT_INT32, DT_INT64]>; NodeDef: {{node Shape_1}} – Muhammad Jun 10 '20 at 05:03
  • Oh. Hard to say what happened. Any chance to share your model or at least to run the model optimizer with debug logs (--log_level=DEBUG) and attach a text file with logs somewhere here? – Artemy Skrebkov Jun 10 '20 at 09:06
  • So i tried with check pointed graph *.meta, as I think frozen graph is not valid. I am attaching the whole log: python3 /opt/intel/openvino_2020.3.194/deployment_tools/model_optimizer/mo_tf.py --input_meta_graph restored_model/model.meta --log_level=DEBUG – Muhammad Jun 10 '20 at 17:43
  • I would recommend to froze the graph instead of trying to work with the meta model of it. Please refer to [the link](https://docs.openvinotoolkit.org/latest/_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_TensorFlow.html#freeze-the-tensorflow-model) to learn how to froze the graph correctly. After that please specify `-b 1` or you can try to specify the input shape directly like this `--input_shape [1,224,224,3]`. If it does not work, please attach logs. – Artemy Skrebkov Jun 11 '20 at 10:14