打开微信,使用扫一扫进入页面后,点击右上角菜单,
点击“发送给朋友”或“分享到朋友圈”完成分享
在算法移植的时候遇到点问题,向各位请教一下,先谢谢各位的解答。
附件中是YOLOV5-4.0降低版本的pt文件。
git地址:PyTorch 框架的 Yolov5 移植 – 寒武纪开发者社区 (cambricon.com),操作步骤如下:
1、在Windows 系统上实现的pt文件的降低版本,使用的yolov5版本分别为4.0、5.0和6.0,生成unzip.pt,增加的代码:torch.save(model.state_dict(), "unzip.pt", _use_new_zipfile_serialization=False),生成的文件大小都与yolov5s_1.3a.pt不同,请问这个yolov5s_1.3a.pt是如何得到的?是否需要其他操作?
2、然后将unzip.pt拷贝到在线检测quantize_online目录下,修改yolo.py的get_model函数,将yolov5s_1.3a.pt修改成unzip.pt,然后运行quant.py,生成yolov5s_int8.pt文件。如果使用yolov5s_1.3a.pt生成的int8文件是可以检测的。转换结果如下:
CNML: 7.10.2 ba2048758
CNRT: 4.10.1 a884a9a
Using CPU
from n params module arguments
0 -1 1 3520 common.Focus [3, 32, 3]
1 -1 1 18560 common.Conv [32, 64, 3, 2]
2 -1 1 19904 common.BottleneckCSP [64, 64, 1]
3 -1 1 73984 common.Conv [64, 128, 3, 2]
4 -1 1 161152 common.BottleneckCSP [128, 128, 3]
5 -1 1 295424 common.Conv [128, 256, 3, 2]
6 -1 1 641792 common.BottleneckCSP [256, 256, 3]
7 -1 1 1180672 common.Conv [256, 512, 3, 2]
8 -1 1 656896 common.SPP [512, 512, [5, 9, 13]]
9 -1 1 1248768 common.BottleneckCSP [512, 512, 1, False]
10 -1 1 131584 common.Conv [512, 256, 1, 1]
11 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest']
12 [-1, 6] 1 0 common.Concat [1]
13 -1 1 378624 common.BottleneckCSP [512, 256, 1, False]
14 -1 1 33024 common.Conv [256, 128, 1, 1]
15 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest']
16 [-1, 4] 1 0 common.Concat [1]
17 -1 1 95104 common.BottleneckCSP [256, 128, 1, False]
18 -1 1 147712 common.Conv [128, 128, 3, 2]
19 [-1, 14] 1 0 common.Concat [1]
20 -1 1 313088 common.BottleneckCSP [256, 256, 1, False]
21 -1 1 590336 common.Conv [256, 256, 3, 2]
22 [-1, 10] 1 0 common.Concat [1]
23 -1 1 1248768 common.BottleneckCSP [512, 512, 1, False]
24 [17, 20, 23] 1 229245 yolo.Detect [80, [[10, 13, 16, 30, 33, 23], [30, 61, 62, 45, 59, 119], [116, 90, 156, 198, 373, 326]], [128, 256, 512]]
Model Summary: 191 layers, 7.46816e+06 parameters, 7.46816e+06 gradients
The 'iteration' key in qconfig has been deprecated in this version. Users needn't
set this key. We will calculate quantization parameters by real forward times controlled by users.
torch.Size([1, 3, 640, 640])
3、运行detect.py,检测不到结果,如下:
CNML: 7.10.2 ba2048758
CNRT: 4.10.1 a884a9a
Using CPU
from n params module arguments
0 -1 1 3520 common.Focus [3, 32, 3]
1 -1 1 18560 common.Conv [32, 64, 3, 2]
2 -1 1 19904 common.BottleneckCSP [64, 64, 1]
3 -1 1 73984 common.Conv [64, 128, 3, 2]
4 -1 1 161152 common.BottleneckCSP [128, 128, 3]
5 -1 1 295424 common.Conv [128, 256, 3, 2]
6 -1 1 641792 common.BottleneckCSP [256, 256, 3]
7 -1 1 1180672 common.Conv [256, 512, 3, 2]
8 -1 1 656896 common.SPP [512, 512, [5, 9, 13]]
9 -1 1 1248768 common.BottleneckCSP [512, 512, 1, False]
10 -1 1 131584 common.Conv [512, 256, 1, 1]
11 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest']
12 [-1, 6] 1 0 common.Concat [1]
13 -1 1 378624 common.BottleneckCSP [512, 256, 1, False]
14 -1 1 33024 common.Conv [256, 128, 1, 1]
15 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest']
16 [-1, 4] 1 0 common.Concat [1]
17 -1 1 95104 common.BottleneckCSP [256, 128, 1, False]
18 -1 1 147712 common.Conv [128, 128, 3, 2]
19 [-1, 14] 1 0 common.Concat [1]
20 -1 1 313088 common.BottleneckCSP [256, 256, 1, False]
21 -1 1 590336 common.Conv [256, 256, 3, 2]
22 [-1, 10] 1 0 common.Concat [1]
23 -1 1 1248768 common.BottleneckCSP [512, 512, 1, False]
24 [17, 20, 23] 1 29667 yolo.Detect [6, [[10, 13, 16, 30, 33, 23], [30, 61, 62, 45, 59, 119], [116, 90, 156, 198, 373, 326]], [128, 256, 512]]
Model Summary: 191 layers, 7.26858e+06 parameters, 7.26858e+06 gradients
torch.Size([1, 3, 640, 640])
y.shape: torch.Size([1, 33, 80, 80])
y.shape: torch.Size([1, 33, 40, 40])
y.shape: torch.Size([1, 33, 20, 20])
batchNum: 1
torch.Size([1, 7232, 1, 1])
num_boxes_final: 0.0
[tensor([], size=(0, 6))]
请问如何解决?
热门帖子
精华帖子