专栏介绍:YOLOv9改进系列 | 包含深度学习最新创新,助力高效涨点!!!
1. 文件说明
在YOLOv5-v9,模型的结构是以yaml文件的存储。我们可以在原有的yaml基础上增、减、改模块,创作我们自己的模型。
2. 改进示例
以下分别以ACmix与C2f-SCConv为例,演示如何加入到YOLOv9-c.yaml文件中。
2.1 加入ACmix
2.1.1创建yaml文件
首先复制一个yolov9-c.yaml文件,重命名为yolov9-ACmix-SCConv.yaml(其他命名也可)
2.1.2 加入模块
在想加入ACmix模块的位置,按照使用说明的格式(或查看ACmix模块所需的初始化参数)插入模块。这里以在“#9”层后加入为例:
2.1.3 函数说明
使用说明中的格式与ACmix的“init”函数。
2.1 加入C2f-SCConv
查看C2f-SCConv的使用说明,需要填入的参数为c2,即输出通道数,其他括号中的参数可不填。
# 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
# YOLOv9 backbone
backbone:
[
[-1, 1, Silence, []],
# conv down
[-1, 1, Conv, [64, 3, 2]], # 1-P1/2
# conv down
[-1, 1, Conv, [128, 3, 2]], # 2-P2/4
# elan-1 block
[-1, 1, RepNCSPELAN4, [256, 128, 64, 1]], # 3
# avg-conv down
[-1, 1, ADown, [256]], # 4-P3/8
# elan-2 block
[-1, 1, RepNCSPELAN4, [512, 256, 128, 1]], # 5
[-1, 1, C2fSCConv, [512]], # 6
# avg-conv down
[-1, 1, ADown, [512]], # 7-P4/16
# elan-2 block
[-1, 1, RepNCSPELAN4, [512, 512, 256, 1]], # 8
# avg-conv down
[-1, 1, ADown, [512]], # 9-P5/32
# elan-2 block
[-1, 1, RepNCSPELAN4, [512, 512, 256, 1]], # 10
[-1, 1, ACmix, [7]], # 11
]
# YOLOv9 head
head:
[
# elan-spp block
[-1, 1, SPPELAN, [512, 256]], # 12
# up-concat merge
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
[[-1, 8], 1, Concat, [1]], # cat backbone P4
# elan-2 block
[-1, 1, RepNCSPELAN4, [512, 512, 256, 1]], # 15
# up-concat merge
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
[[-1, 6], 1, Concat, [1]], # cat backbone P3
# elan-2 block
[-1, 1, RepNCSPELAN4, [256, 256, 128, 1]], # 18 (P3/8-small)
# avg-conv-down merge
[-1, 1, ADown, [256]],
[[-1, 15], 1, Concat, [1]], # cat head P4
# elan-2 block
[-1, 1, RepNCSPELAN4, [512, 512, 256, 1]], # 21 (P4/16-medium)
# avg-conv-down merge
[-1, 1, ADown, [512]],
[[-1, 12], 1, Concat, [1]], # cat head P5
# elan-2 block
[-1, 1, RepNCSPELAN4, [512, 512, 256, 1]], # 24 (P5/32-large)
# multi-level reversible auxiliary branch
# routing
[6, 1, CBLinear, [[256]]], # 25
[8, 1, CBLinear, [[256, 512]]], # 26
[11, 1, CBLinear, [[256, 512, 512]]], # 27
# conv down
[0, 1, Conv, [64, 3, 2]], # 28-P1/2
# conv down
[-1, 1, Conv, [128, 3, 2]], # 29-P2/4
# elan-1 block
[-1, 1, RepNCSPELAN4, [256, 128, 64, 1]], # 30
# avg-conv down fuse
[-1, 1, ADown, [256]], # 31-P3/8
[[25, 26, 27, -1], 1, CBFuse, [[0, 0, 0]]], # 32
# elan-2 block
[-1, 1, RepNCSPELAN4, [512, 256, 128, 1]], # 33
# avg-conv down fuse
[-1, 1, ADown, [512]], # 34-P4/16
[[26, 27, -1], 1, CBFuse, [[1, 1]]], # 35
# elan-2 block
[-1, 1, RepNCSPELAN4, [512, 512, 256, 1]], # 36
# avg-conv down fuse
[-1, 1, ADown, [512]], # 37-P5/32
[[27, -1], 1, CBFuse, [[2]]], # 38
# elan-2 block
[-1, 1, RepNCSPELAN4, [512, 512, 256, 1]], # 39
# detection head
# detect
[[33, 36, 39, 18, 21, 24], 1, DualDDetect, [nc]], # DualDDetect(A3, A4, A5, P3, P4, P5)
]
3 运行查看结果
欢迎关注!