You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

OpenVINO MO转换middlebury_d400.pb报形状不一致错误求解

问题描述

使用OpenVINO 2022.1版本的模型优化器转换HitNet的middlebury_d400.pb模型时,执行命令如下:

mo --input_model ../models/middlebury_d400.pb --input_shape [1,352,704,6]

对应模型可通过如下命令获取:

wget -P . -N https://storage.googleapis.com/tensorflow-graphics/models/hitnet/default_models/middlebury_d400.pb

转换过程中抛出Gather算子形状不匹配错误,关键报错信息如下:

[ ERROR ]  Check 'data_pshape[i].compatible(indices_pshape[i])' failed at core/shape_inference/include/gather_shape_inference.hpp:80:
While validating node 'v0::Gather Gather_4901 (level5/level_init/Reshape_2/Transpose[0]:f32{1,96,192,400}, level5/level_init/GatherV2_1/Cast_1[0]:i32{1,1,96,192}, level5/level_init/GatherV2_1/axis[0]:i64{}) -> ()' with friendly_name 'Gather_4901':
Shapes {1,96,192,400} and {1,1,96,192} are not consistent. data and indices must have equal or intersecting sizes until batch_dims

[ ERROR ]  offline transformations step has failed.

转换过程中出现的int64类型自动转FP32/INT32的警告属于常规类型适配,不影响转换流程,不属于报错原因。

根因分析

该错误是OpenVINO 2022.1版本新版TensorFlow前端的已知bug:解析HitNet模型中的GatherV2算子时,没有正确识别算子自带的batch_dims参数,错误按照batch_dims=0做形状校验,导致判定被索引张量和索引张量的形状不兼容。

修复方法

二选一即可:

  • 升级OpenVINO版本到2022.3或更高版本,新版前端已经修复该Gather算子的解析bug,直接运行原转换命令即可正常生成IR文件。
  • 若必须保留2022.1版本,转换时添加参数强制调用旧版TensorFlow前端即可绕过该bug,修改后的命令如下:
mo --input_model ../models/middlebury_d400.pb --input_shape [1,352,704,6] --use_legacy_frontend

转换成功后生成的xml和bin文件可直接通过OpenVINO Runtime加载推理,输入为左右目图像拼接的6通道张量,形状与指定的[1,352,704,6]一致即可。

内容的提问来源于stack exchange,提问作者Paul Wang

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.01 22:33:24