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.

Model Optimizer error for DeepSpeech model conversion

Menon__Sujeendran
431 Views

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

python ./mo_tf.py --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:        1.5.12.49d067a0
[ 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 'extensions.front.tf.BlockLSTM.BlockLSTM'>)": 7
[ ERROR ]  Traceback (most recent call last):
  File "C:\Intel\computer_vision_sdk\deployment_tools\model_optimizer\mo\utils\class_registration.py", line 114, in apply_replacements
    replacer.find_and_replace_pattern(graph)
  File "C:\Intel\computer_vision_sdk\deployment_tools\model_optimizer\mo\front\common\replacement.py", 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\pattern_match.py", line 95, in apply_pattern
    action(graph, match)
  File "C:\Intel\computer_vision_sdk\deployment_tools\model_optimizer\mo\front\common\replacement.py", 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\BlockLSTM.py", line 84, in replace_op
    [graph.remove_edge(node.in_node(p).id, node.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\BlockLSTM.py", line 84, in <listcomp>
    [graph.remove_edge(node.in_node(p).id, node.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\graph.py", 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\main.py", line 325, in main
    return driver(argv)
  File "C:\Intel\computer_vision_sdk\deployment_tools\model_optimizer\mo\main.py", line 267, in driver
    mean_scale_values=mean_scale)
  File "C:\Intel\computer_vision_sdk\deployment_tools\model_optimizer\mo\pipeline\tf.py", 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\class_registration.py", line 127, in apply_replacements
    )) from err
Exception: Exception occurred during running replacer "None (<class 'extensions.front.tf.BlockLSTM.BlockLSTM'>)": 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
Shubha_R_Intel
Employee
431 Views

Dear Tyurin, Sergey,

Thanks for sharing with the OpenVino community !

Shubha

0 Kudos
STyur
New Contributor I
431 Views

With release 0.5.1 you can use script:

@echo off
setlocal

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\mo_tf.py"

:: Model URL - https://github.com/mozilla/DeepSpeech/releases/download/v0.5.1/deepspeech-0.5.1-models.tar.gz
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
set TRIE=%DS_HOME%\%DS_MODEL_VER%\trie

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"

endlocal
exit /b 0

 

0 Kudos
Reply