我使用TensorFlow for Poets 2 repo (https://github.com/googlecodelabs/tensorflow-for-poets-2(中的python脚本创建了一个自定义图像分类.pb模型文件。
我尝试使用以下脚本使用 OpenVino 模型优化器将其转换为中间表示:
python mo_tf.py --input_model retrained_graph.pb
python mo_tf.py --input_model retrained_graph.pb --mean_values [127.5,127.5,127.5] --input Mul
在这两种情况下,都发生了以下情况:
Model Optimizer arguments:
Common parameters:
- Path to the Input Model: C:Program Files (x86)IntelSWToolsopenvino_2019.3.379deployment_toolsmodel_optimizerretrained_graph.pb
- Path for generated IR: C:Program Files (x86)IntelSWToolsopenvino_2019.3.379deployment_toolsmodel_optimizer.
- IR output name: retrained_graph
- Log level: ERROR
- Batch: Not specified, inherited from the model
- Input layers: Not specified, inherited from the model
- Output layers: Not specified, inherited from the model
- Input shapes: Not specified, inherited from the model
- 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.3.0-408-gac8584cb7
[ ERROR ] -------------------------------------------------
[ ERROR ] ----------------- INTERNAL ERROR ----------------
[ ERROR ] Unexpected exception happened.
[ ERROR ] Please contact Model Optimizer developers and forward the following information:
[ ERROR ] local variable 'new_attrs' referenced before assignment
[ ERROR ] Traceback (most recent call last):
File "C:Program Files (x86)IntelSWToolsopenvino_2019.3.379deployment_toolsmodel_optimizermofrontextractor.py", line 608, in extract_node_attrs
supported, new_attrs = extractor(Node(graph, node))
File "C:Program Files (x86)IntelSWToolsopenvino_2019.3.379deployment_toolsmodel_optimizermopipelinetf.py", line 132, in <lambda>
extract_node_attrs(graph, lambda node: tf_op_extractor(node, check_for_duplicates(tf_op_extractors)))
File "C:Program Files (x86)IntelSWToolsopenvino_2019.3.379deployment_toolsmodel_optimizermofronttfextractor.py", line 109, in tf_op_extractor
attrs = tf_op_extractors[op](node)
File "C:Program Files (x86)IntelSWToolsopenvino_2019.3.379deployment_toolsmodel_optimizermofronttfextractor.py", line 65, in <lambda>
return lambda node: pb_extractor(node.pb)
File "C:Program Files (x86)IntelSWToolsopenvino_2019.3.379deployment_toolsmodel_optimizermofronttfextractorsconst.py", line 31, in tf_const_ext
result['value'] = tf_tensor_content(pb_tensor.dtype, result['shape'], pb_tensor)
File "C:Program Files (x86)IntelSWToolsopenvino_2019.3.379deployment_toolsmodel_optimizermofronttfextractorsutils.py", line 76, in tf_tensor_content
dtype=type_helper[0]),
UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 0: ordinal not in range(128)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:Program Files (x86)IntelSWToolsopenvino_2019.3.379deployment_toolsmodel_optimizermomain.py", line 298, in main
return driver(argv)
File "C:Program Files (x86)IntelSWToolsopenvino_2019.3.379deployment_toolsmodel_optimizermomain.py", line 247, in driver
is_binary=not argv.input_model_is_text)
File "C:Program Files (x86)IntelSWToolsopenvino_2019.3.379deployment_toolsmodel_optimizermopipelinetf.py", line 132, in tf2nx
extract_node_attrs(graph, lambda node: tf_op_extractor(node, check_for_duplicates(tf_op_extractors)))
File "C:Program Files (x86)IntelSWToolsopenvino_2019.3.379deployment_toolsmodel_optimizermofrontextractor.py", line 614, in extract_node_attrs
new_attrs['name'] if 'name' in new_attrs else '<UNKNOWN>',
UnboundLocalError: local variable 'new_attrs' referenced before assignment
[ ERROR ] ---------------- END OF BUG REPORT --------------
[ ERROR ] -------------------------------------------------
有谁知道如何解决它?
最终我找到了一个适合我的解决方案。
我检查了 OpenVino 工具包文档并发现了这个 (02/03/2020(
在"支持的拓扑"下,有一个列表,其中包含与 OpenVino 模型优化器配合使用的拓扑。使用 TensorFlow for Poets 2 创建模型时,需要确保选择模型优化器支持的架构。