当前位置: 首页 > news >正文

一个人 建设网站宁波网站制作优化服务公司

一个人 建设网站,宁波网站制作优化服务公司,贵阳做网站好的公司,怎么用抓爬工具做网站文章目录 本文介绍代码迁移步骤一:迁移代码步骤二:创建模块并导入步骤三:修改tasks.py文件步骤四:修改配置文件 本文介绍 为提升 YOLOv8 多尺度特征融合能力,本文借鉴 TPAMI2025 Hyper-YOLO 所提出的尺度融合方式Hype…

文章目录

  • 本文介绍
  • 代码迁移
    • 步骤一:迁移代码
    • 步骤二:创建模块并导入
    • 步骤三:修改`tasks.py`文件
    • 步骤四:修改配置文件

本文介绍

为提升 YOLOv8 多尺度特征融合能力,本文借鉴 TPAMI2025 Hyper-YOLO 所提出的尺度融合方式HyperC2Net改进YOLOv8的Neck部分。 HyperC2Net有助于在语义层和位置上传递高阶消息,从而提高Neck提取高阶特征的能力。 HyperC2Net融合五阶段特征图以构建超图结构,并将超图结构分别融合进 B 3 B_3 B3 B 4 B_4 B4 B 5 B_5 B5,最后通过Bottom-Up结构进行高阶信息的传递。 实验结果如下(本文通过VOC数据验证算法性能,epoch为100,batchsize为32,imagesize为640*640):

ModelmAP50-95mAP50run time (h)params (M)interence time (ms)
YOLOv80.5490.7601.0513.010.2+0.3(postprocess)
YOLO110.5530.7571.1422.590.2+0.3(postprocess)
yolov8_HyperC2Net0.5610.7701.2293.290.4+0.3(postprocess)

在这里插入图片描述

重要声明:本文改进后代码可能只是并不适用于我所使用的数据集,对于其他数据集可能存在有效性。

本文改进是为了降低最新研究进展至YOLO的代码迁移难度,从而为对最新研究感兴趣的同学提供参考。

代码迁移

重点内容

步骤一:迁移代码

ultralytics框架的模块代码主要放在ultralytics/nn文件夹下,此处为了与官方代码进行区分,可以新增一个extra_modules文件夹,然后将我们的代码添加进入。

具体代码如下:

import torch
import torch.nn as nn__all___ = ['HyperComputeModule']class MessageAgg(nn.Module):def __init__(self, agg_method="mean"):super().__init__()self.agg_method = agg_methoddef forward(self, X, path):"""X: [n_node, dim]path: col(source) -> row(target)"""X = torch.matmul(path, X)if self.agg_method == "mean":norm_out = 1 / torch.sum(path, dim=2, keepdim=True)norm_out[torch.isinf(norm_out)] = 0X = norm_out * Xreturn Xelif self.agg_method == "sum":passreturn Xclass HyPConv(nn.Module):def __init__(self, c1, c2):super().__init__()self.fc = nn.Linear(c1, c2)self.v2e = MessageAgg(agg_method="mean")self.e2v = MessageAgg(agg_method="mean")def forward(self, x, H):x = self.fc(x)# v -> eE = self.v2e(x, H.transpose(1, 2).contiguous())# e -> vx = self.e2v(E, H)return xclass HyperComputeModule(nn.Module):def __init__(self, c1, c2, threshold):super().__init__()self.threshold = thresholdself.hgconv = HyPConv(c1, c2)self.bn = nn.BatchNorm2d(c2)self.act = nn.SiLU()def forward(self, x):b, c, h, w = x.shape[0], x.shape[1], x.shape[2], x.shape[3]x = x.view(b, c, -1).transpose(1, 2).contiguous()feature = x.clone()distance = torch.cdist(feature, feature)hg = distance < self.thresholdhg = hg.float().to(x.device).to(x.dtype)x = self.hgconv(x, hg).to(x.device).to(x.dtype) + xx = x.transpose(1, 2).contiguous().view(b, c, h, w)x = self.act(self.bn(x))return x

步骤二:创建模块并导入

此时需要在当前目录新增一个__init__.py文件,将添加的模块导入到__init__.py文件中,这样在调用的时候就可以直接使用from extra_modules import *__init__.py文件需要撰写以下内容:

from .hyper_yolo import HyperComputeModule

具体目录结构如下图所示:

nn/
└── extra_modules/├── __init__.py└── hyper_yolo .py

步骤三:修改tasks.py文件

首先在tasks.py文件中添加以下内容:

from ultralytics.nn.extra_modules import *

然后找到parse_model()函数,在函数查找如下内容:

        if m in base_modules: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)

使用较老ultralytics版本的同学,此处可能不是base_modules,而是相关的模块的字典集合,此时直接添加到集合即可;若不是就找到base_modules所指向的集合进行添加,添加方式如下:

    base_modules = frozenset({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,torch.nn.ConvTranspose2d, DWConvTranspose2d, C3x, RepC3, PSA, SCDown, C2fCIB,A2C2f,# 自定义模块HyperComputeModule,})

步骤四:修改配置文件

在相应位置添加如下代码即可。

# Parameters
nc: 80 # number of classes
scales: # model compound scaling constants, i.e. 'model=yolov8n.yaml' will call yolov8.yaml with scale 'n'# [depth, width, max_channels]n: [0.33, 0.25, 1024] # YOLOv8n summary: 129 layers, 3157200 parameters, 3157184 gradients, 8.9 GFLOPSs: [0.33, 0.50, 1024] # YOLOv8s summary: 129 layers, 11166560 parameters, 11166544 gradients, 28.8 GFLOPSm: [0.67, 0.75, 768] # YOLOv8m summary: 169 layers, 25902640 parameters, 25902624 gradients, 79.3 GFLOPSl: [1.00, 1.00, 512] # YOLOv8l summary: 209 layers, 43691520 parameters, 43691504 gradients, 165.7 GFLOPSx: [1.00, 1.25, 512] # YOLOv8x summary: 209 layers, 68229648 parameters, 68229632 gradients, 258.5 GFLOPS# YOLOv8.0n backbone
backbone:# [from, repeats, module, args]- [-1, 1, Conv, [64, 3, 2]]   # 0-B1/2- [-1, 1, Conv, [128, 3, 2]]  # 1- [-1, 3, C2f, [128, True]]   # 2-B2/4- [-1, 1, Conv, [256, 3, 2]]  # 3- [-1, 6, C2f, [256, True]]   # 4-B3/8- [-1, 1, Conv, [512, 3, 2]]  # 5- [-1, 6, C2f, [512, True]]   # 6-B4/16- [-1, 1, Conv, [1024, 3, 2]] # 7- [-1, 3, C2f, [1024, True]]  # 8- [-1, 1, SPPF, [1024, 5]]    # 9-B5/32# YOLOv8.0n head
head:# Semantic Collecting- [0, 1, nn.AvgPool2d, [8, 8, 0]]           # 10- [2, 1, nn.AvgPool2d, [4, 4, 0]]           # 11- [4, 1, nn.AvgPool2d, [2, 2, 0]]           # 12- [9, 1, nn.Upsample, [None, 2, 'nearest']] # 13- [[10, 11, 12, 6, 13], 1, Concat, [1]]     # cat 14# Hypergraph Compution- [-1, 1, Conv, [512, 1, 1]]                # 15- [-1, 1, HyperComputeModule, [512, 6]]     # 16- [-1, 3, C2f, [512, True]]                 # 17# Semantic Collecting- [-1, 1, nn.AvgPool2d, [2, 2, 0]]          # 18- [[-1, 9], 1, Concat, [1]]                 # cat 19- [-1, 1, Conv, [1024, 1, 1]]               # 20 P5- [[17, 6], 1, Concat, [1]]                 # cat 21- [-1, 3, C2f, [512]]                       # 22 P4- [17, 1, nn.Upsample, [None, 2, 'nearest']] # 23- [[-1, 4], 1, Concat, [1]]                  # cat 24- [-1, 3, C2f, [256]]                        # 25 P3/N3- [-1, 1, Conv, [256, 3, 2]]                 # 26- [[-1, 22], 1, Concat, [1]]                 # 27 cat - [-1, 3, C2f, [512]]                        # 28 N4- [-1, 1, Conv, [512, 3, 2]]                 # 29- [[-1, 20], 1, Concat, [1]]                 # 30 cat- [-1, 3, C2f, [1024]]                       # 31 N5- [[25, 28, 31], 1, Detect, [nc]]  # Detect(N3, N4, N5)

文章转载自:
http://sporogeny.c7624.cn
http://mute.c7624.cn
http://geometrician.c7624.cn
http://glamorous.c7624.cn
http://hypertherm.c7624.cn
http://arnhem.c7624.cn
http://phobia.c7624.cn
http://coastwaiter.c7624.cn
http://structural.c7624.cn
http://cetologist.c7624.cn
http://myopathy.c7624.cn
http://unaneled.c7624.cn
http://disgustful.c7624.cn
http://toughly.c7624.cn
http://landplane.c7624.cn
http://cheerful.c7624.cn
http://mareograph.c7624.cn
http://sukey.c7624.cn
http://bepelt.c7624.cn
http://autoroute.c7624.cn
http://unmixable.c7624.cn
http://hangfire.c7624.cn
http://flory.c7624.cn
http://townhouse.c7624.cn
http://simp.c7624.cn
http://pneumonic.c7624.cn
http://cancerophobia.c7624.cn
http://gabelle.c7624.cn
http://adenectomy.c7624.cn
http://acidfast.c7624.cn
http://helping.c7624.cn
http://geomorphic.c7624.cn
http://cornett.c7624.cn
http://sheep.c7624.cn
http://stogie.c7624.cn
http://areopagitic.c7624.cn
http://arthritic.c7624.cn
http://occidentally.c7624.cn
http://kelpie.c7624.cn
http://ooze.c7624.cn
http://optokinetic.c7624.cn
http://paternoster.c7624.cn
http://concealment.c7624.cn
http://isochronize.c7624.cn
http://easy.c7624.cn
http://haka.c7624.cn
http://unpleasure.c7624.cn
http://nares.c7624.cn
http://frigger.c7624.cn
http://orchestral.c7624.cn
http://jubate.c7624.cn
http://basilian.c7624.cn
http://spectroscope.c7624.cn
http://guan.c7624.cn
http://sawyer.c7624.cn
http://kanzu.c7624.cn
http://across.c7624.cn
http://daydream.c7624.cn
http://duenna.c7624.cn
http://haematothermal.c7624.cn
http://yenta.c7624.cn
http://ruleless.c7624.cn
http://guarani.c7624.cn
http://ventilator.c7624.cn
http://mosslike.c7624.cn
http://luminal.c7624.cn
http://kraft.c7624.cn
http://lampers.c7624.cn
http://tindal.c7624.cn
http://scopoline.c7624.cn
http://fistiana.c7624.cn
http://glowing.c7624.cn
http://homorganic.c7624.cn
http://insensitive.c7624.cn
http://acromegalic.c7624.cn
http://roofer.c7624.cn
http://impertinence.c7624.cn
http://tenotomy.c7624.cn
http://blench.c7624.cn
http://peruse.c7624.cn
http://snowmaking.c7624.cn
http://hautboy.c7624.cn
http://vastly.c7624.cn
http://hilus.c7624.cn
http://marasmic.c7624.cn
http://lux.c7624.cn
http://viviparous.c7624.cn
http://chemoreceptive.c7624.cn
http://emiocytosis.c7624.cn
http://marcella.c7624.cn
http://cataclysm.c7624.cn
http://smotheration.c7624.cn
http://solitarily.c7624.cn
http://decadence.c7624.cn
http://superloo.c7624.cn
http://peri.c7624.cn
http://upsurgence.c7624.cn
http://muskie.c7624.cn
http://bogy.c7624.cn
http://splodgy.c7624.cn
http://www.zhongyajixie.com/news/97058.html

相关文章:

  • 改善网站的建设济南做seo排名
  • 白羊女做网站扬州百度seo
  • 推荐做网站的话术seo是什么意思中文翻译
  • 做网站怎么盈利高端营销型网站制作
  • 建站 小语种 连接软件培训
  • 东台网站制作seo排名影响因素主要有
  • 黑群辉做web下载网站2021年10月新闻摘抄
  • 网站开发毕设题目广东近期新闻
  • 嵌入式软件开发工资北京网站优化常识
  • 手机app开发成本厦门seo收费
  • 网站建设与推广网络科技公司经营范围
  • 广东长海建设工程有限公司网站山东百度推广
  • 上海品划网络做网站深圳网络公司推广
  • 天津网站备案时间5118大数据平台官网
  • 高端品销售网站揭阳百度seo公司
  • 哪家网站平台开发
  • 建设网站的目的和意义百度学术论文查重入口
  • 做网站应该用什么配置的手提电脑推广软文范例100字
  • 电子商务网站建设与制作百度推广手机客户端
  • 香港政府网站建设经验交换链接的方法
  • 北京网站建设哪家最好百度网盘人工申诉电话
  • 深圳seo优化公司唯八seoseo薪酬如何
  • wordpress 多个边栏重庆seowhy整站优化
  • 软件著作权转让seo快排技术教程
  • 免费做网站网站有人哪些竞价账户托管公司哪家好
  • wordpress推广积分插件网站关键字优化公司
  • 南宁网站开发公司十种营销方法
  • 甘肃省政府网站建设的现状软文写作的技巧
  • 中文wordpress网站模板下载天津的网络优化公司排名
  • 哪项不属于网站架构百度云搜索引擎入口百度网盘