tanluren / yolov3-channel-and-layer-pruning

yolov3 yolov4 channel and layer pruning, Knowledge Distillation 层剪枝,通道剪枝,知识蒸馏
Apache License 2.0
1.5k stars 446 forks source link

onnx输出错误,和pytorch输出不一样 #117

Closed dengfenglai321 closed 3 years ago

dengfenglai321 commented 3 years ago

你好,我是用你的项目完成了训练,训练类别只有1类。然后转成onnx: 转化步骤如下:

  1. 设置model.py中的ONNX_EXPORT = True 2.运行 python detect.py 得到last.onnx文件。

用netron查看last.onnx如下,有两个输出,一个是(10647,4),一个是(10647,1) image

我用查看onnx的输出,前两个box输出(没有做nms)如下:

box[0:2] is 
[[   0.037955    0.039203     0.24276      0.3578]
 [    0.12038    0.037624     0.29324     0.31869]]

Pytorch的前两个输出(没有做nms)如下:

model output but before nms is torch.Size([1, 6552, 6])
tensor([1.43959e+01, 1.52357e+01, 9.64393e+01, 1.55816e+02, 2.89021e-05, 1.00000e+00])
tensor([4.90528e+01, 1.44612e+01, 1.13009e+02, 1.38279e+02, 2.15082e-05, 1.00000e+00])

box的差异很大!

此外,我查看onnx的置信度输出(10647,1),这个矩阵的最大值,即置信度的最大值是0.17而已!,这是不合理的。 max conf is 0.17663425207138062

我觉得是onnx的输出是不对有问题的。

请问我需要做哪些修改才能得到正确的输出? 此外我哪里的操作错误或者没有做。 谢谢