cv516Buaa / tph-yolov5

GNU General Public License v3.0
716 stars 170 forks source link

ONNXRuntimeError #57

Open Harris-X opened 1 year ago

Harris-X commented 1 year ago

while i use the export.py to export onnx,there are some warning,but it can export onnx file:

ONNX: starting export with onnx 1.13.1...
C:\Users\Harri\1\tph-yolov5-plus\models\common.py:393: TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
  attn_mask = attn_mask.masked_fill(attn_mask != 0, torch.tensor(-100.0)).masked_fill(attn_mask == 0,
C:\Users\Harri\1\tph-yolov5-plus\models\common.py:394: TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
  torch.tensor(0.0))
C:\Users\Harri\1\tph-yolov5-plus\models\common.py:213: TracerWarning: Converting a tensor to a Python integer might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  B = int(windows.shape[0] / (H * W / window_size / window_size))
C:\Users\Harri\1\tph-yolov5-plus\models\common.py:431: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if pad_r > 0 or pad_b > 0:
C:\Users\Harri\1\tph-yolov5-plus\models\yolo.py:101: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  assert b1 == b2 and c1 == c2
C:\Users\Harri\1\tph-yolov5-plus\models\yolo.py:184: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if self.onnx_dynamic or self.grid[i].shape[2:4] != p[i].shape[2:4]:
WARNING: The shape inference of prim::Constant type is missing, so it may result in wrong shape inference for the exported graph. Please consider adding it in symbolic function.
WARNING: The shape inference of prim::Constant type is missing, so it may result in wrong shape inference for the exported graph. Please consider adding it in symbolic function.
Warning: Constant folding - Only steps=1 can be constant folded for opset >= 10 onnx::Slice op. Constant folding not applied.
WARNING: The shape inference of prim::Constant type is missing, so it may result in wrong shape inference for the exported graph. Please consider adding it in symbolic function.
WARNING: The shape inference of prim::Constant type is missing, so it may result in wrong shape inference for the exported graph. Please consider adding it in symbolic function.
Warning: Constant folding - Only steps=1 can be constant folded for opset >= 10 onnx::Slice op. Constant folding not applied.
WARNING: The shape inference of prim::Constant type is missing, so it may result in wrong shape inference for the exported graph. Please consider adding it in symbolic function.
WARNING: The shape inference of prim::Constant type is missing, so it may result in wrong shape inference for the exported graph. Please consider adding it in symbolic function.
Warning: Constant folding - Only steps=1 can be constant folded for opset >= 10 onnx::Slice op. Constant folding not applied.
ONNX: export success, saved as weights\best.onnx (168.9 MB)
ONNX: run --dynamic ONNX model inference with: 'python detect.py --weights weights\best.onnx'

while i use onnx file to inference by detect.py, it failed:

onnxruntime.capi.onnxruntime_pybind11_state.Fail: [ONNXRuntimeError] : 1 : FAIL : Node (If_737) Op (If) [TypeInferenceError] Graph attribute inferencing failed: Node (Squeeze_739) Op (Squeeze) [ShapeInferenceError] Dimension of input 3 must be 1 instead of 128

how to fix it ,thanks.

kfchandsome commented 11 months ago

你好,请问现在你解决问题了吗