YOLOv7-tiny网络结构图及yaml文件 详细备注

news/2024/11/23 4:44:07/

YOLOv7-tiny

  • 整体网络结构图
  • yolov7-tiny.yaml
  • 组件模块
    • MX
    • CBL
    • SPPCSP
      • 结构图
      • yaml
      • 构建代码
    • MCB
      • 结构图
      • yaml文件表示
      • common.py代码
  • 参考

整体网络结构图

在这里插入图片描述

yolov7-tiny.yaml

# parameters
nc: 80  # number of classes
depth_multiple: 1.0  # model depth multiple
width_multiple: 1.0  # layer channel multiple# anchors
anchors:- [10,13, 16,30, 33,23]  # P3/8- [30,61, 62,45, 59,119]  # P4/16- [116,90, 156,198, 373,326]  # P5/32# yolov7-tiny backbone
backbone:# [from, number, module, args] ch_out, k=1, s=1, p=None, g=1, act=True[[-1, 1, Conv, [32, 3, 2, None, 1, nn.LeakyReLU(0.1)]],  # 0-P1/2  [-1, 1, Conv, [64, 3, 2, None, 1, nn.LeakyReLU(0.1)]],  # 1-P2/4    [-1, 1, Conv, [32, 1, 1, None, 1, nn.LeakyReLU(0.1)]],  #MCB[-2, 1, Conv, [32, 1, 1, None, 1, nn.LeakyReLU(0.1)]],[-1, 1, Conv, [32, 3, 1, None, 1, nn.LeakyReLU(0.1)]],[-1, 1, Conv, [32, 3, 1, None, 1, nn.LeakyReLU(0.1)]],[[-1, -2, -3, -4], 1, Concat, [1]],[-1, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]],  # 7[-1, 1, MP, []],  # 8-P3/8[-1, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]],[-2, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]],[-1, 1, Conv, [64, 3, 1, None, 1, nn.LeakyReLU(0.1)]],[-1, 1, Conv, [64, 3, 1, None, 1, nn.LeakyReLU(0.1)]],[[-1, -2, -3, -4], 1, Concat, [1]],[-1, 1, Conv, [128, 1, 1, None, 1, nn.LeakyReLU(0.1)]],  # 14[-1, 1, MP, []],  # 15-P4/16[-1, 1, Conv, [128, 1, 1, None, 1, nn.LeakyReLU(0.1)]],[-2, 1, Conv, [128, 1, 1, None, 1, nn.LeakyReLU(0.1)]],[-1, 1, Conv, [128, 3, 1, None, 1, nn.LeakyReLU(0.1)]],[-1, 1, Conv, [128, 3, 1, None, 1, nn.LeakyReLU(0.1)]],[[-1, -2, -3, -4], 1, Concat, [1]],[-1, 1, Conv, [256, 1, 1, None, 1, nn.LeakyReLU(0.1)]],  # 21[-1, 1, MP, []],  # 22-P5/32[-1, 1, Conv, [256, 1, 1, None, 1, nn.LeakyReLU(0.1)]],[-2, 1, Conv, [256, 1, 1, None, 1, nn.LeakyReLU(0.1)]],[-1, 1, Conv, [256, 3, 1, None, 1, nn.LeakyReLU(0.1)]],[-1, 1, Conv, [256, 3, 1, None, 1, nn.LeakyReLU(0.1)]],[[-1, -2, -3, -4], 1, Concat, [1]],[-1, 1, Conv, [512, 1, 1, None, 1, nn.LeakyReLU(0.1)]],  # 28]# yolov7-tiny head
head:#SPPCSP[[-1, 1, Conv, [256, 1, 1, None, 1, nn.LeakyReLU(0.1)]],[-2, 1, Conv, [256, 1, 1, None, 1, nn.LeakyReLU(0.1)]],[-1, 1, SP, [5]],[-2, 1, SP, [9]],[-3, 1, SP, [13]],[[-1, -2, -3, -4], 1, Concat, [1]],[-1, 1, Conv, [256, 1, 1, None, 1, nn.LeakyReLU(0.1)]],[[-1, -7], 1, Concat, [1]],[-1, 1, Conv, [256, 1, 1, None, 1, nn.LeakyReLU(0.1)]],  # 37[-1, 1, Conv, [128, 1, 1, None, 1, nn.LeakyReLU(0.1)]],[-1, 1, nn.Upsample, [None, 2, 'nearest']],[21, 1, Conv, [128, 1, 1, None, 1, nn.LeakyReLU(0.1)]], # route backbone P4[[-1, -2], 1, Concat, [1]],[-1, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]],[-2, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]],[-1, 1, Conv, [64, 3, 1, None, 1, nn.LeakyReLU(0.1)]],[-1, 1, Conv, [64, 3, 1, None, 1, nn.LeakyReLU(0.1)]],[[-1, -2, -3, -4], 1, Concat, [1]],[-1, 1, Conv, [128, 1, 1, None, 1, nn.LeakyReLU(0.1)]],  # 47[-1, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]],[-1, 1, nn.Upsample, [None, 2, 'nearest']],[14, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]], # route backbone P3[[-1, -2], 1, Concat, [1]],[-1, 1, Conv, [32, 1, 1, None, 1, nn.LeakyReLU(0.1)]],[-2, 1, Conv, [32, 1, 1, None, 1, nn.LeakyReLU(0.1)]],[-1, 1, Conv, [32, 3, 1, None, 1, nn.LeakyReLU(0.1)]],[-1, 1, Conv, [32, 3, 1, None, 1, nn.LeakyReLU(0.1)]],[[-1, -2, -3, -4], 1, Concat, [1]],[-1, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]],  # 57[-1, 1, Conv, [128, 3, 2, None, 1, nn.LeakyReLU(0.1)]],[[-1, 47], 1, Concat, [1]],[-1, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]],[-2, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]],[-1, 1, Conv, [64, 3, 1, None, 1, nn.LeakyReLU(0.1)]],[-1, 1, Conv, [64, 3, 1, None, 1, nn.LeakyReLU(0.1)]],[[-1, -2, -3, -4], 1, Concat, [1]],[-1, 1, Conv, [128, 1, 1, None, 1, nn.LeakyReLU(0.1)]],  # 65[-1, 1, Conv, [256, 3, 2, None, 1, nn.LeakyReLU(0.1)]],[[-1, 37], 1, Concat, [1]],[-1, 1, Conv, [128, 1, 1, None, 1, nn.LeakyReLU(0.1)]],[-2, 1, Conv, [128, 1, 1, None, 1, nn.LeakyReLU(0.1)]],[-1, 1, Conv, [128, 3, 1, None, 1, nn.LeakyReLU(0.1)]],[-1, 1, Conv, [128, 3, 1, None, 1, nn.LeakyReLU(0.1)]],[[-1, -2, -3, -4], 1, Concat, [1]],[-1, 1, Conv, [256, 1, 1, None, 1, nn.LeakyReLU(0.1)]],  # 73[57, 1, Conv, [128, 3, 1, None, 1, nn.LeakyReLU(0.1)]],[65, 1, Conv, [256, 3, 1, None, 1, nn.LeakyReLU(0.1)]],[73, 1, Conv, [512, 3, 1, None, 1, nn.LeakyReLU(0.1)]],[[74,75,76], 1, IDetect, [nc, anchors]],   # Detect(P3, P4, P5)]

组件模块

MX

池化层,默认表示两倍下采样,

class MP(nn.Module):def __init__(self, k=2):super(MP, self).__init__()self.m = nn.MaxPool2d(kernel_size=k, stride=k)def forward(self, x):return self.m(x)
   [-1, 1, MP, []],  # 8-P3/8

CBL

就是表示Conv+BN+LeakyReLU
[-1, 1, Conv, [256, 1, 1, None, 1, nn.LeakyReLU(0.1)]]

class Conv(nn.Module):# Standard convolutiondef __init__(self, c1, c2, k=1, s=1, p=None, g=1, act=True):  # ch_in, ch_out, kernel, stride, padding, groupssuper(Conv, self).__init__()self.conv = nn.Conv2d(c1, c2, k, s, autopad(k, p), groups=g, bias=False)self.bn = nn.BatchNorm2d(c2)self.act = nn.SiLU() if act is True else (act if isinstance(act, nn.Module) else nn.Identity())def forward(self, x):return self.act(self.bn(self.conv(x)))def fuseforward(self, x):return self.act(self.conv(x))

SPPCSP

结构图

在这里插入图片描述

yaml

yaml文件中如下表示,直接看最后一层输出通道数,尺寸不会变化,SP模块默认设置卷积Pading为卷积核的一半大小

  #SPPCSP[[-1, 1, Conv, [256, 1, 1, None, 1, nn.LeakyReLU(0.1)]], #20*20*256[-2, 1, Conv, [256, 1, 1, None, 1, nn.LeakyReLU(0.1)]], #20*20*256[-1, 1, SP, [5]],[-2, 1, SP, [9]],[-3, 1, SP, [13]],[[-1, -2, -3, -4], 1, Concat, [1]],                         #20*20*512[-1, 1, Conv, [256, 1, 1, None, 1, nn.LeakyReLU(0.1)]],     #20*20*256[[-1, -7], 1, Concat, [1]],                                 #20*20*512[-1, 1, Conv, [256, 1, 1, None, 1, nn.LeakyReLU(0.1)]],#20  #20*20*256

构建代码

yaml文件中的SP表示如下

# i+2p-k
class SP(nn.Module):def __init__(self, k=3, s=1):super(SP, self).__init__()self.m = nn.MaxPool2d(kernel_size=k, stride=s, padding=k // 2)def forward(self, x):return self.m(x)

MCB

结构图

在这里插入图片描述

yaml文件表示

直接看最后一层输出的通道数看Concat后变化,

   [-1, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]],               #40*40*64[-2, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]],[-1, 1, Conv, [64, 3, 1, None, 1, nn.LeakyReLU(0.1)]],[-1, 1, Conv, [64, 3, 1, None, 1, nn.LeakyReLU(0.1)]],[[-1, -2, -3, -4], 1, Concat, [1]],[-1, 1, Conv, [128, 1, 1, None, 1, nn.LeakyReLU(0.1)]],  # 30       #40*40*128

common.py代码

通过Conv函数构建即可

参考

yolov7-tiny网络结构图
https://blog.csdn.net/weixin_51346544/article/details/129322706


http://www.ppmy.cn/news/328080.html

相关文章

YOLOv7 | 模型结构与正负样本分配解析

如有错误,恳请指出。 Yolov7的原作者就是Yolov4的原作者。看论文的时候看到比较乱,这里可能会比较杂乱的记录一下我觉得有点启发的东西。对于yolov7的代码,我也没有仔细的看,只是大概的看了下其他博客提到的些细节。所以这里也不会…

理解yolov6网络结构

yolov6论文地址:https://arxiv.org/abs/2209.02976 先上一张yolov6的网络架构 图片来源于网络 BACKBONE yolov6使用了repVGG作为backbone 如果不了解repVGG的可以看原文 论文地址https://arxiv.org/pdf/2101.03697.pdf 这里简单过一下,repVGG其核心思…

yolov7各个模型的网络结构图(最详细)

美团刚刚发出yolov6,AB大神就带着yolov7来了。。。。。这速度是真快。。 在 5-160 FPS 范围内速度和精度超过所有已知目标检测器。 在 后不到两个星期,提出 YOLOv4 的团队就发布了更新一代的版本。 YOLOv7 的论文被提交到了预印版论文平台 arXiv 上&am…

pytorch构建YOLOV7网络结构

文章目录 前言一、网络结构图二、各模块的实现1.BConv模块2.E-ELAN模块3.MPConv模块4.SPPCSPC模块5.CatConv模块6.RepConv模块 三、整体实现总结 前言 前不久,正宗的YOLOV7横空出世,引来了很多人的关注,因为这次是官方作者的又一力作&#x…

YOLO系列 --- YOLOV7算法(四):YOLO V7算法网络结构解析

YOLO系列 — YOLOV7算法(四):YOLO V7算法网络结构解析 今天来讲讲YOLO V7算法网络结构吧~ 在train.py中大概95行的地方开始创建网络,如下图(YOLO V7下载的时间不同,可能代码有少许的改动,所以行…

yolov7 网络架构深度解析

在美团yolov6刚出来不到一个月,yolov4的官方人马yolov7带着论文和代码高调现身,迅速霸屏,膜拜下速度和精度: 四个字“多快好省”,yolov7依旧基于anchor based的方法,同时在网络架构上增加E-ELAN层&#xf…

最新|全新风格原创YOLOv7、YOLOv5和YOLOX网络结构解析图

💡本篇分享一下个人绘制的原创全新风格YOLOv7网络结构图、YOLOv5网络结构图和YOLOX网络结构图 个人感觉搭配还行,看着比较直观,所以开源分享一下。 文章目录 YOLOv5 网络结构图(最新 推荐🔥🔥🔥)YOLOv7 网络…

【YOLOv7_0.1】网络结构与源码解析

文章目录 前言整体网络结构分解的yolov7.yaml各组件结构ELAN1 (backbone)ELAN2 (head)MPConvSPPCSPCRepConv(重参数卷积)原理理解层面代码实现层面 ImpConv(隐性知识学习)训练时推理时 References 前言 论文地址 YOLOv7源码 下面…