YOLOV5_NCNN_Android icon indicating copy to clipboard operation
YOLOV5_NCNN_Android copied to clipboard

导出onnx模型时,common.py删除切片操作采用return self.conv(torch.cat([x,x,x,x], 1))替代,export.py导出模型如下操作。但是导出模型还是有slice.

Open keson1984 opened this issue 4 years ago • 7 comments

你好,我解决了自己训练的模型,部署时预测框都在左上角不对的问题了。 【1】在导出onnx模型时,common.py删除切片操作还是采用的return self.conv(torch.cat([x,x,x,x], 1))替代。然后export.py导出模型时,输入大小改为训练模型时的一半,如输入大小640时为[320, 320] image

image

【2】预测框不对是因为YoloV5.h文件中,预测层没有根据自己模型指定对,原来的是“394,“375,“output”这3层输出,可以根据Netron查看自己模型的3个预测层修改,我的是“output”,“423”,“442”,然后预测框正确。 image

image

感谢之前各位大佬的回答和分享!

Originally posted by @Skr20200701 in https://github.com/sunnyden/YOLOV5_NCNN_Android/issues/3#issuecomment-668028381

keson1984 avatar Aug 25 '20 08:08 keson1984

export.py 并没有调用common.py文件,删除comon中slice 是如何在export.py中体现。

keson1984 avatar Aug 25 '20 09:08 keson1984

export.py 并没有调用common.py文件,删除comon中slice 是如何在export.py中体现。

keson1984 avatar Aug 25 '20 09:08 keson1984

export.py 并没有调用common.py文件,删除comon中slice 是如何在export.py中体现。

keson1984 avatar Aug 25 '20 09:08 keson1984

问题解决了,是我代码问题。

keson1984 avatar Aug 26 '20 03:08 keson1984

你好,我替换了切片操作,但导出的onnx模型中仍有Slice,请问你是怎么解决的?

hideinhat avatar Aug 27 '20 02:08 hideinhat

你好,我替换了切片操作,但导出的onnx模型中仍有Slice,请问你是怎么解决的?

model.model[-1].export = True 你写成了False了吧,如果是False的话在Detect层里面还是有slice。

cmdbug avatar Aug 27 '20 06:08 cmdbug

WZTENG提到的把true改成false就可以了。

keson1984 avatar Aug 27 '20 08:08 keson1984