YOLOv9改进策略【注意力机制篇】| 引入SimAM注意力模块(一个简单的,无参数的卷积神经网络注意模块)

一、本文介绍

本文记录的是基于SimAM注意力模块的YOLOv9目标检测方法研究SimAM注意力模块通过优化能量函数来获得每个神经元的三维权重,而无需引入额外的参数或增加计算复杂度。若是有轻量化需求的小伙伴,无参的注意力模块也许是一个不错的选择。


二、SimAM注意力原理

SimAM(A Simple, Parameter-Free Attention Module for Convolutional Neural Networks)是一种简单且无参数的注意力模块,主要用于卷积神经网络。

2.1、原理

  1. 基于神经科学理论定义能量函数
    • 在视觉神经科学中,最具信息量的神经元通常是那些与周围神经元具有不同激发模式的神经元。并且,一个活跃的神经元可能会抑制周围神经元的活动,这种现象被称为空间抑制
    • 基于此,SimAM为每个神经元定义了如下能量函数 e t ( w t , b t , y , x i ) = ( y t − t ^ ) 2 + 1 M − 1 ∑ i = 1 M − 1 ( y o − x ^ i ) 2 e_{t}\left(w_{t}, b_{t}, y, x_{i}\right)=\left(y_{t}-\hat{t}\right)^{2}+\frac{1}{M - 1} \sum_{i = 1}^{M - 1}\left(y_{o}-\hat{x}_{i}\right)^{2} et(wt,bt,y,xi)=(ytt^)2+M11i=1M1(yox^i)2,其中 t ^ = w t t + b t \hat{t}=w_{t}t + b_{t} t^=wtt+bt x ^ i = w t x i + b t \hat{x}_{i}=w_{t}x_{i}+b_{t} x^i=wtxi+bt是线性变换, t t t x i x_{i} xi是输入特征 X ∈ R C × H × W X\in R^{C\times H\times W} XRC×H×W单个通道中的目标神经元和其他神经元。 i i i是空间维度上的索引, M = H × W M = H\times W M=H×W是该通道上的神经元数量。 w t w_{t} wt b t b_{t} bt是线性变换的权重和偏置。
    • 为了简化计算,采用二进制标签(即 1 和 -1)用于 y t y_{t} yt y o y_{o} yo,并添加一个正则项,最终的能量函数为:
      e t ( w t , b t , y , x i ) = 1 M − 1 ∑ i = 1 M − 1 ( − 1 − ( w t x i + b t ) ) 2 + ( 1 − ( w t t + b t ) ) 2 + λ w t 2 e_{t}\left(w_{t}, b_{t}, y, x_{i}\right)=\frac{1}{M - 1} \sum_{i = 1}^{M - 1}\left(-1-\left(w_{t}x_{i}+b_{t}\right)\right)^{2}+\left(1-\left(w_{t}t+b_{t}\right)\right)^{2}+\lambda w_{t}^{2} et(wt,bt,y,xi)=M11i=1M1(1(wtxi+bt))2+(1(wtt+bt))2+λwt2
  2. 推导能量函数的闭式解
    • 通过对上述能量函数求解,得到关于 w t w_{t} wt b t b_{t} bt的闭式解为: w t = − 2 ( t − μ t ) ( t − μ t ) 2 + 2 σ t 2 + 2 λ w_{t}=-\frac{2\left(t-\mu_{t}\right)}{\left(t-\mu_{t}\right)^{2}+2\sigma_{t}^{2}+2\lambda} wt=(tμt)2+2σt2+2λ2(tμt) b t = − 1 2 ( t + μ t ) w t b_{t}=-\frac{1}{2}\left(t+\mu_{t}\right)w_{t} bt=21(t+μt)wt。其中 μ t = 1 M − 1 ∑ i x i \mu_{t}=\frac{1}{M - 1}\sum_{i}x_{i} μt=M11ixi σ t = 1 M − 1 ∑ i ( x i − μ t ) 2 \sigma_{t}=\sqrt{\frac{1}{M - 1}\sum_{i}\left(x_{i}-\mu_{t}\right)^{2}} σt=M11i(xiμt)2 是该通道上除(t)以外所有神经元的均值和方差。
    • 由于上述解是在单个通道上得到的,假设单个通道中的所有像素遵循相同的分布,那么可以对所有神经元计算一次均值和方差,并在该通道上重复使用,得到最小能量计算公式: e t ∗ = 4 ( σ ^ 2 + λ ) ( t − μ ^ ) 2 + 2 σ ^ 2 + 2 λ e_{t}^{*}=\frac{4\left(\hat{\sigma}^{2}+\lambda\right)}{(t-\hat{\mu})^{2}+2\hat{\sigma}^{2}+2\lambda} et=(tμ^)2+2σ^2+2λ4(σ^2+λ),其中 μ ^ = 1 M ∑ i x i \hat{\mu}=\frac{1}{M}\sum_{i}x_{i} μ^=M1ixi σ ^ 2 = 1 M ∑ i ( x i − μ ^ ) 2 \hat{\sigma}^{2}=\frac{1}{M}\sum_{i}\left(x_{i}-\hat{\mu}\right)^{2} σ^2=M1i(xiμ^)2
    • 能量 e t ∗ e_{t}^{*} et越低,神经元 t t t与周围神经元的区别就越大,在视觉处理中就越重要。因此,每个神经元的重要性可以通过 1 / e t ∗ 1/e_{t}^{*} 1/et获得。
  3. 注意力模块的特征细化
    • 根据哺乳动物大脑中的注意力调制通常表现为对神经元响应的增益效应,SimAM使用缩放运算符而不是加法来进行特征细化。整个模块的细化阶段公式为: X ~ = sigmoid ( 1 E ) ⊙ X \tilde{X}=\text{sigmoid}\left(\frac{1}{E}\right)\odot X X~=sigmoid(E1)X,其 E E E是所有通道和空间维度上的 e t ∗ e_{t}^{*} et的集合, sigmoid \text{sigmoid} sigmoid函数用于限制 E E E中的值过大,它是一个单调函数,不会影响每个神经元的相对重要性。

在这里插入图片描述

2.2、优势

  1. 全三维注意力权重
    • 与现有的注意力模块不同,SimAM可以直接推断出全三维注意力权重,同时考虑空间和通道维度,而不是只沿通道或空间维度生成一维或二维权重。这使得网络能够学习到更具判别性的特征,更好地捕捉图像中的有价值线索,与图像标签更加一致。
  2. 基于神经科学理论,可解释性强
    • SimAM基于神经科学理论设计,其实现注意力的方式是估计单个神经元的重要性,这种方法来源于对哺乳动物大脑中视觉处理机制的理解,具有较强的可解释性。相比其他大多基于启发式方法计算注意力权重的模块,SimAM更加科学合理。
  3. 参数自由
    • SimAM通过推导能量函数的闭式解,实现了无需向原始网络添加额外参数的特性。这在实际应用中具有很大的优势,轻量化,不会增加模型的复杂度和计算负担,同时能够有效地提升各种卷积神经网络在不同视觉任务中的表现。

论文:https://proceedings.mlr.press/v139/yang21o/yang21o.pdf
源码:https://github.com/ZjjConan/SimAM

三、SimAM的实现代码

SimAM模块的实现代码如下:

class SimAM(torch.nn.Module):
    def __init__(self, channels = None,out_channels = None, e_lambda = 1e-4):
        super(SimAM, self).__init__()
        self.activaton = nn.Sigmoid()
        self.e_lambda = e_lambda

    def __repr__(self):
        s = self.__class__.__name__ + '('
        s += ('lambda=%f)' % self.e_lambda)
        return s

    @staticmethod
    def get_module_name():
        return "simam"

    def forward(self, x):
        b, c, h, w = x.size()
        n = w * h - 1
        x_minus_mu_square = (x - x.mean(dim=[2,3], keepdim=True)).pow(2)
        y = x_minus_mu_square / (4 * (x_minus_mu_square.sum(dim=[2,3], keepdim=True) / n + self.e_lambda)) + 0.5

        return x * self.activaton(y) 


四、添加步骤

4.1 修改common.py

此处需要修改的文件是models/common.py

common.py中定义了网络结构的通用模块,我们想要加入新的模块就只需要将模块代码放到这个文件内即可。

4.1.1 基础模块1

模块改进方法1️⃣:直接加入SimAM模块
SimAM模块添加后如下:

在这里插入图片描述
注意❗:在4.2小节中的yolo.py文件中需要声明的模块名称为:SimAM

4.1.2 创新模块2⭐

模块改进方法2️⃣:基于SimAM模块RepNCSPELAN4

相较方法一中的直接插入注意力模块,利用注意力模块对卷积等其他模块进行改进,其新颖程度会更高一些,训练精度可能会表现的更高。

第二种改进方法是对YOLOv9中的RepNCSPELAN4模块进行改进。RepNCSPELAN4模块的创新思想是将CSPELAN相结合。CSP可以有效地分割梯度流,减少计算量的同时保持准确性。ELAN则通过灵活的层聚合方式,增强网络的学习能力。此处的改进方法是将SimAM注意力模块替换RepNCSPELAN4中的卷积模块,目的是将分流融合后的特征信息再一次利用注意力加权,而使用SimAM注意力模块会进一步减少模型参数而不破坏CSPNet的中心思想。

改进代码如下:

class SimAMRepNCSPELAN4(nn.Module):
    # csp-elan
    def __init__(self, c1, c2, c3, c4, c5=1):  # ch_in, ch_out, number, shortcut, groups, expansion
        super().__init__()
        self.c = c3//2
        self.cv1 = Conv(c1, c3, 1, 1)
        self.cv2 = nn.Sequential(RepNCSP(c3//2, c4, c5), SimAM(c4, c4))
        self.cv3 = nn.Sequential(RepNCSP(c4, c4, c5), SimAM(c4, c4))
        self.cv4 = Conv(c3+(2*c4), c2, 1, 1)

    def forward(self, x):
        y = list(self.cv1(x).chunk(2, 1))
        y.extend((m(y[-1])) for m in [self.cv2, self.cv3])
        return self.cv4(torch.cat(y, 1))

    def forward_split(self, x):
        y = list(self.cv1(x).split((self.c, self.c), 1))
        y.extend(m(y[-1]) for m in [self.cv2, self.cv3])
        return self.cv4(torch.cat(y, 1))

在这里插入图片描述

注意❗:在4.2小节中的yolo.py文件中需要声明的模块名称为:SimAMRepNCSPELAN4

4.2 修改yolo.py

此处需要修改的文件是models/yolo.py

yolo.py用于函数调用,我们只需要将common.py中定义的新的模块名添加到parse_model函数下即可。

SimAM模块以及SimAMRepNCSPELAN4模块添加后如下:

在这里插入图片描述


五、yaml模型文件

5.1 模型改进版本一

在代码配置完成后,配置模型的YAML文件。

此处以models/detect/yolov9-c.yaml为例,在同目录下创建一个用于自己数据集训练的模型文件yolov9-c-SimAM.yaml

yolov9-c.yaml中的内容复制到yolov9-c-SimAM.yaml文件下,修改nc数量等于自己数据中目标的数量。
在骨干网络的最后一层添加SimAM模块,即下方代码中的第45行,只需要填入一个参数,通道数,和前一层通道数一致还需要注意的是,由于PAN+FPN的颈部模型结构存在,层之间的匹配也要记得修改,维度要匹配上

📌 放在此处的目的是让网络能够学习到更深层的语义信息,因为此时特征图尺寸小,包含全局信息。若是希望网络能够更加关注局部信息,可尝试将注意力模块添加到网络的浅层。

📌 当然由于其即插即用的特性,加在哪里都是可以的,但是想要真的有效,还需要根据模型结构,数据集特性等多方面因素,多做实验进行验证。

# YOLOv9

# parameters
nc: 1  # 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

   # avg-conv down
   [-1, 1, ADown, [512]],  # 6-P4/16

   # elan-2 block
   [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]],  # 7

   # avg-conv down
   [-1, 1, ADown, [512]],  # 8-P5/32

   # elan-2 block
   [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]],  # 9

   [-1, 1, SimAM, [512]],  # 10  # 注意力添加在此处
  ]

# YOLOv9 head
head:
  [
   # elan-spp block
   [-1, 1, SPPELAN, [512, 256]],  # 10

   # up-concat merge
   [-1, 1, nn.Upsample, [None, 2, 'nearest']],
   [[-1, 7], 1, Concat, [1]],  # cat backbone P4

   # elan-2 block
   [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]],  # 13

   # up-concat merge
   [-1, 1, nn.Upsample, [None, 2, 'nearest']],
   [[-1, 5], 1, Concat, [1]],  # cat backbone P3

   # elan-2 block
   [-1, 1, RepNCSPELAN4, [256, 256, 128, 1]],  # 16 (P3/8-small)

   # avg-conv-down merge
   [-1, 1, ADown, [256]],
   [[-1, 14], 1, Concat, [1]],  # cat head P4

   # elan-2 block
   [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]],  # 19 (P4/16-medium)

   # avg-conv-down merge
   [-1, 1, ADown, [512]],
   [[-1, 11], 1, Concat, [1]],  # cat head P5

   # elan-2 block
   [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]],  # 22 (P5/32-large)
   
   
   # multi-level reversible auxiliary branch
   
   # routing
   [5, 1, CBLinear, [[256]]], # 23
   [7, 1, CBLinear, [[256, 512]]], # 24
   [9, 1, CBLinear, [[256, 512, 512]]], # 25
   
   # conv down
   [0, 1, Conv, [64, 3, 2]],  # 26-P1/2

   # conv down
   [-1, 1, Conv, [128, 3, 2]],  # 27-P2/4

   # elan-1 block
   [-1, 1, RepNCSPELAN4, [256, 128, 64, 1]],  # 28

   # avg-conv down fuse
   [-1, 1, ADown, [256]],  # 29-P3/8
   [[24, 25, 26, -1], 1, CBFuse, [[0, 0, 0]]], # 30  

   # elan-2 block
   [-1, 1, RepNCSPELAN4, [512, 256, 128, 1]],  # 31

   # avg-conv down fuse
   [-1, 1, ADown, [512]],  # 32-P4/16
   [[25, 26, -1], 1, CBFuse, [[1, 1]]], # 33 

   # elan-2 block
   [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]],  # 34

   # avg-conv down fuse
   [-1, 1, ADown, [512]],  # 35-P5/32
   [[26, -1], 1, CBFuse, [[2]]], # 36

   # elan-2 block
   [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]],  # 37
   
   
   
   # detection head

   # detect
   [[32, 35, 38, 17, 20, 23], 1, DualDDetect, [nc]],  # DualDDetect(A3, A4, A5, P3, P4, P5)
  ]

5.2 模型改进版本二⭐

此处同样以models/detect/yolov9-c.yaml为例,在同目录下创建一个用于自己数据集训练的模型文件yolov9-c-SimAMRepNCSPELAN4.yaml

yolov9-c.yaml中的内容复制到yolov9-c-SimAMRepNCSPELAN4.yaml文件下,修改nc数量等于自己数据中目标的数量。

📌 模型的修改方法是将骨干网络中的所有RepNCSPELAN4模块替换成SimAMRepNCSPELAN4模块使模型可以更早地聚焦于重要信息,避免在初始阶段引入过多无关或冗余特征,并且不同层之间的特征传递更加协调和有针对性,进一步加强模型性能。

# YOLOv9

# parameters
nc: 1  # 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, SimAMRepNCSPELAN4, [256, 128, 64, 1]],  # 3  修改此处

   # avg-conv down
   [-1, 1, ADown, [256]],  # 4-P3/8

   # elan-2 block
   [-1, 1, SimAMRepNCSPELAN4, [512, 256, 128, 1]],  # 5  修改此处

   # avg-conv down
   [-1, 1, ADown, [512]],  # 6-P4/16

   # elan-2 block
   [-1, 1, SimAMRepNCSPELAN4, [512, 512, 256, 1]],  # 7  修改此处

   # avg-conv down
   [-1, 1, ADown, [512]],  # 8-P5/32

   # elan-2 block
   [-1, 1, SimAMRepNCSPELAN4, [512, 512, 256, 1]],  # 9  修改此处
  ]

# YOLOv9 head
head:
  [
   # elan-spp block
   [-1, 1, SPPELAN, [512, 256]],  # 10

   # up-concat merge
   [-1, 1, nn.Upsample, [None, 2, 'nearest']],
   [[-1, 7], 1, Concat, [1]],  # cat backbone P4

   # elan-2 block
   [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]],  # 13

   # up-concat merge
   [-1, 1, nn.Upsample, [None, 2, 'nearest']],
   [[-1, 5], 1, Concat, [1]],  # cat backbone P3

   # elan-2 block
   [-1, 1, RepNCSPELAN4, [256, 256, 128, 1]],  # 16 (P3/8-small)

   # avg-conv-down merge
   [-1, 1, ADown, [256]],
   [[-1, 13], 1, Concat, [1]],  # cat head P4

   # elan-2 block
   [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]],  # 19 (P4/16-medium)

   # avg-conv-down merge
   [-1, 1, ADown, [512]],
   [[-1, 10], 1, Concat, [1]],  # cat head P5

   # elan-2 block
   [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]],  # 22 (P5/32-large)
   
   
   # multi-level reversible auxiliary branch
   
   # routing
   [5, 1, CBLinear, [[256]]], # 23
   [7, 1, CBLinear, [[256, 512]]], # 24
   [9, 1, CBLinear, [[256, 512, 512]]], # 25
   
   # conv down
   [0, 1, Conv, [64, 3, 2]],  # 26-P1/2

   # conv down
   [-1, 1, Conv, [128, 3, 2]],  # 27-P2/4

   # elan-1 block
   [-1, 1, RepNCSPELAN4, [256, 128, 64, 1]],  # 28

   # avg-conv down fuse
   [-1, 1, ADown, [256]],  # 29-P3/8
   [[23, 24, 25, -1], 1, CBFuse, [[0, 0, 0]]], # 30  

   # elan-2 block
   [-1, 1, RepNCSPELAN4, [512, 256, 128, 1]],  # 31

   # avg-conv down fuse
   [-1, 1, ADown, [512]],  # 32-P4/16
   [[24, 25, -1], 1, CBFuse, [[1, 1]]], # 33 

   # elan-2 block
   [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]],  # 34

   # avg-conv down fuse
   [-1, 1, ADown, [512]],  # 35-P5/32
   [[25, -1], 1, CBFuse, [[2]]], # 36

   # elan-2 block
   [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]],  # 37
   
   
   
   # detection head

   # detect
   [[31, 34, 37, 16, 19, 22], 1, DualDDetect, [nc]],  # DualDDetect(A3, A4, A5, P3, P4, P5)
  ]


六、成功运行结果

分别打印网络模型可以看到SimAM模块SimAMRepNCSPELAN4已经加入到模型中,并可以进行训练了。

yolov9-c-SimAM

                 from  n    params  module                                  arguments                     
  0                -1  1         0  models.common.Silence                   []                            
  1                -1  1      1856  models.common.Conv                      [3, 64, 3, 2]                 
  2                -1  1     73984  models.common.Conv                      [64, 128, 3, 2]               
  3                -1  1    212864  models.common.RepNCSPELAN4              [128, 256, 128, 64, 1]        
  4                -1  1    164352  models.common.ADown                     [256, 256]                    
  5                -1  1    847616  models.common.RepNCSPELAN4              [256, 512, 256, 128, 1]       
  6                -1  1    656384  models.common.ADown                     [512, 512]                    
  7                -1  1   2857472  models.common.RepNCSPELAN4              [512, 512, 512, 256, 1]       
  8                -1  1    656384  models.common.ADown                     [512, 512]                    
  9                -1  1   2857472  models.common.RepNCSPELAN4              [512, 512, 512, 256, 1]       
 10                -1  1         0  models.common.SimAM                     [512, 512]                    
 11                -1  1    656896  models.common.SPPELAN                   [512, 512, 256]               
 12                -1  1         0  torch.nn.modules.upsampling.Upsample    [None, 2, 'nearest']          
 13           [-1, 7]  1         0  models.common.Concat                    [1]                           
 14                -1  1   3119616  models.common.RepNCSPELAN4              [1024, 512, 512, 256, 1]      
 15                -1  1         0  torch.nn.modules.upsampling.Upsample    [None, 2, 'nearest']          
 16           [-1, 5]  1         0  models.common.Concat                    [1]                           
 17                -1  1    912640  models.common.RepNCSPELAN4              [1024, 256, 256, 128, 1]      
 18                -1  1    164352  models.common.ADown                     [256, 256]                    
 19          [-1, 14]  1         0  models.common.Concat                    [1]                           
 20                -1  1   2988544  models.common.RepNCSPELAN4              [768, 512, 512, 256, 1]       
 21                -1  1    656384  models.common.ADown                     [512, 512]                    
 22          [-1, 11]  1         0  models.common.Concat                    [1]                           
 23                -1  1   3119616  models.common.RepNCSPELAN4              [1024, 512, 512, 256, 1]      
 24                 5  1    131328  models.common.CBLinear                  [512, [256]]                  
 25                 7  1    393984  models.common.CBLinear                  [512, [256, 512]]             
 26                 9  1    656640  models.common.CBLinear                  [512, [256, 512, 512]]        
 27                 0  1      1856  models.common.Conv                      [3, 64, 3, 2]                 
 28                -1  1     73984  models.common.Conv                      [64, 128, 3, 2]               
 29                -1  1    212864  models.common.RepNCSPELAN4              [128, 256, 128, 64, 1]        
 30                -1  1    164352  models.common.ADown                     [256, 256]                    
 31  [24, 25, 26, -1]  1         0  models.common.CBFuse                    [[0, 0, 0]]                   
 32                -1  1    847616  models.common.RepNCSPELAN4              [256, 512, 256, 128, 1]       
 33                -1  1    656384  models.common.ADown                     [512, 512]                    
 34      [25, 26, -1]  1         0  models.common.CBFuse                    [[1, 1]]                      
 35                -1  1   2857472  models.common.RepNCSPELAN4              [512, 512, 512, 256, 1]       
 36                -1  1    656384  models.common.ADown                     [512, 512]                    
 37          [26, -1]  1         0  models.common.CBFuse                    [[2]]                         
 38                -1  1   2857472  models.common.RepNCSPELAN4              [512, 512, 512, 256, 1]       
 39[32, 35, 38, 17, 20, 23]  1  21542822  DualDDetect                             [1, [512, 512, 512, 256, 512, 512]]
yolov9-c-SimAM summary: 964 layers, 50999590 parameters, 50999558 gradients, 238.9 GFLOPs

yolov9-c-SimAMRepNCSPELAN4

从参数量和计算量可以看出,相较于yolov9-c-SimAM和原模型,均有减少,更加轻量。

                 from  n    params  module                                  arguments                     
  0                -1  1         0  models.common.Silence                   []                            
  1                -1  1      1856  models.common.Conv                      [3, 64, 3, 2]                 
  2                -1  1     73984  models.common.Conv                      [64, 128, 3, 2]               
  3                -1  1    138880  models.common.SimAMRepNCSPELAN4         [128, 256, 128, 64, 1]        
  4                -1  1    164352  models.common.ADown                     [256, 256]                    
  5                -1  1    552192  models.common.SimAMRepNCSPELAN4         [256, 512, 256, 128, 1]       
  6                -1  1    656384  models.common.ADown                     [512, 512]                    
  7                -1  1   1676800  models.common.SimAMRepNCSPELAN4         [512, 512, 512, 256, 1]       
  8                -1  1    656384  models.common.ADown                     [512, 512]                    
  9                -1  1   1676800  models.common.SimAMRepNCSPELAN4         [512, 512, 512, 256, 1]       
 10                -1  1    656896  models.common.SPPELAN                   [512, 512, 256]               
 11                -1  1         0  torch.nn.modules.upsampling.Upsample    [None, 2, 'nearest']          
 12           [-1, 7]  1         0  models.common.Concat                    [1]                           
 13                -1  1   3119616  models.common.RepNCSPELAN4              [1024, 512, 512, 256, 1]      
 14                -1  1         0  torch.nn.modules.upsampling.Upsample    [None, 2, 'nearest']          
 15           [-1, 5]  1         0  models.common.Concat                    [1]                           
 16                -1  1    912640  models.common.RepNCSPELAN4              [1024, 256, 256, 128, 1]      
 17                -1  1    164352  models.common.ADown                     [256, 256]                    
 18          [-1, 13]  1         0  models.common.Concat                    [1]                           
 19                -1  1   2988544  models.common.RepNCSPELAN4              [768, 512, 512, 256, 1]       
 20                -1  1    656384  models.common.ADown                     [512, 512]                    
 21          [-1, 10]  1         0  models.common.Concat                    [1]                           
 22                -1  1   3119616  models.common.RepNCSPELAN4              [1024, 512, 512, 256, 1]      
 23                 5  1    131328  models.common.CBLinear                  [512, [256]]                  
 24                 7  1    393984  models.common.CBLinear                  [512, [256, 512]]             
 25                 9  1    656640  models.common.CBLinear                  [512, [256, 512, 512]]        
 26                 0  1      1856  models.common.Conv                      [3, 64, 3, 2]                 
 27                -1  1     73984  models.common.Conv                      [64, 128, 3, 2]               
 28                -1  1    212864  models.common.RepNCSPELAN4              [128, 256, 128, 64, 1]        
 29                -1  1    164352  models.common.ADown                     [256, 256]                    
 30  [23, 24, 25, -1]  1         0  models.common.CBFuse                    [[0, 0, 0]]                   
 31                -1  1    847616  models.common.RepNCSPELAN4              [256, 512, 256, 128, 1]       
 32                -1  1    656384  models.common.ADown                     [512, 512]                    
 33      [24, 25, -1]  1         0  models.common.CBFuse                    [[1, 1]]                      
 34                -1  1   2857472  models.common.RepNCSPELAN4              [512, 512, 512, 256, 1]       
 35                -1  1    656384  models.common.ADown                     [512, 512]                    
 36          [25, -1]  1         0  models.common.CBFuse                    [[2]]                         
 37                -1  1   2857472  models.common.RepNCSPELAN4              [512, 512, 512, 256, 1]       
 38[31, 34, 37, 16, 19, 22]  1  21542822  DualDDetect                             [1, [512, 512, 512, 256, 512, 512]]
yolov9-c-SimAMRepNCSPELAN4 summary: 954 layers, 48268838 parameters, 48268806 gradients, 226.5 GFLOPs
  • 17
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Limiiiing

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值