X2Paddle icon indicating copy to clipboard operation
X2Paddle copied to clipboard

ONNX 转 PaddlePaddle 报错 incomplete shape inference

Open bright1109 opened this issue 2 years ago • 0 comments

问题描述

错误

Stopping at incomplete shape inference at Add: x2paddle_992 RuntimeError: Inferred shape and existing shape differ in dimension 0: (0) vs (3)

完整错误输出

INFO:root:paddle.__version__ = 2.3.2
.local/lib/python3.7/site-packages/onnx/mapping.py:25: DeprecationWarning: `np.object` is a deprecated alias for the builtin `object`. To silence this warning, use `object` by itself. Doing this will not modify any behavior and is safe. 
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
  int(TensorProto.STRING): np.dtype(np.object)
INFO:root:Now translating model from onnx to paddle.
model ir_version: 6, op version: 11
shape inferencing ...
/home/tianyating/.local/lib/python3.7/site-packages/x2paddle/decoder/onnx_shape_inference.py:510: DeprecationWarning: np.asscalar(a) is deprecated since NumPy v1.16, use a.item() instead
  new_v = int(np.asscalar(v))
Stopping at incomplete shape inference at Add: x2paddle_992
node inputs:
name: "x2paddle_991"
type {
  tensor_type {
    elem_type: 1
    shape {
      dim {
        dim_value: 1
      }
      dim {
        dim_value: 256
      }
      dim {
        dim_param: "floor(floor(floor(floor(Pad26_o0__d1/2 - 1/2)/2)/2)/2) + 1"
      }
      dim {
        dim_param: "floor(floor(floor(floor(Pad26_o0__d2/2 - 1/2)/2)/2)/2) + 1"
      }
    }
  }
}

name: "x2paddle_990"
type {
  tensor_type {
    elem_type: 1
    shape {
      dim {
        dim_value: 1
      }
      dim {
        dim_value: 256
      }
      dim {
        dim_param: "floor(2.0*floor(floor(floor(floor(floor(Pad26_o0__d1/2 - 1/2)/2)/2)/2)/2) + 2.0)"
      }
      dim {
        dim_param: "floor(2.0*floor(floor(floor(floor(floor(Pad26_o0__d2/2 - 1/2)/2)/2)/2)/2) + 2.0)"
      }
    }
  }
}

node outputs:
name: "x2paddle_992"
type {
  tensor_type {
    elem_type: 1
    shape {
      dim {
        dim_value: 1
      }
      dim {
        dim_value: 256
      }
      dim {
      }
      dim {
      }
    }
  }
}

!!!!!!!!!!
(op_type:Slice, name:x2paddle_634): Inferred shape and existing shape differ in dimension 0: (0) vs (3)
[WARNING] Incomplete symbolic shape inference
(op_type:Slice, name:x2paddle_634): Inferred shape and existing shape differ in dimension 0: (0) vs (3)
Traceback (most recent call last):
  File "/home/tianyating/.local/lib/python3.7/site-packages/x2paddle/decoder/onnx_shape_inference.py", line 1606, in infer_shapes
    symbolic_shape_inference.out_mp_)
  File "/home/tianyating/.local/lib/python3.7/site-packages/onnx/shape_inference.py", line 35, in infer_shapes
    inferred_model_str = C.infer_shapes(model_str)
RuntimeError: Inferred shape and existing shape differ in dimension 0: (0) vs (3)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/tianyating/.local/bin/x2paddle", line 8, in <module>
    sys.exit(main())
  File "/home/tianyating/.local/lib/python3.7/site-packages/x2paddle/convert.py", line 488, in main
    enable_onnx_checker=args.enable_onnx_checker)
  File "/home/tianyating/.local/lib/python3.7/site-packages/x2paddle/convert.py", line 295, in onnx2paddle
    model = ONNXDecoder(model_path, enable_onnx_checker)
  File "/home/tianyating/.local/lib/python3.7/site-packages/x2paddle/decoder/onnx_decoder.py", line 430, in __init__
    self.graph = ONNXGraph(onnx_model)
  File "/home/tianyating/.local/lib/python3.7/site-packages/x2paddle/decoder/onnx_decoder.py", line 186, in __init__
    onnx_model, fixed_input_shape=self.fixed_input_shape)
  File "/home/tianyating/.local/lib/python3.7/site-packages/x2paddle/decoder/onnx_shape_inference.py", line 1610, in infer_shapes
    symbolic_shape_inference.out_mp_)
  File "/home/tianyating/.local/lib/python3.7/site-packages/onnx/shape_inference.py", line 35, in infer_shapes
    inferred_model_str = C.infer_shapes(model_str)
RuntimeError: Inferred shape and existing shape differ in dimension 0: (0) vs (3)

具体信息

  • 转换模型后用处

    • [x] 使用 Paddle 框架/ PaddleInference 推理预测
    • [ ] 使用 Paddle-Lite 做移动端推理
    • [ ] 转换预训练参数,再使用 Paddle 进行模型开发
  • 模型来源 Detectron2: https://github.com/facebookresearch/detectron2/tree/main/projects/DensePose 后来我将 DensePose 从 Detectron2 中提取了出来,删除了训练部分的代码。

  • 版本信息 PaddlePaddle => 2.3.2 X2Paddle => 1.3.9 来源框架版本(PyTorch/TF/ONNX/Caffe) => PyTorch 1.8.0

  • 您的联系方式(邮箱/微信/电话) => 微信:13269881213

我调试了很久,还是没有调出来,期待您的联系与指点迷津!鞠躬.png

bright1109 avatar Oct 08 '22 11:10 bright1109