如何在OpenVINO for Tacotron模型中为模型优化器设置输入形状?

问题描述 投票:3回答:1

我正在尝试使用NCS在英特尔OpenVINO上运行KeithIto的Tacotron模型。模型优化器无法将冻结模型转换为IR格式。

在英特尔论坛上询问后,我被告知2018 R5版本没有GRU支持,我将其更改为LSTM单元格。但该模型在训练后仍然在张量流中运行良好。我还将我的OpenVINO更新为2019 R1版本。但优化器仍然存在错误。该模型主要有两个输入节点:输入[N,T_in]和input_lengths [N];其中N是批量大小,T_in是输入时间序列中的步数,值是具有默认形状的字符ID,如[1,?]和[1]。问题在于[1,?],因为模型优化器不允许动态形状。我尝试了不同的值,它总是会抛出一些错误。

我尝试了带有输出节点“model / griffinlim / Squeeze”的冻结图,这是最终的解码器输出,还有(https://github.com/keithito/tacotron/issues/95#issuecomment-362854371)中提到的“model / inference / dense / BiasAdd”,它是Griffin-lim声码器的输入,因此我可以在模型外部进行Spectrogram2Wav部分并降低其复杂性。

C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\model_optimizer>python mo_tf.py --input_model "D:\Programming\LSTM\logs-tacotron\freezeinf.pb" --freeze_placeholder_with_value "input_lengths->[1]" --input inputs --input_shape [1,128] --output model/inference/dense/BiasAdd
Model Optimizer arguments:
Common parameters:
        - Path to the Input Model:      D:\Programming\Thesis\LSTM\logs-tacotron\freezeinf.pb
        - Path for generated IR:        C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\model_optimizer\.
        - IR output name:       freezeinf
        - Log level:    ERROR
        - Batch:        Not specified, inherited from the model
        - Input layers:         inputs
        - Output layers:        model/inference/dense/BiasAdd
        - Input shapes:         [1,128]
        - 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
        - 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:        2019.1.0-341-gc9b66a2
[ ERROR ]  Shape [  1  -1 128] is not fully defined for output 0 of "model/inference/post_cbhg/conv_bank/conv1d_8/batch_normalization/batchnorm/mul_1". Use --input_shape with positive integers to override model input shapes.
[ ERROR ]  Cannot infer shapes or values for node "model/inference/post_cbhg/conv_bank/conv1d_8/batch_normalization/batchnorm/mul_1".
[ ERROR ]  Not all output shapes were inferred or fully defined for node "model/inference/post_cbhg/conv_bank/conv1d_8/batch_normalization/batchnorm/mul_1".
 For more information please refer to Model Optimizer FAQ (<INSTALL_DIR>/deployment_tools/documentation/docs/MO_FAQ.html), question #40.
[ ERROR ]
[ ERROR ]  It can happen due to bug in custom shape infer function <function tf_eltwise_ext.<locals>.<lambda> at 0x000001F00598FE18>.
[ 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 'extensions.middle.PartialInfer.PartialInfer'>): Stopped shape/value propagation at "model/inference/post_cbhg/conv_bank/conv1d_8/batch_normalization/batchnorm/mul_1" node.
 For more information please refer to Model Optimizer FAQ (<INSTALL_DIR>/deployment_tools/documentation/docs/MO_FAQ.html), question #38.

我也尝试了不同的方法来冻结图形。

方法1:在转储图形后使用Tensorflow中提供的freeze_graph.py:

tf.train.write_graph(self.session.graph.as_graph_def(), "models/", "graph.pb", as_text=True)

其次是:

python freeze_graph.py --input_graph .\models\graph.pb  --output_node_names "model/griffinlim/Squeeze" --output_graph .\logs-tacotron\freezeinf.pb --input_checkpoint .\logs-tacotron\model.ckpt-33000 --input_binary=true

方法2:加载模型后使用以下代码:

frozen = tf.graph_util.convert_variables_to_constants(self.session,self.session.graph_def, ["model/inference/dense/BiasAdd"]) #model/griffinlim/Squeeze
graph_io.write_graph(frozen, "models/", "freezeinf.pb", as_text=False)

我希望在冻结后删除BatchNormalization和Dropout图层,但看看它仍然存在的错误。

环境

AS:总是10 Pro

Python 3.6.5

Tensorflow 1.12.0

OpenVINO 2019 R1发布

任何人都可以帮助解决优化器的上述问题吗?

python tensorflow text-to-speech speech-synthesis openvino
1个回答
0
投票

OpenVINO尚不支持此型号。我们会及时通知您。

© www.soinside.com 2019 - 2024. All rights reserved.