YOLO11网络结构以及改进1

news2025/2/22 6:35:08

YOLO11

    • 1.YOLO11网络结构图在哪里?
    • 2.对应的网络结构图
    • 3.每一个模块详解
      • 3.1 Conv模块
      • 3.2关于卷积模块
      • 3.3 关于给各个模块指定参数的细节
    • 4.加入CBAM

1.YOLO11网络结构图在哪里?

在这里插入图片描述

2.对应的网络结构图

在这里插入图片描述

3.每一个模块详解

3.1 Conv模块

位置:ultralytics/nn/modules/conv.py
在这里插入图片描述
特点:YOLO11代码更加模块化以及简洁化

3.2关于卷积模块

在这里插入图片描述

3.3 关于给各个模块指定参数的细节

回到yolo11.yaml文件,我们只是绘制了对应的网络模块,而没有管后面的参数信息,这明显是不够的,后期我们进行模型改进,也是要注意这个的,不是随心所欲。
在这里插入图片描述
在这里插入图片描述`def parse_model(d, ch, verbose=True): # model_dict, input_channels(3)
“”“Parse a YOLO model.yaml dictionary into a PyTorch model.”“”
import ast

# Args
legacy = True  # backward compatibility for v3/v5/v8/v9 models
max_channels = float("inf")
nc, act, scales = (d.get(x) for x in ("nc", "activation", "scales"))
depth, width, kpt_shape = (d.get(x, 1.0) for x in ("depth_multiple", "width_multiple", "kpt_shape"))
if scales:
    scale = d.get("scale")
    if not scale:
        scale = tuple(scales.keys())[0]
        LOGGER.warning(f"WARNING ⚠️ no model scale passed. Assuming scale='{scale}'.")
    depth, width, max_channels = scales[scale]

if act:
    Conv.default_act = eval(act)  # redefine default activation, i.e. Conv.default_act = nn.SiLU()
    if verbose:
        LOGGER.info(f"{colorstr('activation:')} {act}")  # print

if verbose:
    LOGGER.info(f"\n{'':>3}{'from':>20}{'n':>3}{'params':>10}  {'module':<45}{'arguments':<30}")
ch = [ch]
layers, save, c2 = [], [], ch[-1]  # layers, savelist, ch out
for i, (f, n, m, args) in enumerate(d["backbone"] + d["head"]):  # from, number, module, args
    m = getattr(torch.nn, m[3:]) if "nn." in m else globals()[m]  # get module
    for j, a in enumerate(args):
        if isinstance(a, str):
            try:
                args[j] = locals()[a] if a in locals() else ast.literal_eval(a)
            except ValueError:
                pass
    n = n_ = max(round(n * depth), 1) if n > 1 else n  # depth gain
    if m in {
        Classify,
        Conv,
        ConvTranspose,
        GhostConv,
        Bottleneck,
        GhostBottleneck,
        SPP,
        SPPF,
        C2fPSA,
        C2PSA,
        DWConv,
        Focus,
        BottleneckCSP,
        C1,
        C2,
        C2f,
        C3k2,
        RepNCSPELAN4,
        ELAN1,
        ADown,
        AConv,
        SPPELAN,
        C2fAttn,
        C3,
        C3TR,
        C3Ghost,
        nn.ConvTranspose2d,
        DWConvTranspose2d,
        C3x,
        RepC3,
        PSA,
        SCDown,
        C2fCIB,
    }:
        c1, c2 = ch[f], args[0]
        if c2 != nc:  # if c2 not equal to number of classes (i.e. for Classify() output)
            c2 = make_divisible(min(c2, max_channels) * width, 8)
        if m is C2fAttn:
            args[1] = make_divisible(min(args[1], max_channels // 2) * width, 8)  # embed channels
            args[2] = int(
                max(round(min(args[2], max_channels // 2 // 32)) * width, 1) if args[2] > 1 else args[2]
            )  # num heads

        args = [c1, c2, *args[1:]]
        if m in {
            BottleneckCSP,
            C1,
            C2,
            C2f,
            C3k2,
            C2fAttn,
            C3,
            C3TR,
            C3Ghost,
            C3x,
            RepC3,
            C2fPSA,
            C2fCIB,
            C2PSA,
        }:
            args.insert(2, n)  # number of repeats
            n = 1
        if m is C3k2:  # for M/L/X sizes
            legacy = False
            if scale in "mlx":
                args[3] = True
    elif m is AIFI:
        args = [ch[f], *args]
    elif m in {HGStem, HGBlock}:
        c1, cm, c2 = ch[f], args[0], args[1]
        args = [c1, cm, c2, *args[2:]]
        if m is HGBlock:
            args.insert(4, n)  # number of repeats
            n = 1
    elif m is ResNetLayer:
        c2 = args[1] if args[3] else args[1] * 4
    elif m is nn.BatchNorm2d:
        args = [ch[f]]
    elif m is Concat:
        c2 = sum(ch[x] for x in f)
    elif m in {Detect, WorldDetect, Segment, Pose, OBB, ImagePoolingAttn, v10Detect}:
        args.append([ch[x] for x in f])
        if m is Segment:
            args[2] = make_divisible(min(args[2], max_channels) * width, 8)
        if m in {Detect, Segment, Pose, OBB}:
            m.legacy = legacy
    elif m is RTDETRDecoder:  # special case, channels arg must be passed in index 1
        args.insert(1, [ch[x] for x in f])
    elif m is CBLinear:
        c2 = args[0]
        c1 = ch[f]
        args = [c1, c2, *args[1:]]
    elif m is CBFuse:
        c2 = ch[f[-1]]
    else:
        c2 = ch[f]

    m_ = nn.Sequential(*(m(*args) for _ in range(n))) if n > 1 else m(*args)  # module
    t = str(m)[8:-2].replace("__main__.", "")  # module type
    m_.np = sum(x.numel() for x in m_.parameters())  # number params
    m_.i, m_.f, m_.type = i, f, t  # attach index, 'from' index, type
    if verbose:
        LOGGER.info(f"{i:>3}{str(f):>20}{n_:>3}{m_.np:10.0f}  {t:<45}{str(args):<30}")  # print
    save.extend(x % i for x in ([f] if isinstance(f, int) else f) if x != -1)  # append to savelist
    layers.append(m_)
    if i == 0:
        ch = []
    ch.append(c2)
return nn.Sequential(*layers), sorted(save)`

改进一定要修改此处代码

4.加入CBAM

由于本身就有CBAM的代码
所以只需要在yaml中加入即可

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

# Parameters
nc: 80 # number of classes
scales: # model compound scaling constants, i.e. 'model=yolo11n.yaml' will call yolo11.yaml with scale 'n'
  # [depth, width, max_channels]
  n: [0.50, 0.25, 1024] # summary: 319 layers, 2624080 parameters, 2624064 gradients, 6.6 GFLOPs
  s: [0.50, 0.50, 1024] # summary: 319 layers, 9458752 parameters, 9458736 gradients, 21.7 GFLOPs
  m: [0.50, 1.00, 512] # summary: 409 layers, 20114688 parameters, 20114672 gradients, 68.5 GFLOPs
  l: [1.00, 1.00, 512] # summary: 631 layers, 25372160 parameters, 25372144 gradients, 87.6 GFLOPs
  x: [1.00, 1.50, 512] # summary: 631 layers, 56966176 parameters, 56966160 gradients, 196.0 GFLOPs

# YOLO11n backbone
backbone:
  # [from, repeats, module, args]
  - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2
  - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4
  - [-1, 2, C3k2, [256, False, 0.25]]
  - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8
  - [-1, 2, C3k2, [512, False, 0.25]]
  - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16
  - [-1, 2, C3k2, [512, True]]
  - [-1, 1, Conv, [1024, 3, 2]] # 7-P5/32
  - [-1, 2, C3k2, [1024, True]]
  - [-1, 1, SPPF, [1024, 5]] # 9
  - [-1, 2, C2PSA, [1024]] # 10

# YOLO11n head
head:
  - [-1, 1, nn.Upsample, [None, 2, "nearest"]]
  - [[-1, 6], 1, Concat, [1]] # cat backbone P4
  - [-1, 2, C3k2, [512, False]] # 13

  - [-1, 1, nn.Upsample, [None, 2, "nearest"]]
  - [[-1, 4], 1, Concat, [1]] # cat backbone P3
  - [-1, 2, C3k2, [256, False]] # 16 (P3/8-small)
  - [-1, 1, CBAM, []]

  - [-1, 1, Conv, [256, 3, 2]]
  - [[-1, 13], 1, Concat, [1]] # cat head P4
  - [-1, 2, C3k2, [512, False]] # 19 (P4/16-medium)
  - [-1, 1, CBAM, []]

  - [-1, 1, Conv, [512, 3, 2]]
  - [[-1, 10], 1, Concat, [1]] # cat head P5
  - [-1, 2, C3k2, [1024, True]] # 22 (P5/32-large)
  - [-1, 1, CBAM, []]

  - [[16, 19, 22], 1, Detect, [nc]] # Detect(P3, P4, P5)

修改配置文件
在这里插入图片描述结果图
在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2298300.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

AI 编程私有化部署,在使用 cline 时,可能无法避免私隐的泄漏问题

摘录&#xff1a;Cline Privacy Policy https://github.com/cline/cline/blob/main/docs/PRIVACY.md Key Points Cline operates entirely client-side as a VS Code extensionNo code or data is collected, stored, or transmitted to Clines servers 问题是&#xff1a…

计算机视觉-局部特征

一、局部特征 1.1全景拼接 先用RANSAC估计出变换&#xff0c;就可以拼接两张图片 ①提取特征 ②匹配特征 ③拼接图像 1.2 点的特征 怎么找到对应点&#xff1f;&#xff08;才能做点对应关系RANSAC&#xff09; &#xff1a;特征检测 我们希望找到的点具有的特征有什么特…

数据结构:Map Set(一)

目录 一、搜索树 1、概念 2、查找 3、插入 4、删除 二、搜索 1、概念及场景 2、模型 &#xff08;1&#xff09;纯key模型 &#xff08;2&#xff09;Key-Value模型 三、Map的使用 1、什么是Map&#xff1f; 2、Map的常用方法 &#xff08;1&#xff09;V put(K …

关闭浏览器安全dns解决访问速度慢的问题

谷歌浏览器加载速度突然变慢了&#xff1f;检查安全DNS功能(DoH)是否被默认开启。 谷歌浏览器在去年已经推出安全DNS功能(即DoH) , 启用此功能后可以通过加密的DNS增强网络连接安全性。例如查询请求被加密后网络运营商将无法嗅探用户访问的地址&#xff0c;因此对于增强用户的…

C语言-章节 4:函数的定义与声明 ——「神秘法术的卷轴」

少年和 Inta 成功通过运算符与表达式的考验后&#xff0c;继续在函数城堡中探索。他们沿着一条闪烁着幽光的走廊前行&#xff0c;走廊两侧的墙壁上刻满了奇异的符号&#xff0c;仿佛在诉说着古老的编程秘密。终于&#xff0c;他们来到了一间神秘的房间&#xff0c;房间中央悬浮…

47.实验室管理系统(基于SSM和html的Java项目)

目录 1.系统的受众说明 2.系统可行性分析 2.1 经济可行性 2.2 技术可行性 2.2.1 Java Web技术 2.2.2 Eclipse 2.2.3 Tomcat 2.2.4 数据库 2.2.5 Layui框架 2.2.6 SSM框架 3.系统需求分析 3.1 用户需求分析 3.2 功能需求分析 3.3 其他需求分析 4.系统设计 4.1 系…

【免费送书活动】《MySQL 9从入门到性能优化(视频教学版)》

本博主免费赠送读者3本书&#xff0c;书名为《MySQL 9从入门到性能优化&#xff08;视频教学版&#xff09;》。 《MySQL 9从入门到性能优化&#xff08;视频教学版&#xff09;&#xff08;数据库技术丛书&#xff09;》(王英英)【摘要 书评 试读】- 京东图书 这本书已经公开…

【人工智能】通过python练习机器学习中的8大算法

python一系列练习在前面几节中基本练习了一遍&#xff0c;本篇通过机器学习的算法加强python的训练。我印象中常用的几种算法有&#xff1a;线性回归、逻辑回归&#xff0c;决策树&#xff0c;向量机SVM&#xff0c;KNN-近邻&#xff0c;朴素贝叶斯&#xff0c;K-means&#xf…

Android Studio2024版本安装环境SDK、Gradle配置

一、软件版本&#xff0c;安装包附上 &#x1f449;android-studio-2024.1.2.12-windows.exe&#x1f448; &#x1f449;百度网盘Android Studio安装包&#x1f448; &#xff08;若下载连链接失效可去百度网盘链接下载&#xff09; 二、软件安装过程 ​ ​ ​ 三、准备运行…

RabbitMQ学习—day2—安装

目录 普通Linux安装 安装RabbitMQ 1、下载 2、安装 3. Web管理界面及授权操作 Docker 安装 强力推荐学docker&#xff0c;使用docker安装 普通Linux安装 安装RabbitMQ 1、下载 官网下载地址&#xff1a;https://www.rabbitmq.com/download.html(opens new window) 这…

Jenkins 新建配置Pipeline任务 三

Jenkins 新建配置Pipeline任务 三 一. 登录 Jenkins 网页输入 http://localhost:8080 输入账号、密码登录 一个没有创建任务的空 Jenkins 二. 创建 任务 图 NewItem 界面左上角 New Item 图NewItemSelect 1.Enter an item name&#xff1a;输入任务名 2.Select an ite…

社区版IDEA中配置TomCat(详细版)

文章目录 1、下载Smart TomCat2、配置TomCat3、运行代码 1、下载Smart TomCat 由于小编的是社区版&#xff0c;没有自带的tomcat server&#xff0c;所以在设置的插件里面搜索&#xff0c;安装第一个&#xff08;注意&#xff1a;安装时一定要关闭外网&#xff0c;小编因为这个…

MATLAB 生成脉冲序列 pulstran函数使用详解

MATLAB 生成脉冲序列 pulstran函数使用详解 目录 前言 一、参数说明 二、示例一 三、示例二 总结 前言 MATLAB中的pulstran函数用于生成脉冲序列&#xff0c;支持连续或离散脉冲。该函数通过将原型脉冲延迟并相加&#xff0c;生成脉冲序列&#xff0c;适用于信号处理和系统…

概率论、组合数学知识点汇总

1、概率论知识点 全概率公式&#xff1a;如果事件B1,B2,…,Bn是样本空间的一个划分&#xff0c;则&#xff1a;贝叶斯定理&#xff1a;协方差&#xff1a;协方差用来衡量两个变量之间的变化趋势是否一致&#xff0c;公式为相关系数&#xff08;Pearson&#xff09;&#xff1a…

【人工智能】deepseek R1模型在蓝耘智算平台的搭建与机器学习的探索

&#x1f4dd;个人主页&#x1f339;&#xff1a;Eternity._ &#x1f339;&#x1f339;期待您的关注 &#x1f339;&#x1f339; ❀ 蓝耘智算平台 deepseek R1简介与优点蓝耘智算平台蓝耘智算平台简介蓝耘智算平台优势deepseek R1模型在蓝耘智算平台的搭建模型使用与机器学习…

tomcat html乱码

web tomcat html中文乱码 将html文件改成jsp <% page language"java" contentType"text/html; charsetUTF-8" pageEncoding"UTF-8"%>添加 <meta charset"UTF-8">

基于单片机的智能奶茶机(论文+源码+图纸)

1总体架构设计 本课题为基于单片机的智能奶茶机设计&#xff0c;其系统架构上设计如图2.1所示&#xff0c;整个系统包括了DS18B20温度传感器、继电器模块、LCD液晶、蜂鸣器、按键、STC89C52单片机等器件&#xff0c;在功能上用户可以通过按键键控制选择甜度和添加物以及设置温度…

Centos7系统安装redis

Centos7系统安装redis 下载编译配置配置环境变量服务脚本安装使用远程连接 下载 下载地址&#xff1a;https://download.redis.io/releases/&#xff0c;选择版本6.2.7 具体下载链接&#xff1a;https://download.redis.io/releases/redis-6.2.7.tar.gz 操作&#xff1a;在ro…

图数据库neo4j进阶(一):csv文件导入节点及关系

CSV 一、load csv二、neo4j-admin import<一>、导入入口<二>、文件准备<三>、命令详解 一、load csv 在neo4j Browser中使用Cypher语句LOAD CSV,对于数据量比较大的情况,建议先运行create constraint语句来生成约束 create constraint for (s:Student) req…

深度剖析责任链模式

一、责任链模式的本质&#xff1a;灵活可扩展的流水线处理 责任链模式&#xff08;Chain of Responsibility Pattern&#xff09;是行为型设计模式的代表&#xff0c;其核心思想是将请求的发送者与接收者解耦&#xff0c;允许多个对象都有机会处理请求。这种模式完美解决了以下…