自学内容网 自学内容网

YOLOv8白皮书-第Y8周:yolov8.yaml文件解读

一、环境

  • 语言:Python3、Pytorch
  • 开发环境
  • 电脑系统:Windows 10
  • 语言环境:Python 3.9.2
  • 编译器:VS Code
  • 显卡:3060
  • CUDA版本:Release 11.4, V11.4.48
  • 本周任务:根据YOLOv8n、YOLOV8s的结构输出,手写出YOLOv8l的模型输出

二、yolov8.yaml

# YOLOv5 🚀 by Ultralytics, AGPL-3.0 license

# Parameters
nc: 80 # number of classes
depth_multiple: 0.33 # model depth multiple  控制模型的深度
width_multiple: 0.50 # layer channel multiple 控制conv通道channel个数(卷积核数量)
anchors:
  - [10, 13, 16, 30, 33, 23] # P3/8 ,检测小目标,10,13是一组尺寸,总共三组检测小目标
  - [30, 61, 62, 45, 59, 119] # P4/16,检测中等目标,30,61是一组尺寸,总共三组检测中等目标
  - [116, 90, 156, 198, 373, 326] # P5/32,检测大目标,116,90是一组尺寸,总共三组检测大目标
# YOLOv5 v6.0 backbone
backbone:
  # [from, number, module, args]
  [
    [-1, 1, Conv, [64, 6, 2, 2]], # 0-P1/2   宽高减半
    [-1, 1, Conv, [128, 3, 2]], # 1-P2/4
    [-1, 3, C3, [128]],
    [-1, 1, Conv, [256, 3, 2]], # 3-P3/8
    [-1, 6, C2, [256]],
    [-1, 1, Conv, [512, 3, 2]], # 5-P4/16
    [-1, 3, C3, [512]],
    [-1, 1, SPPF, [1024, 5]], # 9
  ]

# YOLOv5 v6.0 head
head: [
    [-1, 1, Conv, [512, 3, 2]],   # 宽高减半
    [-1, 1, nn.Upsample, [None, 2, "nearest"]],
    [[-1, 6], 1, Concat, [1]], # cat backbone P4
    [-1, 3, C3, [512, False]], # 13

    [-1, 1, Conv, [256, 1, 1]],
    [-1, 1, nn.Upsample, [None, 2, "nearest"]],
    [[-1, 4], 1, Concat, [1]], # cat backbone P3
    [-1, 3, C3, [256, False]], # 17 (P3/8-small)

    [-1, 1, Conv, [256, 3, 2]],
    [[-1, 12], 1, Concat, [1]], # cat head P4
    [-1, 3, C3, [512, False]], # 20 (P4/16-medium)

    [-1, 1, Conv, [512, 3, 2]],
    [[-1, 8], 1, Concat, [1]], # cat head P5
    [-1, 3, C3, [1024, False]], # 23 (P5/32-large)

    [[15, 18, 21], 1, Detect, [nc, anchors]], # Detect(P3, P4, P5)
  ]

#    [
#    [-1, 1, Conv, [64, 6, 2, 2]], # 0-P1/2   宽高减半
#    [-1, 1, Conv, [128, 3, 2]], # 1-P2/4
#    [-1, 3, C3, [128]],
#    [-1, 3, C2, [128]], 
#    [-1, 1, Conv, [256, 3, 2]], # 3-P3/8
#    [-1, 6, C3, [256]],
#    [-1, 1, Conv, [512, 3, 2]], # 5-P4/16
#    [-1, 9, C3, [512]],
#    [-1, 1, Conv, [1024, 3, 2]], # 7-P5/32
#    [-1, 3, C3, [1024]],
#    [-1, 1, SPPF, [1024, 5]], # 9
#  ]
# head: [
#     [-1, 1, Conv, [512, 1, 1]],   # 宽高不变
#     [-1, 1, nn.Upsample, [None, 2, "nearest"]],
#     [[-1, 6], 1, Concat, [1]], # cat backbone P4
#     [-1, 3, C3, [512, False]], # 13
# 
#     [-1, 1, Conv, [256, 1, 1]],
#     [-1, 1, nn.Upsample, [None, 2, "nearest"]],
#     [[-1, 4], 1, Concat, [1]], # cat backbone P3
#     [-1, 3, C3, [256, False]], # 17 (P3/8-small)
# 
#     [-1, 1, Conv, [256, 3, 2]],
#     [[-1, 14], 1, Concat, [1]], # cat head P4
#     [-1, 3, C3, [512, False]], # 20 (P4/16-medium)
# 
#     [-1, 1, Conv, [512, 3, 2]],
#     [[-1, 10], 1, Concat, [1]], # cat head P5
#     [-1, 3, C3, [1024, False]], # 23 (P5/32-large)
# 
#     [[17, 20, 23], 1, Detect, [nc, anchors]], # Detect(P3, P4, P5)
#   ]
  • 在yolov8中,depth决定模型的深度,即重复的次数,重复次数=number * depth
  • width决定模型的通道数,通道数=module中的通道数 * width

三、手写yolov8l的输出

fromnarguments
0-1    1[3,64,3,2]
1-11[64,128,3,2]
2-13[128,128,3,True]
3-11[128,256,3,2]
4-16[256,256,6,True]
5-11[256,512,3,2]
6-16[512,512,6,True]
7-11[512,512,3,2]
8-13[512,512,3,True]
9-11[512,512,5]
10-11[None,2,'nearest']
11[-1,6]1[1]
12-13[1024,512,3]
13-11[None,2,'nearest']
14[-1,4]1[1]
15-13[768,256,3]
16-11[256,256,3,2]
17[-1,12]1[1]
18-13[768,512,3]
19-11[512,512,3,2]
20[-1,9]1[1]
21-13[1024,512,3]
22[15,18,21]1[3,[256,512,512]]

总结

  • 相比于yolov8n和yolov8s,yolov8l的深度和宽度没有缩小
  • 同时,yolov8l的最大通道数由1024降为了512

原文地址:https://blog.csdn.net/a536723241/article/details/140111573

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!