RT-DETR
RT-DETR copied to clipboard
模型导出onnx报错
Load PResNet50 state_dict /mnt/2/leejq/RTDETRV2/rtdetrv2_pytorch/onnx/../src/zoo/rtdetr/rtdetr_decoder.py:465: 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. valid_WH = torch.tensor([w, h]).to(dtype) /mnt/2/leejq/RTDETRV2/rtdetrv2_pytorch/onnx/../src/zoo/rtdetr/rtdetr_decoder.py:122: 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 reference_points.shape[-1] == 2: /mnt/2/leejq/RTDETRV2/rtdetrv2_pytorch/onnx/../src/zoo/rtdetr/rtdetr_decoder.py:129: 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! elif reference_points.shape[-1] == 4: /home/leejq/.conda/envs/RTDETR/lib/python3.8/site-packages/torch/onnx/utils.py:1703: UserWarning: The exported ONNX model failed ONNX shape inference. The model will not be executable by the ONNX Runtime. If this is unintended and you believe there is a bug, please report an issue at https://github.com/pytorch/pytorch/issues. Error reported by strict ONNX shape inference: [ShapeInferenceError] (op_type:Where, node name: /model/decoder/Where): Y has inconsistent type tensor(double) (Triggered internally at ../torch/csrc/jit/serialization/export.cpp:1484.) _C._check_onnx_proto(proto) Check export onnx model done...
使用python tools/export_onnx.py -c path/to/config -r path/to/checkpoint --check导出onnx时出现中间数据形状出错的问题,看了一下评论区只有我有这个问题,问一下大佬有没有解决办法:)
Y has inconsistent type tensor(double) (Triggered internally at ../torch/csrc/jit/serialization/export.cpp:1484.)
改啥了没;用的是最新的代码吗;贴一下你这个文件里用到where的地方;还有onnx和torch的版本
https://github.com/lyuwenyu/RT-DETR/blob/main/rtdetrv2_pytorch/src/zoo/rtdetr/rtdetrv2_decoder.py
Y has inconsistent type tensor(double) (Triggered internally at ../torch/csrc/jit/serialization/export.cpp:1484.)
改啥了没;用的是最新的代码吗;贴一下你这个文件里用到
where的地方;还有onnx和torch的版本https://github.com/lyuwenyu/RT-DETR/blob/main/rtdetrv2_pytorch/src/zoo/rtdetr/rtdetrv2_decoder.py
好的好的谢谢,我试一下:)
Y has inconsistent type tensor(double) (Triggered internally at ../torch/csrc/jit/serialization/export.cpp:1484.)
改啥了没;用的是最新的代码吗;贴一下你这个文件里用到
where的地方;还有onnx和torch的版本https://github.com/lyuwenyu/RT-DETR/blob/main/rtdetrv2_pytorch/src/zoo/rtdetr/rtdetrv2_decoder.py
这是我的版本
Y has inconsistent type tensor(double) (Triggered internally at ../torch/csrc/jit/serialization/export.cpp:1484.)
改啥了没;用的是最新的代码吗;贴一下你这个文件里用到
where的地方;还有onnx和torch的版本https://github.com/lyuwenyu/RT-DETR/blob/main/rtdetrv2_pytorch/src/zoo/rtdetr/rtdetrv2_decoder.py
代码没有进行修改
下面应该还有一个where
这是我的 刚试了一下没问题;onnx版本和你不一样
这是我的 刚试了一下没问题;onnx版本和你不一样
![]()
好的谢谢大佬。我改一下版本试一下
请问报这种警告对onnx推理和pytorch直推的性能差异不会有影响吗?目前我们自己测试中发现对于同一张图片,使用转得的.onnx和使用pytorch直推,两者之间的结果存在一定差异,如推理得到的所有实例类别不同。 rtdetr_decoder.py:128: 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 reference_points.shape[-1] == 2: rtdetr_decoder.py:134: 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!
这是我的 刚试了一下没问题;onnx版本和你不一样
![]()