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

Model Optimizer error for DeepSpeech model conversion


I tried to convert the Mozilla DeepSpeech Mode to IR model as mentioned in your page. But the converter fails with internal error:

python ./ --input_model "D:\Programming\deepSpeech\models\output_graph.pb" --freeze_placeholder_with_value "input_lengths->[16]" --input input_node,previous_state_h/read,previous_state_c/read --input_shape [1,16,19,26],[1,2048],[1,2048] --output raw_logits,lstm_fused_cell/Gather,lstm_fused_cell/Gather_1

Model Optimizer arguments:
Common parameters:
        - Path to the Input Model:      D:\Programming\deepSpeech\models\output_graph.pb
        - Path for generated IR:        C:\Intel\computer_vision_sdk\deployment_tools\model_optimizer\.
        - IR output name:       output_graph
        - Log level:    ERROR
        - Batch:        Not specified, inherited from the model
        - Input layers:         input_node,previous_state_h/read,previous_state_c/read
        - Output layers:        raw_logits,lstm_fused_cell/Gather,lstm_fused_cell/Gather_1
        - Input shapes:         [1,16,19,26],[1,2048],[1,2048]
        - Mean values:  Not specified
        - Scale values:         Not specified
        - Scale factor:         Not specified
        - Precision of IR:      FP32
        - Enable fusing:        True
        - Enable grouped convolutions fusing:   True
        - Move mean values to preprocess section:       False
        - Reverse input channels:       False
TensorFlow specific parameters:
        - Input model in text protobuf format:  False
        - Offload unsupported operations:       False
        - Path to model dump for TensorBoard:   None
        - List of shared libraries with TensorFlow custom layers implementation:        None
        - Update the configuration file with input/output node names:   None
        - Use configuration file used to generate the model with Object Detection API:  None
        - Operations to offload:        None
        - Patterns to offload:  None
        - Use the config file:  None
Model Optimizer version:
[ 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 "None (<class ''>)": 7
[ ERROR ]  Traceback (most recent call last):
  File "C:\Intel\computer_vision_sdk\deployment_tools\model_optimizer\mo\utils\", line 114, in apply_replacements
  File "C:\Intel\computer_vision_sdk\deployment_tools\model_optimizer\mo\front\common\", line 125, in find_and_replace_pattern
    apply_pattern(graph, action=self.replace_sub_graph, **self.pattern())
  File "C:\Intel\computer_vision_sdk\deployment_tools\model_optimizer\mo\middle\", line 95, in apply_pattern
    action(graph, match)
  File "C:\Intel\computer_vision_sdk\deployment_tools\model_optimizer\mo\front\common\", line 189, in replace_sub_graph
    self.replace_output_edges(graph, self.gen_output_edges_match(node, self.replace_op(graph, node)))
  File "C:\Intel\computer_vision_sdk\deployment_tools\model_optimizer\extensions\front\tf\", line 84, in replace_op
    [graph.remove_edge(node.in_node(p).id, for p, input_data in node.in_nodes().items() if p in [5, 6, 7]]
  File "C:\Intel\computer_vision_sdk\deployment_tools\model_optimizer\extensions\front\tf\", line 84, in <listcomp>
    [graph.remove_edge(node.in_node(p).id, for p, input_data in node.in_nodes().items() if p in [5, 6, 7]]
  File "C:\Intel\computer_vision_sdk\deployment_tools\model_optimizer\mo\graph\", line 329, in in_node
    return self.in_nodes(control_flow=control_flow)[key]
KeyError: 7

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

Traceback (most recent call last):
  File "C:\Intel\computer_vision_sdk\deployment_tools\model_optimizer\mo\", line 325, in main
    return driver(argv)
  File "C:\Intel\computer_vision_sdk\deployment_tools\model_optimizer\mo\", line 267, in driver
  File "C:\Intel\computer_vision_sdk\deployment_tools\model_optimizer\mo\pipeline\", line 248, in tf2nx
    class_registration.apply_replacements(graph, class_registration.ClassType.FRONT_REPLACER)
  File "C:\Intel\computer_vision_sdk\deployment_tools\model_optimizer\mo\utils\", line 127, in apply_replacements
    )) from err
Exception: Exception occurred during running replacer "None (<class ''>)": 7

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

The only thing I have changed is the quotes for the freeze placeholder value argument as it threw an error asking to use this format.

0 Kudos
2 Replies

Dear Tyurin, Sergey,

Thanks for sharing with the OpenVino community !


0 Kudos
New Contributor I

With release 0.5.1 you can use script:

@echo off

set TMP_HOME=%~dp0

set DS_HOME=%TMP_HOME:~0,-1%

set DS_MODEL_VER=deepspeech-0.5.1-models

set MO_TF="%INTEL_OPENVINO_DIR%\deployment_tools\model_optimizer\"

:: Model URL -
set OUT_GRAPH=%DS_HOME%\%DS_MODEL_VER%\output_graph.pb
set ALPHBET=%DS_HOME%\%DS_MODEL_VER%\alphabet.txt
set LM_BINARY=%DS_HOME%\%DS_MODEL_VER%\lm.binary

if not exist %DS_HOME%\tb_log (
	mkdir %DS_HOME%\tb_log

python %MO_TF% ^
--input_model %OUT_GRAPH% ^
--freeze_placeholder_with_value "input_lengths->[16]" ^
--input "input_node,previous_state_h/read,previous_state_c/read" ^
--input_shape "[1,16,19,26],[1,2048],[1,2048]" ^
--output raw_logits,lstm_fused_cell/GatherNd,lstm_fused_cell/GatherNd_1 ^
--log_level WARNING ^
--tensorboard_logdir "%DS_HOME%\tb_log"

exit /b 0


0 Kudos