YOLOv8魔改核心-模型yaml文件解析与网络结构打印

前言

本篇文章主要用于记录学习YOLOv8中网络模型yaml文件,我们一般只知道如何去训练模型,和配置yaml文件,但是对于yaml文件是如何输入到模型里,模型如何将yaml文件解析出来的确是不知道的,下面我们从yaml文件来讲解,并打印出网络结构参数。

往期回顾

1、YOLOv8入门-训练TT100K数据集实践

一、yaml文件的定义

文件位置:./ultralytics/cfg/models/v8/yolov8.yaml,文件详解:

# Ultralytics YOLO 🚀, AGPL-3.0 license
# YOLOv8 object detection model with P3-P5 outputs. For Usage examples see https://docs.ultralytics.com/tasks/detect

# Parameters
nc: 80  # 类别数目,nc代表"number of classes",即模型用于检测的对象类别总数。 80表示该模型配置用于检测80种不同的对象。由于默认使用COCO数据集,这里nc=80;
scales: # 模型复合缩放常数,用于定义模型的不同尺寸和复杂度。例如 'model=yolov8n.yaml' 将调用带有 'n' 缩放的 yolov8.yaml
  # [depth, width, max_channels]
  n: [0.33, 0.25, 1024]  # YOLOv8n概览:225层, 3157200参数, 3157184梯度, 8.9 GFLOPs
  s: [0.33, 0.50, 1024]  # YOLOv8s概览:225层, 11166560参数, 11166544梯度, 28.8 GFLOPs
  m: [0.67, 0.75, 768]   # YOLOv8m概览:295层, 25902640参数, 25902624梯度, 79.3 GFLOPs
  l: [1.00, 1.00, 512]   # YOLOv8l概览:365层, 43691520参数, 43691504梯度, 165.7 GFLOPs
  x: [1.00, 1.25, 512]   # YOLOv8x概览:365层, 68229648参数, 68229632梯度, 258.5 GFLOPs

# YOLOv8.0n backbone 骨干层
backbone:
  # [from, repeats, module, args]
  - [-1, 1, Conv, [64, 3, 2]]  # 0-P1/2 第0层,-1代表将上层的输出作为本层的输入。第0层的输入是640*640*3的图像。Conv代表卷积层,相应的参数:64代表输出通道数,3代表卷积核大小k,2代表stride步长。卷积后输出的特征图尺寸为320*320*64,长宽为初始图片的1/2
  - [-1, 1, Conv, [128, 3, 2]]  # 1-P2/4 第1层,本层和上一层是一样的操作(128代表输出通道数,3代表卷积核大小k,2代表stride步长)。卷积后输出的特征图尺寸为160*160*128,长宽为初始图片的1/4
  - [-1, 3, C2f, [128, True]] # 第2层,本层是C2f模块,3代表本层重复3次。128代表输出通道数,True表示Bottleneck有shortcut。输出的特征图尺寸为160*160*128。
  - [-1, 1, Conv, [256, 3, 2]]  # 3-P3/8 第3层,进行卷积操作(256代表输出通道数,3代表卷积核大小k,2代表stride步长),输出特征图尺寸为80*80*256(卷积的参数都没变,所以都是长宽变成原来的1/2,和之前一样),特征图的长宽已经变成输入图像的1/8。
  - [-1, 6, C2f, [256, True]] # 第4层,本层是C2f模块,可以参考第2层的讲解。6代表本层重复6次。256代表输出通道数,True表示Bottleneck有shortcut。经过这层之后,特征图尺寸依旧是80*80*256。
  - [-1, 1, Conv, [512, 3, 2]]  # 5-P4/16 第5层,进行卷积操作(512代表输出通道数,3代表卷积核大小k,2代表stride步长),输出特征图尺寸为40*40*512(卷积的参数都没变,所以都是长宽变成原来的1/2,和之前一样),特征图的长宽已经变成输入图像的1/16。
  - [-1, 6, C2f, [512, True]] # 第6层,本层是C2f模块,可以参考第2层的讲解。6代表本层重复6次。512代表输出通道数,True表示Bottleneck有shortcut。经过这层之后,特征图尺寸依旧是40*40*512。
  - [-1, 1, Conv, [1024, 3, 2]]  # 7-P5/32 第7层,进行卷积操作(1024代表输出通道数,3代表卷积核大小k,2代表stride步长),输出特征图尺寸为20*20*1024(卷积的参数都没变,所以都是长宽变成原来的1/2,和之前一样),特征图的长宽已经变成输入图像的1/32。
  - [-1, 3, C2f, [1024, True]] #第8层,本层是C2f模块,可以参考第2层的讲解。3代表本层重复3次。1024代表输出通道数,True表示Bottleneck有shortcut。经过这层之后,特征图尺寸依旧是20*20*1024。
  - [-1, 1, SPPF, [1024, 5]]  # 9 第9层,本层是快速空间金字塔池化层(SPPF)。1024代表输出通道数,5代表池化核大小k。结合模块结构图和代码可以看出,最后concat得到的特征图尺寸是20*20*(512*4),经过一次Conv得到20*20*1024。

# YOLOv8.0n head 头部层
head:
  - [-1, 1, nn.Upsample, [None, 2, 'nearest']] # 第10层,本层是上采样层。-1代表将上层的输出作为本层的输入。None代表上采样的size=None(输出尺寸)不指定。2代表scale_factor=2,表示输出的尺寸是输入尺寸的2倍。mode=nearest代表使用的上采样算法为最近邻插值算法。经过这层之后,特征图的长和宽变成原来的两倍,通道数不变,所以最终尺寸为40*40*1024。
  - [[-1, 6], 1, Concat, [1]]  # cat backbone P4 第11层,本层是concat层,[-1, 6]代表将上层和第6层的输出作为本层的输入。[1]代表concat拼接的维度是1。从上面的分析可知,上层的输出尺寸是40*40*1024,第6层的输出是40*40*512,最终本层的输出尺寸为40*40*1536。
  - [-1, 3, C2f, [512]]  # 12 第12层,本层是C2f模块,可以参考第2层的讲解。3代表本层重复3次。512代表输出通道数。与Backbone中C2f不同的是,此处的C2f的bottleneck模块的shortcut=False。

  - [-1, 1, nn.Upsample, [None, 2, 'nearest']] # 第13层,本层也是上采样层(参考第10层)。经过这层之后,特征图的长和宽变成原来的两倍,通道数不变,所以最终尺寸为80*80*512。
  - [[-1, 4], 1, Concat, [1]]  # cat backbone P3 第14层,本层是concat层,[-1, 4]代表将上层和第4层的输出作为本层的输入。[1]代表concat拼接的维度是1。从上面的分析可知,上层的输出尺寸是80*80*512,第6层的输出是80*80*256,最终本层的输出尺寸为80*80*768。
  - [-1, 3, C2f, [256]]  # 15 (P3/8-small) 第15层,本层是C2f模块,可以参考第2层的讲解。3代表本层重复3次。256代表输出通道数。经过这层之后,特征图尺寸变为80*80*256,特征图的长宽已经变成输入图像的1/8。

  - [-1, 1, Conv, [256, 3, 2]] # 第16层,进行卷积操作(256代表输出通道数,3代表卷积核大小k,2代表stride步长),输出特征图尺寸为40*40*256(卷积的参数都没变,所以都是长宽变成原来的1/2,和之前一样)。
  - [[-1, 12], 1, Concat, [1]]  # cat head P4 第17层,本层是concat层,[-1, 12]代表将上层和第12层的输出作为本层的输入。[1]代表concat拼接的维度是1。从上面的分析可知,上层的输出尺寸是40*40*256,第12层的输出是40*40*512,最终本层的输出尺寸为40*40*768。
  - [-1, 3, C2f, [512]]  # 18 (P4/16-medium) 第18层,本层是C2f模块,可以参考第2层的讲解。3代表本层重复3次。512代表输出通道数。经过这层之后,特征图尺寸变为40*40*512,特征图的长宽已经变成输入图像的1/16。

  - [-1, 1, Conv, [512, 3, 2]] # 第19层,进行卷积操作(512代表输出通道数,3代表卷积核大小k,2代表stride步长),输出特征图尺寸为20*20*512(卷积的参数都没变,所以都是长宽变成原来的1/2,和之前一样)。
  - [[-1, 9], 1, Concat, [1]]  # cat head P5 第20层,本层是concat层,[-1, 9]代表将上层和第9层的输出作为本层的输入。[1]代表concat拼接的维度是1。从上面的分析可知,上层的输出尺寸是20*20*512,第9层的输出是20*20*1024,最终本层的输出尺寸为20*20*1536。
  - [-1, 3, C2f, [1024]]  # 21 (P5/32-large) 第21层,本层是C2f模块,可以参考第2层的讲解。3代表本层重复3次。1024代表输出通道数。经过这层之后,特征图尺寸变为20*20*1024,特征图的长宽已经变成输入图像的1/32。

  - [[15, 18, 21], 1, Detect, [nc]]  # Detect(P3, P4, P5) 第20层,本层是Detect层,[15, 18, 21]代表将第15、18、21层的输出(分别是80*80*256、40*40*512、20*20*1024)作为本层的输入。nc是数据集的类别数。

1、参数配置

在这里插入图片描述

nc:80 # 数据集的类别数,默认coco是80类别(yolov8的权重也是基于此数据集训练出来的),nc此处其实不需要修改,模型会自动根据我们数据集的yaml文件获取此处的数量

scales:# 包含了不同模型配置的尺度参数,调整模型的规模,通过尺度参数可以实现不同复杂度的模型设计。YOLOv8n、YOLOv8s、YOLOv8m、YOLOv8l、YOLOv8x五种模型的区别在于depth、width、max_channels这三个参数的不同。

#model compound scaling constants, i.e. ‘model=yolov8n.yaml’ will call yolov8.yaml with scale ‘n’
#此处的含义大概就是如果我们在训练的指令时候使用model=yolov8.yaml 则对应的是v8n,如果使用model=yolov8s.yaml则对应的是v8s

[depth, width, max_channels]
depth:深度,控制子模块的数量
width: 宽度,控制卷积核的数量
max_channels: 最大通道数

2、backbone模块

在这里插入图片描述
[from, repeats, module, args]
from: 有三种可能的值分别是 -1、具体的数值、list存放数值。
(1)-1代表此层的输入就是上一层的输出
(2)如果是具体的某个数字4则代表本层的输入来自于模型的第四层
(3)有的层是list存在两个值可能是多个值,则代表对应两个值的输出为本层的输入

repeats: 这个参数是为了c2f设置的,其他模块用不到,代表着C2f中Bottleneck重复的次数,当我们的模型用到的是1时候,repeats=3那么则代表C2f当中的Bottleneck串行3个。

module:模块类名,通过这个类名在common.py中寻找相应的类,进行模块化的搭建网络。

args:以conv[64, 3, 2]为例,分别对应[channel, kernel, stride] 。channel是输出feature map的通道数,kernel是卷积核的个数, stride是卷积核移动步幅。此处代表输入到对应模块的参数,此处和parse_model函数中的定义方法有关,对于C2f来说传入的参数->第一个参数是上一个模型的输出通道数,第二个参数就是args的第一个参数,然后以此类推。

在这里插入图片描述

以C2f[128,true]为例,128是输出feature map的通道数,True代表Bottleneck模块中的shortcut=True,m没有写代表False。
以SPPF[1024,5]为例,1024是输出feature map的通道数,5是SPPF模块中池化核的尺寸。
以nn.upsample为例,None表示不指定输出尺寸,2表示输出尺寸为输入尺寸的2倍,“nearest”表示上采样差值方式为最近邻差值。

3、head模块

在这里插入图片描述

head用于将主干网络(backbone)的特征图(feature maps)转化为目标检测的输出结果,head部分定义了模型的检测头,即用于最终目标检测的网络结构。头部网络的主要作用是进行目标分类和定位。它根据颈部网络提供的融合特征图,对每个特征点进行分类(目标类别预测)和定位(边界框预测)。

关键组成:
nn.Upsample:表示上采样层,用于放大特征图。
Concat:表示连接层,用于合并来自不同层的特征。
C2f:层再次出现,可能用于进一步处理合并后的特征。
Detect:层是最终的检测层,负责输出检测结果。

二、模型结构图

YOLOv8(You Only Look Once version 8)目标检测模型的结构图。它展示了模型的三个主要部分:Backbone(主干网络)、Neck(颈部网络)和 Head(头部网络),以及它们的子模块和连接方式。
在这里插入图片描述

概述
提供全新SOTA模型,包括640(P5)和1280(P6)分辨率的目标检测网络和基于YOLACT的实例分割模型。

  • Backbone:骨干网络和neck部分参考了YOLOv7 ELAN的设计思想,将YOLOv5的C3结构换成了梯度流更丰富的C2f结构,并对不同尺度模型调整了不同通道数。
  • Head:Head部分较yolov5而言有两大改进:(1)换成了目前主流的解耦头结构(Decoupled-Head),将分类与检测头分离 (2)将Anchor-Based换成Anchor-Free
  • Loss:YOLOv8抛弃以往IOU匹配或者单边比例的分配方法,使用了Task-Aligned Assigner正负样本匹配方式。2)并引入了 Distribution Focal Loss(DFL)
  • Train:训练的数据增强部分引入了 YOLOX 中的最后 10 epoch 关闭 Mosiac 增强的操作,有效地提升精度

三、模型结构解析

ultralytics/nn/modules.py文件中定义了yolov8网络中的卷积神经单元,也是后续网络魔改的主要文件。

四、模型结构打印

每次进行YOLOv8模型训练前,都会打印相应的模型结构信息,如下图。

在这里插入图片描述

通过查看源码发现,信息是在源码DetectionModel类中,打印出来的。因此我们直接使用该类,传入我们自己的模型配置文件,运行该类即可。

第一步:进入./ultralytics/nn/tasks.py文件,找到DetectionModel类

代码如下:

class DetectionModel(BaseModel):
    """YOLOv8 detection model."""

    def __init__(self, cfg="yolov8n.yaml", ch=3, nc=None, verbose=True):  # model, input channels, number of classes
        """Initialize the YOLOv8 detection model with the given config and parameters."""
        super().__init__()
        self.yaml = cfg if isinstance(cfg, dict) else yaml_model_load(cfg)  # cfg dict
        if self.yaml["backbone"][0][2] == "Silence":
            LOGGER.warning(
                "WARNING ⚠️ YOLOv9 `Silence` module is deprecated in favor of nn.Identity. "
                "Please delete local *.pt file and re-download the latest model checkpoint."
            )
            self.yaml["backbone"][0][2] = "nn.Identity"

        # Define model
        ch = self.yaml["ch"] = self.yaml.get("ch", ch)  # input channels
        if nc and nc != self.yaml["nc"]:
            LOGGER.info(f"Overriding model.yaml nc={self.yaml['nc']} with nc={nc}")
            self.yaml["nc"] = nc  # override YAML value
        self.model, self.save = parse_model(deepcopy(self.yaml), ch=ch, verbose=verbose)  # model, savelist
        self.names = {i: f"{i}" for i in range(self.yaml["nc"])}  # default names dict
        self.inplace = self.yaml.get("inplace", True)
        self.end2end = getattr(self.model[-1], "end2end", False)

        # Build strides
        m = self.model[-1]  # Detect()
        if isinstance(m, Detect):  # includes all Detect subclasses like Segment, Pose, OBB, WorldDetect
            s = 256  # 2x min stride
            m.inplace = self.inplace

            def _forward(x):
                """Performs a forward pass through the model, handling different Detect subclass types accordingly."""
                if self.end2end:
                    return self.forward(x)["one2many"]
                return self.forward(x)[0] if isinstance(m, (Segment, Pose, OBB)) else self.forward(x)

            m.stride = torch.tensor([s / x.shape[-2] for x in _forward(torch.zeros(1, ch, s, s))])  # forward
            self.stride = m.stride
            m.bias_init()  # only run once
        else:
            self.stride = torch.Tensor([32])  # default stride for i.e. RTDETR

        # Init weights, biases
        initialize_weights(self)
        if verbose:
            self.info()
            LOGGER.info("")

    def _predict_augment(self, x):
        """Perform augmentations on input image x and return augmented inference and train outputs."""
        if getattr(self, "end2end", False):
            LOGGER.warning(
                "WARNING ⚠️ End2End model does not support 'augment=True' prediction. "
                "Reverting to single-scale prediction."
            )
            return self._predict_once(x)
        img_size = x.shape[-2:]  # height, width
        s = [1, 0.83, 0.67]  # scales
        f = [None, 3, None]  # flips (2-ud, 3-lr)
        y = []  # outputs
        for si, fi in zip(s, f):
            xi = scale_img(x.flip(fi) if fi else x, si, gs=int(self.stride.max()))
            yi = super().predict(xi)[0]  # forward
            yi = self._descale_pred(yi, fi, si, img_size)
            y.append(yi)
        y = self._clip_augmented(y)  # clip augmented tails
        return torch.cat(y, -1), None  # augmented inference, train

第二步:在task.py文件下添加以下代码

# 模型网络结构配置文件路径
yaml_path = 'ultralytics/cfg/models/v8/yolov8n.yaml'
# 改进的模型结构路径
# yaml_path = 'ultralytics/cfg/models/v8/yolov8n-CBAM.yaml'  
# 传入模型网络结构配置文件cfg, nc为模型检测类别数
DetectionModel(cfg=yaml_path,nc=5)

第三步:运行task.py文件即可打印网络参数

效果如下:

在这里插入图片描述

模型配置文件一共有23行,params为每一层的参数量大小,module为每一层的结构名称,arguments为每一层结构需要传入的参数。最后一行summary为总的信息参数,模型一共有25层,参数量(parameters)为:3011823 ,计算量GFLOPs为:8.2

五、查看详细网络结构

第一步:新建tools/DetectModel.py文件

代码如下:

from ultralytics import YOLO
# 加载训练好的模型或者网络结构配置文件
#model = YOLO('best.pt')
model = YOLO('ultralytics/cfg/models/v8/yolov8.yaml')
# 打印模型参数信息
print(model.info())
print(model.info(detailed=True))

第二步:运行DetectModel.py

打印出了模型每一层网络结构的名字、参数量以及该层的结构形状。

layer                                     name  gradient   parameters                shape         mu      sigma
    0                      model.0.conv.weight      True          432        [16, 3, 3, 3]    -0.0018      0.112 torch.float32
    1                        model.0.bn.weight      True           16                 [16]          1          0 torch.float32
    2                          model.0.bn.bias      True           16                 [16]          0          0 torch.float32
    3                      model.1.conv.weight      True         4608       [32, 16, 3, 3]  -5.27e-05     0.0479 torch.float32
    4                        model.1.bn.weight      True           32                 [32]          1          0 torch.float32
    5                          model.1.bn.bias      True           32                 [32]          0          0 torch.float32
    6                  model.2.cv1.conv.weight      True         1024       [32, 32, 1, 1]    0.00697      0.104 torch.float32
    7                    model.2.cv1.bn.weight      True           32                 [32]          1          0 torch.float32
    8                      model.2.cv1.bn.bias      True           32                 [32]          0          0 torch.float32
    9                  model.2.cv2.conv.weight      True         1536       [32, 48, 1, 1]    0.00101     0.0828 torch.float32
   10                    model.2.cv2.bn.weight      True           32                 [32]          1          0 torch.float32
   11                      model.2.cv2.bn.bias      True           32                 [32]          0          0 torch.float32
   12              model.2.m.0.cv1.conv.weight      True         2304       [16, 16, 3, 3]  -0.000518     0.0479 torch.float32
   13                model.2.m.0.cv1.bn.weight      True           16                 [16]          1          0 torch.float32
   14                  model.2.m.0.cv1.bn.bias      True           16                 [16]          0          0 torch.float32
   15              model.2.m.0.cv2.conv.weight      True         2304       [16, 16, 3, 3]     0.0003     0.0483 torch.float32
   16                model.2.m.0.cv2.bn.weight      True           16                 [16]          1          0 torch.float32
   17                  model.2.m.0.cv2.bn.bias      True           16                 [16]          0          0 torch.float32
   18                      model.3.conv.weight      True        18432       [64, 32, 3, 3]  -2.67e-05      0.034 torch.float32
   19                        model.3.bn.weight      True           64                 [64]          1          0 torch.float32
   20                          model.3.bn.bias      True           64                 [64]          0          0 torch.float32
   21                  model.4.cv1.conv.weight      True         4096       [64, 64, 1, 1]   -0.00063      0.072 torch.float32
   22                    model.4.cv1.bn.weight      True           64                 [64]          1          0 torch.float32
   23                      model.4.cv1.bn.bias      True           64                 [64]          0          0 torch.float32
   24                  model.4.cv2.conv.weight      True         8192      [64, 128, 1, 1]   0.000625     0.0512 torch.float32
   25                    model.4.cv2.bn.weight      True           64                 [64]          1          0 torch.float32
   26                      model.4.cv2.bn.bias      True           64                 [64]          0          0 torch.float32
   27              model.4.m.0.cv1.conv.weight      True         9216       [32, 32, 3, 3]   0.000206     0.0341 torch.float32
   28                model.4.m.0.cv1.bn.weight      True           32                 [32]          1          0 torch.float32
   29                  model.4.m.0.cv1.bn.bias      True           32                 [32]          0          0 torch.float32
   30              model.4.m.0.cv2.conv.weight      True         9216       [32, 32, 3, 3]  -7.44e-05      0.034 torch.float32
   31                model.4.m.0.cv2.bn.weight      True           32                 [32]          1          0 torch.float32
   32                  model.4.m.0.cv2.bn.bias      True           32                 [32]          0          0 torch.float32
   33              model.4.m.1.cv1.conv.weight      True         9216       [32, 32, 3, 3]  -0.000666     0.0342 torch.float32
   34                model.4.m.1.cv1.bn.weight      True           32                 [32]          1          0 torch.float32
   35                  model.4.m.1.cv1.bn.bias      True           32                 [32]          0          0 torch.float32
   36              model.4.m.1.cv2.conv.weight      True         9216       [32, 32, 3, 3]   6.18e-05     0.0341 torch.float32
   37                model.4.m.1.cv2.bn.weight      True           32                 [32]          1          0 torch.float32
   38                  model.4.m.1.cv2.bn.bias      True           32                 [32]          0          0 torch.float32
   39                      model.5.conv.weight      True        73728      [128, 64, 3, 3]   -6.7e-05     0.0241 torch.float32
   40                        model.5.bn.weight      True          128                [128]          1          0 torch.float32
   41                          model.5.bn.bias      True          128                [128]          0          0 torch.float32
   42                  model.6.cv1.conv.weight      True        16384     [128, 128, 1, 1]  -0.000304      0.051 torch.float32
   43                    model.6.cv1.bn.weight      True          128                [128]          1          0 torch.float32
   44                      model.6.cv1.bn.bias      True          128                [128]          0          0 torch.float32
   45                  model.6.cv2.conv.weight      True        32768     [128, 256, 1, 1]   4.06e-05      0.036 torch.float32
   46                    model.6.cv2.bn.weight      True          128                [128]          1          0 torch.float32
   47                      model.6.cv2.bn.bias      True          128                [128]          0          0 torch.float32
   48              model.6.m.0.cv1.conv.weight      True        36864       [64, 64, 3, 3]  -0.000123     0.0241 torch.float32
   49                model.6.m.0.cv1.bn.weight      True           64                 [64]          1          0 torch.float32
   50                  model.6.m.0.cv1.bn.bias      True           64                 [64]          0          0 torch.float32
   51              model.6.m.0.cv2.conv.weight      True        36864       [64, 64, 3, 3]  -6.25e-05      0.024 torch.float32
   52                model.6.m.0.cv2.bn.weight      True           64                 [64]          1          0 torch.float32
   53                  model.6.m.0.cv2.bn.bias      True           64                 [64]          0          0 torch.float32
   54              model.6.m.1.cv1.conv.weight      True        36864       [64, 64, 3, 3]   2.97e-05     0.0241 torch.float32
   55                model.6.m.1.cv1.bn.weight      True           64                 [64]          1          0 torch.float32
   56                  model.6.m.1.cv1.bn.bias      True           64                 [64]          0          0 torch.float32
   57              model.6.m.1.cv2.conv.weight      True        36864       [64, 64, 3, 3]   0.000165     0.0241 torch.float32
   58                model.6.m.1.cv2.bn.weight      True           64                 [64]          1          0 torch.float32
   59                  model.6.m.1.cv2.bn.bias      True           64                 [64]          0          0 torch.float32
   60                      model.7.conv.weight      True       294912     [256, 128, 3, 3]  -1.75e-05      0.017 torch.float32
   61                        model.7.bn.weight      True          256                [256]          1          0 torch.float32
   62                          model.7.bn.bias      True          256                [256]          0          0 torch.float32
   63                  model.8.cv1.conv.weight      True        65536     [256, 256, 1, 1]   0.000161      0.036 torch.float32
   64                    model.8.cv1.bn.weight      True          256                [256]          1          0 torch.float32
   65                      model.8.cv1.bn.bias      True          256                [256]          0          0 torch.float32
   66                  model.8.cv2.conv.weight      True        98304     [256, 384, 1, 1]   0.000193     0.0295 torch.float32
   67                    model.8.cv2.bn.weight      True          256                [256]          1          0 torch.float32
   68                      model.8.cv2.bn.bias      True          256                [256]          0          0 torch.float32
   69              model.8.m.0.cv1.conv.weight      True       147456     [128, 128, 3, 3]   5.85e-05      0.017 torch.float32
   70                model.8.m.0.cv1.bn.weight      True          128                [128]          1          0 torch.float32
   71                  model.8.m.0.cv1.bn.bias      True          128                [128]          0          0 torch.float32
   72              model.8.m.0.cv2.conv.weight      True       147456     [128, 128, 3, 3]  -3.18e-05      0.017 torch.float32
   73                model.8.m.0.cv2.bn.weight      True          128                [128]          1          0 torch.float32
   74                  model.8.m.0.cv2.bn.bias      True          128                [128]          0          0 torch.float32
   75                  model.9.cv1.conv.weight      True        32768     [128, 256, 1, 1]   9.07e-05      0.036 torch.float32
   76                    model.9.cv1.bn.weight      True          128                [128]          1          0 torch.float32
   77                      model.9.cv1.bn.bias      True          128                [128]          0          0 torch.float32
   78                  model.9.cv2.conv.weight      True       131072     [256, 512, 1, 1]  -6.56e-05     0.0255 torch.float32
   79                    model.9.cv2.bn.weight      True          256                [256]          1          0 torch.float32
   80                      model.9.cv2.bn.bias      True          256                [256]          0          0 torch.float32
   81                 model.12.cv1.conv.weight      True        49152     [128, 384, 1, 1]   3.35e-05     0.0295 torch.float32
   82                   model.12.cv1.bn.weight      True          128                [128]          1          0 torch.float32
   83                     model.12.cv1.bn.bias      True          128                [128]          0          0 torch.float32
   84                 model.12.cv2.conv.weight      True        24576     [128, 192, 1, 1]   0.000263     0.0417 torch.float32
   85                   model.12.cv2.bn.weight      True          128                [128]          1          0 torch.float32
   86                     model.12.cv2.bn.bias      True          128                [128]          0          0 torch.float32
   87             model.12.m.0.cv1.conv.weight      True        36864       [64, 64, 3, 3]  -9.72e-05     0.0241 torch.float32
   88               model.12.m.0.cv1.bn.weight      True           64                 [64]          1          0 torch.float32
   89                 model.12.m.0.cv1.bn.bias      True           64                 [64]          0          0 torch.float32
   90             model.12.m.0.cv2.conv.weight      True        36864       [64, 64, 3, 3]   4.32e-05     0.0241 torch.float32
   91               model.12.m.0.cv2.bn.weight      True           64                 [64]          1          0 torch.float32
   92                 model.12.m.0.cv2.bn.bias      True           64                 [64]          0          0 torch.float32
   93                 model.15.cv1.conv.weight      True        12288      [64, 192, 1, 1]  -0.000269     0.0416 torch.float32
   94                   model.15.cv1.bn.weight      True           64                 [64]          1          0 torch.float32
   95                     model.15.cv1.bn.bias      True           64                 [64]          0          0 torch.float32
   96                 model.15.cv2.conv.weight      True         6144       [64, 96, 1, 1]   0.000311     0.0588 torch.float32
   97                   model.15.cv2.bn.weight      True           64                 [64]          1          0 torch.float32
   98                     model.15.cv2.bn.bias      True           64                 [64]          0          0 torch.float32
   99             model.15.m.0.cv1.conv.weight      True         9216       [32, 32, 3, 3]   6.21e-05     0.0341 torch.float32
  100               model.15.m.0.cv1.bn.weight      True           32                 [32]          1          0 torch.float32
  101                 model.15.m.0.cv1.bn.bias      True           32                 [32]          0          0 torch.float32
  102             model.15.m.0.cv2.conv.weight      True         9216       [32, 32, 3, 3]   0.000244     0.0336 torch.float32
  103               model.15.m.0.cv2.bn.weight      True           32                 [32]          1          0 torch.float32
  104                 model.15.m.0.cv2.bn.bias      True           32                 [32]          0          0 torch.float32
  105                     model.16.conv.weight      True        36864       [64, 64, 3, 3]   -0.00011      0.024 torch.float32
  106                       model.16.bn.weight      True           64                 [64]          1          0 torch.float32
  107                         model.16.bn.bias      True           64                 [64]          0          0 torch.float32
  108                 model.18.cv1.conv.weight      True        24576     [128, 192, 1, 1]   0.000266     0.0417 torch.float32
  109                   model.18.cv1.bn.weight      True          128                [128]          1          0 torch.float32
  110                     model.18.cv1.bn.bias      True          128                [128]          0          0 torch.float32
  111                 model.18.cv2.conv.weight      True        24576     [128, 192, 1, 1]   0.000163     0.0416 torch.float32
  112                   model.18.cv2.bn.weight      True          128                [128]          1          0 torch.float32
  113                     model.18.cv2.bn.bias      True          128                [128]          0          0 torch.float32
  114             model.18.m.0.cv1.conv.weight      True        36864       [64, 64, 3, 3]   -6.7e-05      0.024 torch.float32
  115               model.18.m.0.cv1.bn.weight      True           64                 [64]          1          0 torch.float32
  116                 model.18.m.0.cv1.bn.bias      True           64                 [64]          0          0 torch.float32
  117             model.18.m.0.cv2.conv.weight      True        36864       [64, 64, 3, 3]  -0.000178      0.024 torch.float32
  118               model.18.m.0.cv2.bn.weight      True           64                 [64]          1          0 torch.float32
  119                 model.18.m.0.cv2.bn.bias      True           64                 [64]          0          0 torch.float32
  120                     model.19.conv.weight      True       147456     [128, 128, 3, 3]  -4.19e-05      0.017 torch.float32
  121                       model.19.bn.weight      True          128                [128]          1          0 torch.float32
  122                         model.19.bn.bias      True          128                [128]          0          0 torch.float32
  123                 model.21.cv1.conv.weight      True        98304     [256, 384, 1, 1]   -3.8e-05     0.0294 torch.float32
  124                   model.21.cv1.bn.weight      True          256                [256]          1          0 torch.float32
  125                     model.21.cv1.bn.bias      True          256                [256]          0          0 torch.float32
  126                 model.21.cv2.conv.weight      True        98304     [256, 384, 1, 1]   1.01e-05     0.0294 torch.float32
  127                   model.21.cv2.bn.weight      True          256                [256]          1          0 torch.float32
  128                     model.21.cv2.bn.bias      True          256                [256]          0          0 torch.float32
  129             model.21.m.0.cv1.conv.weight      True       147456     [128, 128, 3, 3]  -6.31e-05      0.017 torch.float32
  130               model.21.m.0.cv1.bn.weight      True          128                [128]          1          0 torch.float32
  131                 model.21.m.0.cv1.bn.bias      True          128                [128]          0          0 torch.float32
  132             model.21.m.0.cv2.conv.weight      True       147456     [128, 128, 3, 3]   1.04e-05      0.017 torch.float32
  133               model.21.m.0.cv2.bn.weight      True          128                [128]          1          0 torch.float32
  134                 model.21.m.0.cv2.bn.bias      True          128                [128]          0          0 torch.float32
  135             model.22.cv2.0.0.conv.weight      True        36864       [64, 64, 3, 3]  -0.000182     0.0241 torch.float32
  136               model.22.cv2.0.0.bn.weight      True           64                 [64]          1          0 torch.float32
  137                 model.22.cv2.0.0.bn.bias      True           64                 [64]          0          0 torch.float32
  138             model.22.cv2.0.1.conv.weight      True        36864       [64, 64, 3, 3]   0.000133     0.0241 torch.float32
  139               model.22.cv2.0.1.bn.weight      True           64                 [64]          1          0 torch.float32
  140                 model.22.cv2.0.1.bn.bias      True           64                 [64]          0          0 torch.float32
  141                  model.22.cv2.0.2.weight      True         4096       [64, 64, 1, 1]  -0.000657     0.0724 torch.float32
  142                    model.22.cv2.0.2.bias      True           64                 [64]          1          0 torch.float32
  143             model.22.cv2.1.0.conv.weight      True        73728      [64, 128, 3, 3]  -6.36e-06     0.0171 torch.float32
  144               model.22.cv2.1.0.bn.weight      True           64                 [64]          1          0 torch.float32
  145                 model.22.cv2.1.0.bn.bias      True           64                 [64]          0          0 torch.float32
  146             model.22.cv2.1.1.conv.weight      True        36864       [64, 64, 3, 3]  -0.000187      0.024 torch.float32
  147               model.22.cv2.1.1.bn.weight      True           64                 [64]          1          0 torch.float32
  148                 model.22.cv2.1.1.bn.bias      True           64                 [64]          0          0 torch.float32
  149                  model.22.cv2.1.2.weight      True         4096       [64, 64, 1, 1]  -0.000317     0.0718 torch.float32
  150                    model.22.cv2.1.2.bias      True           64                 [64]          1          0 torch.float32
  151             model.22.cv2.2.0.conv.weight      True       147456      [64, 256, 3, 3]  -2.29e-05      0.012 torch.float32
  152               model.22.cv2.2.0.bn.weight      True           64                 [64]          1          0 torch.float32
  153                 model.22.cv2.2.0.bn.bias      True           64                 [64]          0          0 torch.float32
  154             model.22.cv2.2.1.conv.weight      True        36864       [64, 64, 3, 3]  -0.000249     0.0241 torch.float32
  155               model.22.cv2.2.1.bn.weight      True           64                 [64]          1          0 torch.float32
  156                 model.22.cv2.2.1.bn.bias      True           64                 [64]          0          0 torch.float32
  157                  model.22.cv2.2.2.weight      True         4096       [64, 64, 1, 1]   -0.00175     0.0713 torch.float32
  158                    model.22.cv2.2.2.bias      True           64                 [64]          1          0 torch.float32
  159             model.22.cv3.0.0.conv.weight      True        36864       [64, 64, 3, 3]   8.05e-05     0.0241 torch.float32
  160               model.22.cv3.0.0.bn.weight      True           64                 [64]          1          0 torch.float32
  161                 model.22.cv3.0.0.bn.bias      True           64                 [64]          0          0 torch.float32
  162             model.22.cv3.0.1.conv.weight      True        36864       [64, 64, 3, 3]  -0.000122     0.0241 torch.float32
  163               model.22.cv3.0.1.bn.weight      True           64                 [64]          1          0 torch.float32
  164                 model.22.cv3.0.1.bn.bias      True           64                 [64]          0          0 torch.float32
  165                  model.22.cv3.0.2.weight      True         2880       [45, 64, 1, 1]  -0.000135     0.0724 torch.float32
  166                    model.22.cv3.0.2.bias      True           45                 [45]        -11   9.64e-07 torch.float32
  167             model.22.cv3.1.0.conv.weight      True        73728      [64, 128, 3, 3]  -1.51e-05      0.017 torch.float32
  168               model.22.cv3.1.0.bn.weight      True           64                 [64]          1          0 torch.float32
  169                 model.22.cv3.1.0.bn.bias      True           64                 [64]          0          0 torch.float32
  170             model.22.cv3.1.1.conv.weight      True        36864       [64, 64, 3, 3]    4.7e-05      0.024 torch.float32
  171               model.22.cv3.1.1.bn.weight      True           64                 [64]          1          0 torch.float32
  172                 model.22.cv3.1.1.bn.bias      True           64                 [64]          0          0 torch.float32
  173                  model.22.cv3.1.2.weight      True         2880       [45, 64, 1, 1]     -0.003      0.072 torch.float32
  174                    model.22.cv3.1.2.bias      True           45                 [45]      -9.57   9.64e-07 torch.float32
  175             model.22.cv3.2.0.conv.weight      True       147456      [64, 256, 3, 3]  -3.16e-05      0.012 torch.float32
  176               model.22.cv3.2.0.bn.weight      True           64                 [64]          1          0 torch.float32
  177                 model.22.cv3.2.0.bn.bias      True           64                 [64]          0          0 torch.float32
  178             model.22.cv3.2.1.conv.weight      True        36864       [64, 64, 3, 3]  -7.14e-05     0.0241 torch.float32
  179               model.22.cv3.2.1.bn.weight      True           64                 [64]          1          0 torch.float32
  180                 model.22.cv3.2.1.bn.bias      True           64                 [64]          0          0 torch.float32
  181                  model.22.cv3.2.2.weight      True         2880       [45, 64, 1, 1]  -0.000625     0.0719 torch.float32
  182                    model.22.cv3.2.2.bias      True           45                 [45]      -8.19          0 torch.float32
  183                 model.22.dfl.conv.weight     False           16        [1, 16, 1, 1]        7.5       4.76 torch.float32
YOLOv8 summary: 225 layers, 3,019,623 parameters, 3,019,607 gradients, 8.2 GFLOPs
(225, 3019623, 3019607, 8.2414592)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值