专栏介绍:YOLOv9改进系列 | 包含深度学习最新创新,主力高效涨点!!!
B站链接:YOLOv9去除辅助训练分支!_哔哩哔哩_bilibili
一、说明
在subbranch_removal.py脚本中,我们需要填入上方两个参数,第一个是训练好权重文件,第二个是去掉辅助分支后的模型配置文件,以YOLOv9-c为例,对应去掉辅助分支后的模型配置文件为glen-c.yaml。
运行脚本,会在填入的weights路径下生成converted.pt文件,即为精简后的版本。
对比
以下为glen-c.yaml。
# YOLOv9
# parameters
nc: 80 # number of classes
depth_multiple: 1.0 # model depth multiple
width_multiple: 1.0 # layer channel multiple
#activation: nn.LeakyReLU(0.1)
#activation: nn.ReLU()
# anchors
anchors: 3
# gelan backbone
backbone:
[
# conv down
[-1, 1, Conv, [64, 3, 2]], # 0-P1/2
# conv down
[-1, 1, Conv, [128, 3, 2]], # 1-P2/4
# elan-1 block
[-1, 1, RepNCSPELAN4, [256, 128, 64, 1]], # 2
# avg-conv down
[-1, 1, ADown, [256]], # 3-P3/8
# elan-2 block
[-1, 1, RepNCSPELAN4, [512, 256, 128, 1]], # 4
# avg-conv down
[-1, 1, ADown, [512]], # 5-P4/16
# elan-2 block
[-1, 1, RepNCSPELAN4, [512, 512, 256, 1]], # 6
# avg-conv down
[-1, 1, ADown, [512]], # 7-P5/32
# elan-2 block
[-1, 1, RepNCSPELAN4, [512, 512, 256, 1]], # 8
]
# gelan head
head:
[
# elan-spp block
[-1, 1, SPPELAN, [512, 256]], # 9
# up-concat merge
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
[[-1, 6], 1, Concat, [1]], # cat backbone P4
# elan-2 block
[-1, 1, RepNCSPELAN4, [512, 512, 256, 1]], # 12
# up-concat merge
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
[[-1, 4], 1, Concat, [1]], # cat backbone P3
# elan-2 block
[-1, 1, RepNCSPELAN4, [256, 256, 128, 1]], # 15 (P3/8-small)
# avg-conv-down merge
[-1, 1, ADown, [256]],
[[-1, 12], 1, Concat, [1]], # cat head P4
# elan-2 block
[-1, 1, RepNCSPELAN4, [512, 512, 256, 1]], # 18 (P4/16-medium)
# avg-conv-down merge
[-1, 1, ADown, [512]],
[[-1, 9], 1, Concat, [1]], # cat head P5
# elan-2 block
[-1, 1, RepNCSPELAN4, [512, 512, 256, 1]], # 21 (P5/32-large)
# detect
[[15, 18, 21], 1, DDetect, [nc]], # DDetect(P3, P4, P5)
]