作者现有的剪枝,经过测试非常有效,现有对网络修改后,再运行剪枝失败,请指教:# parameters
nc: 1 # number of classes
depth_multiple: 0.33 # model depth multiple
width_multiple: 0.50 # layer channel multiple
anchors
anchors:
- [4,4, 5,5, 5,5] # P2/4
- [5,5, 5,5, 6,6] # P3/8
- [6,6, 7,7, 8,8] # P4/16
#- [116,90, 156,198, 373,326] # P5/16
#- 4,4, 5,5, 5,5, 5,5, 5,5, 6,6, 6,6, 7,7, 8,8
YOLOv5 backbone
backbone:
[from, number, module, args]
[from, number, module, args]
[ [ -1, 1, Conv, [ 64, 6, 2, 2, 1, True, 1.0 ] ], # 0-P1/2
[ -1, 1, Conv, [ 128, 3, 2, None, 1, True, 1.0 ] ], # 1-P2/4
[ -1, 3, C3, [ 128, True, 1, [ 0.5, 0.5 ], [ 1.0, 1.0, 1.0 ], 1.0 ] ],
[ -1, 1, Conv, [ 256, 3, 2, None, 1, True, 1.0 ] ], # 3-P3/8
[ -1, 6, C3, [ 256, True, 1, [ 0.5, 0.5 ], [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ], 1.0 ] ],
[ -1, 1, Conv, [ 512, 3, 2, None, 1, True, 1.0 ] ], # 5-P4/16
[ -1, 9, C3, [ 512, True, 1, [ 0.5, 0.5 ], [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ], 1.0 ] ],
[-1, 1, Conv, [1024, 3, 2]], # 7-P5/32 去掉32倍特征图输出
[ -1, 3, C3, [ 512, True, 1, [ 0.5, 0.5 ], [ 1.0, 1.0, 1.0 ], 1.0 ] ],
[ -1, 1, SPPF, [ 512, 5, 0.5 ] ], # 9
]
YOLOv5 v6.0 head
head:
[[-1, 1, Conv, [512, 1, 1, None, 1, True, 1.0]],
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
[[-1, 4], 1, Concat, [1]], # cat backbone P3
[-1, 3, C3, [512, False, 1, [0.5, 0.5], [1.0, 1.0, 1.0], 1.0]], # 17 (P3/8-small)
[ -1, 1, Conv, [256, 1, 1, None, 1, True, 1.0]],
[ -1, 1, nn.Upsample, [ None, 2, 'nearest' ] ],
[ [ -1, 2 ], 1, Concat, [ 1 ] ], # cat backbone P2 160*160
[ -1, 3, C3, [256, False, 1, [0.5, 0.5], [1.0, 1.0, 1.0], 1.0]], # 16 (P2/4-small)
[-1, 1, Conv, [256, 3, 2, None, 1, True, 1.0]],
[[-1, 13], 1, Concat, [1]], # cat head P2
[-1, 3, C3, [256, False, 1, [0.5, 0.5], [1.0, 1.0, 1.0], 1.0]], # 20 (P3/16-medium)
[-1, 1, Conv, [256, 3, 2, None, 1, True, 1.0]],
[[-1, 9], 1, Concat, [1]], # cat head P4
[-1, 3, C3, [512, False, 1, [0.5, 0.5], [1.0, 1.0, 1.0], 1.0]], # 22 (P4/16-large)
[[16, 19, 22], 1, Detect, [nc, anchors]], # Detect(P2, P3, P4)
]