学习资源站

YOLOv11改进-添加注意力篇-利用SENetV2改进网络结构(全网独家改进,含二次创新C2PSA,SPPF)

一、本文介绍

本文给大家带来的改进机制是 SENetV2 其是一种通过调整卷积网络中的通道关系来提升性能的网络结构。SENet并不是一个独立的网络 模型 ,而是一个可以和现有的任何一个模型相结合的模块 ( 可以看作是一种通道型的注意力机制但是相对于SENetV1来说V2又在全局的角度进行了考虑 ) 。在SENet中,所谓的 挤压和激励 (Squeeze-and-Excitation)操作是作为一个单元添加到传统的卷积网络结构中,如残差单元中 ( 文章中我会把修改好的残差单元给大家大家直接复制粘贴即可使用 ) 亲测大中小三中目标检测上都有一定程度的涨点效果,含二次创新SPPF、C2PSA机制.。



二、SENetV2框架原理

论文地址: 官方论文地址点击即可跳转

代码地址: 官方代码地址点击即可跳转


SENetV2介绍了一种改进的SENet架构 该架构通过引入一种称为Squeeze aggregated excitation(SaE)的新模块来提升网络的表征能力。这个模块结合了挤压和激励 ( SENetV1 ) 操作,通过多分支全连接层增强了网络的全局表示学习。在基准数据集上的实验结果证明了SENetV2模型相较于现有模型在分类精度上的显著提升。这一架构尤其强调在仅略微增加模型参数的情况下,如何有效地提高模型的性能。

挤压和激励模块大家可以看我发的SENetV1文章里面有介绍。

图中展示了三种不同的 神经网络 模块对比:

a) ResNeXt模块:采用多分支CNN结构,不同分支的特征图通过卷积操作处理后合并(concatenate),再进行额外的卷积操作。

b) SENet模块:标准卷积操作后,利用全局平均池化来挤压特征,然后通过两个尺寸为1x1的全连接层(FC)和Sigmoid 激活函数 来获取通道权重,最后对卷积特征进行缩放(Scale)。

c) SENetV2模块:结合了ResNeXt和SENet的特点,采用多分支全连接层(FC)来挤压和激励操作,最后进行特征缩放。

其中SENetV2的设计旨在通过多分支结构进一步提升特征表达的精细度和全局信息的整合能力。

前面我们提到了SaE,就是SENetV2相对于SENetV1的主要改进机制,下面的图片介绍了其内部工作原理。

SENet V2中所提出的SaE(Squeeze-and-Excitation)模块的内部工作机制。挤压输出后,被输入到多分支的全连接(FC)层,然后进行激励过程。分割的输入在最后被传递以恢复其原始形状。这种设计能够让网络更有效地学习到输入数据的不同特征,并且在进行特征转换时考虑到不同通道之间的相互依赖性。


三、SENetV2核心代码

下面的代码是SENetV2的核心代码,我们将其复制导'ultralytics/nn'目录下,在其中创建一个文件,我这里起名为SENetV2然后粘贴进去,其余使用方式看章节四。

  1. import torch
  2. import torch.nn as nn
  3. __all__ = ['C2PSA_SENetV2', 'SELayerV2', 'SPPFSENetV2']
  4. # 定义SE模块
  5. class SELayer(nn.Module):
  6. def __init__(self, channel, reduction=16):
  7. super(SELayer, self).__init__()
  8. self.avg_pool = nn.AdaptiveAvgPool2d(1)
  9. self.fc = nn.Sequential(
  10. nn.Linear(channel, channel // reduction, bias=False),
  11. nn.ReLU(inplace=True),
  12. nn.Linear(channel // reduction, channel, bias=False),
  13. nn.Sigmoid()
  14. )
  15. def forward(self, x):
  16. b, c, _, _ = x.size()
  17. y = self.avg_pool(x).view(b, c)
  18. y = self.fc(y).view(b, c, 1, 1)
  19. return x * y.expand_as(x)
  20. # 定义SaE模块
  21. class SELayerV2(nn.Module):
  22. def __init__(self, in_channel, reduction=16):
  23. super(SELayerV2, self).__init__()
  24. assert in_channel >= reduction and in_channel % reduction == 0, 'invalid in_channel in SaElayer'
  25. self.reduction = reduction
  26. self.cardinality = 4
  27. self.avg_pool = nn.AdaptiveAvgPool2d(1)
  28. # cardinality 1
  29. self.fc1 = nn.Sequential(
  30. nn.Linear(in_channel, in_channel // self.reduction, bias=False),
  31. nn.ReLU(inplace=True)
  32. )
  33. # cardinality 2
  34. self.fc2 = nn.Sequential(
  35. nn.Linear(in_channel, in_channel // self.reduction, bias=False),
  36. nn.ReLU(inplace=True)
  37. )
  38. # cardinality 3
  39. self.fc3 = nn.Sequential(
  40. nn.Linear(in_channel, in_channel // self.reduction, bias=False),
  41. nn.ReLU(inplace=True)
  42. )
  43. # cardinality 4
  44. self.fc4 = nn.Sequential(
  45. nn.Linear(in_channel, in_channel // self.reduction, bias=False),
  46. nn.ReLU(inplace=True)
  47. )
  48. self.fc = nn.Sequential(
  49. nn.Linear(in_channel // self.reduction * self.cardinality, in_channel, bias=False),
  50. nn.Sigmoid()
  51. )
  52. def forward(self, x):
  53. b, c, _, _ = x.size()
  54. y = self.avg_pool(x).view(b, c)
  55. y1 = self.fc1(y)
  56. y2 = self.fc2(y)
  57. y3 = self.fc3(y)
  58. y4 = self.fc4(y)
  59. y_concate = torch.cat([y1, y2, y3, y4], dim=1)
  60. y_ex_dim = self.fc(y_concate).view(b, c, 1, 1)
  61. return x * y_ex_dim.expand_as(x)
  62. def autopad(k, p=None, d=1): # kernel, padding, dilation
  63. """Pad to 'same' shape outputs."""
  64. if d > 1:
  65. k = d * (k - 1) + 1 if isinstance(k, int) else [d * (x - 1) + 1 for x in k] # actual kernel-size
  66. if p is None:
  67. p = k // 2 if isinstance(k, int) else [x // 2 for x in k] # auto-pad
  68. return p
  69. class Conv(nn.Module):
  70. """Standard convolution with args(ch_in, ch_out, kernel, stride, padding, groups, dilation, activation)."""
  71. default_act = nn.SiLU() # default activation
  72. def __init__(self, c1, c2, k=1, s=1, p=None, g=1, d=1, act=True):
  73. """Initialize Conv layer with given arguments including activation."""
  74. super().__init__()
  75. self.conv = nn.Conv2d(c1, c2, k, s, autopad(k, p, d), groups=g, dilation=d, bias=False)
  76. self.bn = nn.BatchNorm2d(c2)
  77. self.act = self.default_act if act is True else act if isinstance(act, nn.Module) else nn.Identity()
  78. def forward(self, x):
  79. """Apply convolution, batch normalization and activation to input tensor."""
  80. return self.act(self.bn(self.conv(x)))
  81. def forward_fuse(self, x):
  82. """Perform transposed convolution of 2D data."""
  83. return self.act(self.conv(x))
  84. class PSABlock(nn.Module):
  85. """
  86. PSABlock class implementing a Position-Sensitive Attention block for neural networks.
  87. This class encapsulates the functionality for applying multi-head attention and feed-forward neural network layers
  88. with optional shortcut connections.
  89. Attributes:
  90. attn (Attention): Multi-head attention module.
  91. ffn (nn.Sequential): Feed-forward neural network module.
  92. add (bool): Flag indicating whether to add shortcut connections.
  93. Methods:
  94. forward: Performs a forward pass through the PSABlock, applying attention and feed-forward layers.
  95. Examples:
  96. Create a PSABlock and perform a forward pass
  97. >>> psablock = PSABlock(c=128, attn_ratio=0.5, num_heads=4, shortcut=True)
  98. >>> input_tensor = torch.randn(1, 128, 32, 32)
  99. >>> output_tensor = psablock(input_tensor)
  100. """
  101. def __init__(self, c, attn_ratio=0.5, num_heads=4, shortcut=True) -> None:
  102. """Initializes the PSABlock with attention and feed-forward layers for enhanced feature extraction."""
  103. super().__init__()
  104. self.attn = SELayerV2(c)
  105. self.ffn = nn.Sequential(Conv(c, c * 2, 1), Conv(c * 2, c, 1, act=False))
  106. self.add = shortcut
  107. def forward(self, x):
  108. """Executes a forward pass through PSABlock, applying attention and feed-forward layers to the input tensor."""
  109. x = x + self.attn(x) if self.add else self.attn(x)
  110. x = x + self.ffn(x) if self.add else self.ffn(x)
  111. return x
  112. class C2PSA_SENetV2(nn.Module):
  113. """
  114. C2PSA module with attention mechanism for enhanced feature extraction and processing.
  115. This module implements a convolutional block with attention mechanisms to enhance feature extraction and processing
  116. capabilities. It includes a series of PSABlock modules for self-attention and feed-forward operations.
  117. Attributes:
  118. c (int): Number of hidden channels.
  119. cv1 (Conv): 1x1 convolution layer to reduce the number of input channels to 2*c.
  120. cv2 (Conv): 1x1 convolution layer to reduce the number of output channels to c.
  121. m (nn.Sequential): Sequential container of PSABlock modules for attention and feed-forward operations.
  122. Methods:
  123. forward: Performs a forward pass through the C2PSA module, applying attention and feed-forward operations.
  124. Notes:
  125. This module essentially is the same as PSA module, but refactored to allow stacking more PSABlock modules.
  126. Examples:
  127. >>> c2psa = C2PSA(c1=256, c2=256, n=3, e=0.5)
  128. >>> input_tensor = torch.randn(1, 256, 64, 64)
  129. >>> output_tensor = c2psa(input_tensor)
  130. """
  131. def __init__(self, c1, c2, n=1, e=0.5):
  132. """Initializes the C2PSA module with specified input/output channels, number of layers, and expansion ratio."""
  133. super().__init__()
  134. assert c1 == c2
  135. self.c = int(c1 * e)
  136. self.cv1 = Conv(c1, 2 * self.c, 1, 1)
  137. self.cv2 = Conv(2 * self.c, c1, 1)
  138. self.m = nn.Sequential(*(PSABlock(self.c, attn_ratio=0.5, num_heads=self.c // 64) for _ in range(n)))
  139. def forward(self, x):
  140. """Processes the input tensor 'x' through a series of PSA blocks and returns the transformed tensor."""
  141. a, b = self.cv1(x).split((self.c, self.c), dim=1)
  142. b = self.m(b)
  143. return self.cv2(torch.cat((a, b), 1))
  144. class SPPFSENetV2(nn.Module):
  145. """Spatial Pyramid Pooling - Fast (SPPF) layer for YOLOv5 by Glenn Jocher."""
  146. def __init__(self, c1, c2, k=5):
  147. """
  148. Initializes the SPPF layer with given input/output channels and kernel size.
  149. This module is equivalent to SPP(k=(5, 9, 13)).
  150. """
  151. super().__init__()
  152. c_ = c1 // 2 # hidden channels
  153. self.cv1 = Conv(c1, c_, 1, 1)
  154. self.cv2 = Conv(c_ * 4, c2, 1, 1)
  155. self.m = nn.MaxPool2d(kernel_size=k, stride=1, padding=k // 2)
  156. self.h = nn.AvgPool2d(kernel_size=k, stride=1, padding=k // 2)
  157. self.Att = SELayerV2(c1)
  158. def forward(self, x):
  159. """Forward pass through Ghost Convolution block."""
  160. x = self.Att(x)
  161. y = [self.cv1(x)]
  162. y.extend(self.m(y[-1]) for _ in range(3))
  163. return self.cv2(torch.cat(y, 1))
  164. if __name__ == "__main__":
  165. # Generating Sample image
  166. image_size = (1, 64, 240, 240)
  167. image = torch.rand(*image_size)
  168. # Model
  169. mobilenet_v1 = SPPFSENetV2(64, 64)
  170. out = mobilenet_v1(image)
  171. print(out.size())


四、手把手教你添加SENetV2模块

4.1 修改一

第一还是建立文件,我们找到如下 ultralytics /nn文件夹下建立一个目录名字呢就是'Addmodules'文件夹( 用群内的文件的话已经有了无需新建) !然后在其内部建立一个新的py文件将核心代码复制粘贴进去即可。


4.2 修改二

第二步我们在该目录下创建一个新的py文件名字为'__init__.py'( 用群内的文件的话已经有了无需新建) ,然后在其内部导入我们的检测头如下图所示。


4.3 修改三

第三步我门中到如下文件'ultralytics/nn/tasks.py'进行导入和注册我们的模块( 用群内的文件的话已经有了无需重新导入直接开始第四步即可)

从今天开始以后的教程就都统一成这个样子了,因为我默认大家用了我群内的文件来进行修改!!


4.4 修改四

按照我的添加在parse_model里添加即可。


到此就修改完成了,大家可以复制下面的yaml文件运行。


五、SENetV2的yaml文件和运行记录

5.1 C2PSA-SENetV2的yaml文件

此版本训练信息:YOLO11-C2PSA-SENetV2 summary: 324 layers, 2,551,579 parameters, 2,551,563 gradients, 6.4 GFLOPs

  1. # Ultralytics YOLO 🚀, AGPL-3.0 license
  2. # YOLO11 object detection model with P3-P5 outputs. For Usage examples see https://docs.ultralytics.com/tasks/detect
  3. # Parameters
  4. nc: 80 # number of classes
  5. scales: # model compound scaling constants, i.e. 'model=yolo11n.yaml' will call yolo11.yaml with scale 'n'
  6. # [depth, width, max_channels]
  7. n: [0.50, 0.25, 1024] # summary: 319 layers, 2624080 parameters, 2624064 gradients, 6.6 GFLOPs
  8. s: [0.50, 0.50, 1024] # summary: 319 layers, 9458752 parameters, 9458736 gradients, 21.7 GFLOPs
  9. m: [0.50, 1.00, 512] # summary: 409 layers, 20114688 parameters, 20114672 gradients, 68.5 GFLOPs
  10. l: [1.00, 1.00, 512] # summary: 631 layers, 25372160 parameters, 25372144 gradients, 87.6 GFLOPs
  11. x: [1.00, 1.50, 512] # summary: 631 layers, 56966176 parameters, 56966160 gradients, 196.0 GFLOPs
  12. # YOLO11n backbone
  13. backbone:
  14. # [from, repeats, module, args]
  15. - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2
  16. - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4
  17. - [-1, 2, C3k2, [256, False, 0.25]]
  18. - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8
  19. - [-1, 2, C3k2, [512, False, 0.25]]
  20. - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16
  21. - [-1, 2, C3k2, [512, True]]
  22. - [-1, 1, Conv, [1024, 3, 2]] # 7-P5/32
  23. - [-1, 2, C3k2, [1024, True]]
  24. - [-1, 1, SPPF, [1024, 5]] # 9
  25. - [-1, 2, C2PSA_SENetV2, [1024]] # 10
  26. # YOLO11n head
  27. head:
  28. - [-1, 1, nn.Upsample, [None, 2, "nearest"]]
  29. - [[-1, 6], 1, Concat, [1]] # cat backbone P4
  30. - [-1, 2, C3k2, [512, False]] # 13
  31. - [-1, 1, nn.Upsample, [None, 2, "nearest"]]
  32. - [[-1, 4], 1, Concat, [1]] # cat backbone P3
  33. - [-1, 2, C3k2, [256, False]] # 16 (P3/8-small)
  34. - [-1, 1, Conv, [256, 3, 2]]
  35. - [[-1, 13], 1, Concat, [1]] # cat head P4
  36. - [-1, 2, C3k2, [512, False]] # 19 (P4/16-medium)
  37. - [-1, 1, Conv, [512, 3, 2]]
  38. - [[-1, 10], 1, Concat, [1]] # cat head P5
  39. - [-1, 2, C3k2, [1024, True]] # 22 (P5/32-large)
  40. - [[16, 19, 22], 1, Detect, [nc]] # Detect(P3, P4, P5)


5.2 SPPFSENetV2的yaml文件

此版本训练信息:YOLO11-SPPF-SENetV2 summary: 362 layers, 2,144,923 parameters, 2,144,907 gradients, 5.3 GFLOPs

# 我这里就是将SENetV2放在了SPPF的前面简单融合了一下但是这样也比大家在yaml文件配置的创新都要大一点.

  1. # Ultralytics YOLO 🚀, AGPL-3.0 license
  2. # YOLO11 object detection model with P3-P5 outputs. For Usage examples see https://docs.ultralytics.com/tasks/detect
  3. # Parameters
  4. nc: 80 # number of classes
  5. scales: # model compound scaling constants, i.e. 'model=yolo11n.yaml' will call yolo11.yaml with scale 'n'
  6. # [depth, width, max_channels]
  7. n: [0.50, 0.25, 1024] # summary: 319 layers, 2624080 parameters, 2624064 gradients, 6.6 GFLOPs
  8. s: [0.50, 0.50, 1024] # summary: 319 layers, 9458752 parameters, 9458736 gradients, 21.7 GFLOPs
  9. m: [0.50, 1.00, 512] # summary: 409 layers, 20114688 parameters, 20114672 gradients, 68.5 GFLOPs
  10. l: [1.00, 1.00, 512] # summary: 631 layers, 25372160 parameters, 25372144 gradients, 87.6 GFLOPs
  11. x: [1.00, 1.50, 512] # summary: 631 layers, 56966176 parameters, 56966160 gradients, 196.0 GFLOPs
  12. # YOLO11n backbone
  13. backbone:
  14. # [from, repeats, module, args]
  15. - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2
  16. - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4
  17. - [-1, 2, C3k2, [256, False, 0.25]]
  18. - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8
  19. - [-1, 2, C3k2, [512, False, 0.25]]
  20. - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16
  21. - [-1, 2, C3k2, [512, True]]
  22. - [-1, 1, Conv, [1024, 3, 2]] # 7-P5/32
  23. - [-1, 2, C3k2, [1024, True]]
  24. - [-1, 1, SPPF, [1024, 5]] # 9
  25. - [-1, 2, C2PSASENetV2, [1024]] # 10
  26. # YOLO11n head
  27. head:
  28. - [-1, 1, nn.Upsample, [None, 2, "nearest"]]
  29. - [[-1, 6], 1, Concat, [1]] # cat backbone P4
  30. - [-1, 2, C3k2, [512, False]] # 13
  31. - [-1, 1, nn.Upsample, [None, 2, "nearest"]]
  32. - [[-1, 4], 1, Concat, [1]] # cat backbone P3
  33. - [-1, 2, C3k2, [256, False]] # 16 (P3/8-small)
  34. - [-1, 1, Conv, [256, 3, 2]]
  35. - [[-1, 13], 1, Concat, [1]] # cat head P4
  36. - [-1, 2, C3k2, [512, False]] # 19 (P4/16-medium)
  37. - [-1, 1, Conv, [512, 3, 2]]
  38. - [[-1, 10], 1, Concat, [1]] # cat head P5
  39. - [-1, 2, C3k2, [1024, True]] # 22 (P5/32-large)
  40. - [[16, 19, 22], 1, Detect, [nc]] # Detect(P3, P4, P5)


5.3 SENetV2的yaml文件

此版本训练信息:YOLO11-SENetV2 summary: 370 layers, 2,637,723 parameters, 2,637,707 gradients, 6.5 GFLOPs

# 注意力机制我这里其实是添加了三个但是实际一般生效就只添加一个就可以了,所以大家可以自行注释来尝试, 上面三个仅建议大家保留一个, 但是from位置要对齐.
  1. # Ultralytics YOLO 🚀, AGPL-3.0 license
  2. # YOLO11 object detection model with P3-P5 outputs. For Usage examples see https://docs.ultralytics.com/tasks/detect
  3. # Parameters
  4. nc: 80 # number of classes
  5. scales: # model compound scaling constants, i.e. 'model=yolo11n.yaml' will call yolo11.yaml with scale 'n'
  6. # [depth, width, max_channels]
  7. n: [0.50, 0.25, 1024] # summary: 319 layers, 2624080 parameters, 2624064 gradients, 6.6 GFLOPs
  8. s: [0.50, 0.50, 1024] # summary: 319 layers, 9458752 parameters, 9458736 gradients, 21.7 GFLOPs
  9. m: [0.50, 1.00, 512] # summary: 409 layers, 20114688 parameters, 20114672 gradients, 68.5 GFLOPs
  10. l: [1.00, 1.00, 512] # summary: 631 layers, 25372160 parameters, 25372144 gradients, 87.6 GFLOPs
  11. x: [1.00, 1.50, 512] # summary: 631 layers, 56966176 parameters, 56966160 gradients, 196.0 GFLOPs
  12. # YOLO11n backbone
  13. backbone:
  14. # [from, repeats, module, args]
  15. - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2
  16. - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4
  17. - [-1, 2, C3k2, [256, False, 0.25]]
  18. - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8
  19. - [-1, 2, C3k2, [512, False, 0.25]]
  20. - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16
  21. - [-1, 2, C3k2, [512, True]]
  22. - [-1, 1, Conv, [1024, 3, 2]] # 7-P5/32
  23. - [-1, 2, C3k2, [1024, True]]
  24. - [-1, 1, SPPF, [1024, 5]] # 9
  25. - [-1, 2, C2PSA, [1024]] # 10
  26. # YOLO11n head
  27. head:
  28. - [-1, 1, nn.Upsample, [None, 2, "nearest"]]
  29. - [[-1, 6], 1, Concat, [1]] # cat backbone P4
  30. - [-1, 2, C3k2, [512, False]] # 13
  31. - [-1, 1, nn.Upsample, [None, 2, "nearest"]]
  32. - [[-1, 4], 1, Concat, [1]] # cat backbone P3
  33. - [-1, 2, C3k2, [256, False]] # 16 (P3/8-small)
  34. - [-1, 1, SELayerV2, []] # 17 (P3/8-small) 小目标检测层输出位置增加注意力机制
  35. - [-1, 1, Conv, [256, 3, 2]]
  36. - [[-1, 13], 1, Concat, [1]] # cat head P4
  37. - [-1, 2, C3k2, [512, False]] # 20 (P4/16-medium)
  38. - [-1, 1, SELayerV2, []] # 21 (P4/16-medium) 中目标检测层输出位置增加注意力机制
  39. - [-1, 1, Conv, [512, 3, 2]]
  40. - [[-1, 10], 1, Concat, [1]] # cat head P5
  41. - [-1, 2, C3k2, [1024, True]] # 24 (P5/32-large)
  42. - [-1, 1, SELayerV2, []] # 25 (P5/32-large) 大目标检测层输出位置增加注意力机制
  43. # 注意力机制我这里其实是添加了三个但是实际一般生效就只添加一个就可以了,所以大家可以自行注释来尝试, 上面三个仅建议大家保留一个, 但是from位置要对齐.
  44. # 具体在那一层用注意力机制可以根据自己的数据集场景进行选择。
  45. # 如果你自己配置注意力位置注意from[17, 21, 25]位置要对应上对应的检测层!
  46. - [[17, 21, 25], 1, Detect, [nc]] # Detect(P3, P4, P5)


5.4 训练代码

大家可以创建一个py文件将我给的代码复制粘贴进去,配置好自己的文件路径即可运行。

  1. import warnings
  2. warnings.filterwarnings('ignore')
  3. from ultralytics import YOLO
  4. if __name__ == '__main__':
  5. model = YOLO('ultralytics/cfg/models/v8/yolov8-C2f-FasterBlock.yaml')
  6. # model.load('yolov8n.pt') # loading pretrain weights
  7. model.train(data=r'替换数据集yaml文件地址',
  8. # 如果大家任务是其它的'ultralytics/cfg/default.yaml'找到这里修改task可以改成detect, segment, classify, pose
  9. cache=False,
  10. imgsz=640,
  11. epochs=150,
  12. single_cls=False, # 是否是单类别检测
  13. batch=4,
  14. close_mosaic=10,
  15. workers=0,
  16. device='0',
  17. optimizer='SGD', # using SGD
  18. # resume='', # 如过想续训就设置last.pt的地址
  19. amp=False, # 如果出现训练损失为Nan可以关闭amp
  20. project='runs/train',
  21. name='exp',
  22. )


5.5 训练过程截图


五、本文总结

到此本文的正式分享内容就结束了,在这里给大家推荐我的YOLOv11改进有效涨点专栏,本专栏目前为新开的平均质量分98分,后期我会根据各种最新的前沿顶会进行论文复现,也会对一些老的改进机制进行补充,如果大家觉得本文帮助到你了,订阅本专栏,关注后续更多的更新~

​​​