Computer vision 转换TensorFlow模型时OpenVino模型优化器错误

Computer vision 转换TensorFlow模型时OpenVino模型优化器错误,computer-vision,object-recognition,openvino,tensorflow-slim,movidius,Computer Vision,Object Recognition,Openvino,Tensorflow Slim,Movidius,我已经使用TensorFlow for Poets 2 repo()中的python脚本创建了一个自定义图像分类.pb模型文件 我尝试使用以下脚本使用OpenVino模型优化器将其转换为中间表示: python-mo\u-tf.py--input\u-model-retained\u-graph.pb python mo_tf.py--input_model retained_graph.pb--mean_值[127.5127.5127.5]--input Mul 在这两种情况下都是这样: Mo

我已经使用TensorFlow for Poets 2 repo()中的python脚本创建了一个自定义图像分类.pb模型文件

我尝试使用以下脚本使用OpenVino模型优化器将其转换为中间表示:

python-mo\u-tf.py--input\u-model-retained\u-graph.pb

python mo_tf.py--input_model retained_graph.pb--mean_值[127.5127.5127.5]--input Mul

在这两种情况下都是这样:

Model Optimizer arguments:
Common parameters:
        - Path to the Input Model:      C:\Program Files (x86)\IntelSWTools\openvino_2019.3.379\deployment_tools\model_optimizer\retrained_graph.pb
        - Path for generated IR:        C:\Program Files (x86)\IntelSWTools\openvino_2019.3.379\deployment_tools\model_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)\IntelSWTools\openvino_2019.3.379\deployment_tools\model_optimizer\mo\front\extractor.py", line 608, in extract_node_attrs
    supported, new_attrs = extractor(Node(graph, node))
  File "C:\Program Files (x86)\IntelSWTools\openvino_2019.3.379\deployment_tools\model_optimizer\mo\pipeline\tf.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)\IntelSWTools\openvino_2019.3.379\deployment_tools\model_optimizer\mo\front\tf\extractor.py", line 109, in tf_op_extractor
    attrs = tf_op_extractors[op](node)
  File "C:\Program Files (x86)\IntelSWTools\openvino_2019.3.379\deployment_tools\model_optimizer\mo\front\tf\extractor.py", line 65, in <lambda>
    return lambda node: pb_extractor(node.pb)
  File "C:\Program Files (x86)\IntelSWTools\openvino_2019.3.379\deployment_tools\model_optimizer\mo\front\tf\extractors\const.py", line 31, in tf_const_ext
    result['value'] = tf_tensor_content(pb_tensor.dtype, result['shape'], pb_tensor)
  File "C:\Program Files (x86)\IntelSWTools\openvino_2019.3.379\deployment_tools\model_optimizer\mo\front\tf\extractors\utils.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)\IntelSWTools\openvino_2019.3.379\deployment_tools\model_optimizer\mo\main.py", line 298, in main
    return driver(argv)
  File "C:\Program Files (x86)\IntelSWTools\openvino_2019.3.379\deployment_tools\model_optimizer\mo\main.py", line 247, in driver
    is_binary=not argv.input_model_is_text)
  File "C:\Program Files (x86)\IntelSWTools\openvino_2019.3.379\deployment_tools\model_optimizer\mo\pipeline\tf.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)\IntelSWTools\openvino_2019.3.379\deployment_tools\model_optimizer\mo\front\extractor.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 ]  ------------------------------------------------- 
模型优化器参数:
通用参数:
-输入模型的路径:C:\Program Files(x86)\IntelSWTools\openvino\u 2019.3.379\deployment\u tools\Model\u optimizer\retrained\u graph.pb
-生成的IR的路径:C:\Program Files(x86)\IntelSWTools\openvino\u 2019.3.379\deployment\u tools\model\u optimizer\。
-IR输出名称:重新训练的_图
-日志级别:错误
-批处理:未指定,从模型继承
-输入层:未指定,从模型继承
-输出层:未指定,从模型继承
-输入形状:未指定,从模型继承
-平均值:未指定
-比例值:未指定
-比例系数:未指定
-红外光谱精度:FP32
-启用熔断:真
-启用分组卷积融合:True
-将平均值移动到预处理部分:False
-反向输入通道:错误
TensorFlow特定参数:
-文本protobuf格式的输入模型:False
-张力板的模型转储路径:无
-带有TensorFlow自定义层实现的共享库列表:无
-使用输入/输出节点名称更新配置文件:无
-使用用于生成具有对象检测API的模型的配置文件:无
-卸载操作:无
-要卸载的模式:无
-使用配置文件:无
模型优化器版本:2019.3.0-408-gac8584cb7
[错误]-------------------------------------------------
[错误]--------------内部错误----------------
[错误]发生意外异常。
[错误]请联系模型优化器开发人员并转发以下信息:
[错误]赋值前引用的局部变量“new_attrs”
[错误]回溯(最近一次呼叫上次):
文件“C:\Program Files(x86)\IntelSWTools\openvino\u 2019.3.379\deployment\u tools\model\u optimizer\mo\front\extractor.py”,第608行,在extract\u node\u attrs中
支持,新属性=提取器(节点(图形,节点))
文件“C:\Program Files(x86)\IntelSWTools\openvino\u 2019.3.379\deployment\u tools\model\u optimizer\mo\pipeline\tf.py”,第132行,在
提取节点属性(图,lambda节点:tf\u op\u提取器(节点,检查重复项(tf\u op\u提取器)))
文件“C:\Program Files(x86)\IntelSWTools\openvino\u 2019.3.379\deployment\u tools\model\u optimizer\mo\front\tf\extractor.py”,第109行,在tf\u op\u提取器中
attrs=tf_op_提取器[op](节点)
文件“C:\Program Files(x86)\IntelSWTools\openvino\u 2019.3.379\deployment\u tools\model\u optimizer\mo\front\tf\extractor.py”,第65行,在
返回lambda节点:pb_提取器(node.pb)
文件“C:\Program Files(x86)\IntelSWTools\openvino\u 2019.3.379\deployment\u tools\model\u optimizer\mo\front\tf\extractors\const.py”,tf\u const\u ext第31行
结果['value']=tf_张量内容(pb_tensor.dtype,结果['shape'],pb_张量)
文件“C:\Program Files(x86)\IntelSWTools\openvino\u 2019.3.379\deployment\u tools\model\u optimizer\mo\front\tf\extractors\utils.py”,tf\u tensor\u内容第76行
dtype=type_helper[0]),
UnicodeDecodeError:“ascii”编解码器无法解码位置0中的字节0xff:序号不在范围内(128)
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“C:\Program Files(x86)\IntelSWTools\openvino\u 2019.3.379\deployment\u tools\model\u optimizer\mo\main.py”,第298行,主目录
返回驱动器(argv)
驱动程序中的文件“C:\Program Files(x86)\IntelSWTools\openvino\u 2019.3.379\deployment\u tools\model\u optimizer\mo\main.py”,第247行
is_binary=非argv。输入_model_为_text)
文件“C:\Program Files(x86)\IntelSWTools\openvino\u 2019.3.379\deployment\u tools\model\u optimizer\mo\pipeline\tf.py”,第132行,在tf2nx中
提取节点属性(图,lambda节点:tf\u op\u提取器(节点,检查重复项(tf\u op\u提取器)))
文件“C:\Program Files(x86)\IntelSWTools\openvino\u 2019.3.379\deployment\u tools\model\u optimizer\mo\front\extractor.py”,第614行,在extract\u node\u attrs中
new_attrs['name']如果new_attrs else“”中的'name',
UnboundLocalError:赋值前引用的局部变量“new\u attrs”
[错误]------------错误报告结束--------------
[错误]------------------------------------

有人知道如何修复吗?

最终我找到了一个适合我的解决方案

我查看了OpenVino工具包文档,发现(2020年3月2日)

在“支持的拓扑”下有一个列表,其中列出了与OpenVino模型优化器一起工作的拓扑。使用TensorFlow for Poeters 2创建模型时,需要确保选择模型优化器支持的体系结构