个人可以做网站吗,搜索引擎分哪三类,做网站一般什么配置,做网站开发的步骤YOLOv8最新改进系列#xff1a;YOLOv8最新改进系列:融合最新顶会提出的HCANet网络中卷积和注意力融合模块(CAFM)#xff0c;有效提升小目标检测性能#xff0c;大幅度拉升目标检测效果#xff01;遥遥领先#xff01;
B站全文戳这里#xff01;
详细的改进教程以及源码…YOLOv8最新改进系列YOLOv8最新改进系列:融合最新顶会提出的HCANet网络中卷积和注意力融合模块(CAFM)有效提升小目标检测性能大幅度拉升目标检测效果遥遥领先
B站全文戳这里
详细的改进教程以及源码戳这戳这戳这B站AI学术叫叫兽 源码在相簿的链接中动态中也有链接感谢支持祝科研遥遥领先
截止到发稿时B站YOLOv8最新改进系列的源码包已更新40种损失函数的改进自己排列组合2-4种后不考虑位置已达10万种以上改进方法考虑位置不同后可排列上百万种专注AI学术关注B站博主Ai学术叫叫兽er
YOLOv8最新改进系列:融合最新顶会提出的HCANet网络中卷积和注意力融合模块(CAFM)有效提升小目标检测性能大幅度拉升目标检测效果遥遥领先 HCANet提出原文戳这
一、摘要
摘要高光谱图像去噪是高光谱数据有效分析和解释的关键。然而同时建模全局和局部特征很少被探索以增强HSI去噪。在这封信中我们提出了一个混合卷积和注意力网络HCANet它利用了卷积神经网络CNN和变压器的优势。为了增强全局和局部特征的建模我们设计了一个卷积和注意力融合模块旨在捕获长程依赖性和邻域光谱相关性。此外为了改善多尺度信息聚合我们设计了一个多尺度前馈网络通过提取不同尺度的特征来提高去噪性能。在主流HSI数据集上的实验结果验证了HCANet的合理性和有效性。该模型能有效去除各种复杂噪声。我们的代码可在https://github.com/summitgao/HCANet上获得。
二、介绍
超光谱成像是一种强大的技术它可以从物体或场景中获取丰富的光谱信息。与RGB数据相比高光谱图像HSI捕获的光谱信息更精细。因此HSI已被广泛用于许多实际应用中例如解混[1]和地物分类[2]。然而HSI经常受到传感器成像过程中不可避免的混合噪声的困扰这是由于曝光时间和反射能量不足造成的。这些噪声可能会降低图像质量并妨碍后续分析和解释的性能。消除这些噪声可以提高地面目标检测和分类的准确性。因此HSI去噪是许多遥感应用中预处理阶段的关键和不可缺少的技术。受HSI的空间和光谱特性的启发传统的HSI去噪方法利用具有先验的优化方案例如低秩[3]全变差[4]非局部相似性[5]虽然这些方法已经取得了可观的性能但它们通常取决于手工先验和真实世界噪声模型之间的相似程度。近年来卷积神经网络CNN[7]为HSI去噪提供了新的思路表现出显着的性能进步。Maffei等人。[8]提出了一种基于CNN的HSI去噪模型将噪声水平图作为输入来训练网络。Wang等人。[9]提出了一种基于联合Octave和注意力机制的卷积网络用于HSI去噪。Pan等人。[10]提出了一种渐进的多尺度信息聚合网络以消除HSI中的噪声。这些基于CNN的方法使用卷积核进行局部特征建模。最近随着Vision TransformerViT的出现基于Transformer的方法在各种计算机视觉任务中取得了重大成功。现有的基于Transformer的图像去噪方法通过学习全局上下文信息取得了很大的成功。然而如果局部特征被有效地考虑和利用HSI去噪性能可能会进一步提高。因此通过结合CNN和Transformers来考虑局部和全局信息以提高去噪性能是很重要的。由于以下两个挑战为HSI去噪构建有效的Transformer和CNN混合模型通常是不平凡的1局部和全局特征建模的最佳混合架构仍然是一个悬而未决的问题。卷积核捕捉局部特征这意味着失去了长距离的信息交互。卷积和注意力的结合可以提供一个可行的解决方案。2)Transformer中前馈网络的单尺度特征聚合受到限制。一些方法使用深度卷积来改善FFN中的局部特征聚合。然而由于隐藏层中的信道数量较多单尺度令牌聚合很难利用丰富的信道表示。为了解决上述两个挑战我们提出了一种用于HSI去噪的混合卷积和注意力网络HCANet它同时利用全局上下文信息和局部特征如图1所示。具体来说为了增强全局和局部特征的建模我们设计了一个卷积和注意力融合模块CAFM旨在捕获长程依赖性和邻域光谱相关性。此外为了提高FFN中的多尺度信息聚合我们设计了一个多尺度前馈网络MSFN通过提取不同尺度的特征来提高去噪性能。在MSFN中使用了三个具有不同步长的并行扩张卷积。通过在两个真实世界的数据集上进行实验我们验证了我们提出的HCANet是上级优于其他国家的最先进的竞争对手。
这封信的贡献可以总结如下 1.探索了用于HSI去噪的全局和局部特征建模的有前途但具有挑战性的问题。据我们所知这是第一个将联合收割机卷积和注意力机制结合起来用于HSI去噪任务的工作。 2.提出了多尺度前馈网络在不同尺度上无缝提取特征有效抑制多尺度噪声。 3.在两个基准数据集上进行了大量实验验证了HCANet的合理性和有效性。
结论
我们提出了HCANet一种新的网络HSI去噪。特别是我们提出了卷积和注意力融合模块CAFM融合全局和局部特征。此外我们提出了多尺度前馈网络MSFN从多个尺度提取特征提高去噪性能。在具有挑战性的HSI数据集上的实验结果表明与现有的HSI去噪方法相比我们提出的模型是有效的。我们的模型实现了显着的去噪性能的定量指标和重建图像的视觉质量。
二、HCANet全文代码
import sys
import torch
import torch.nn as nn
import torch.nn.functional as F
from pdb import set_trace as stx
import numbersfrom einops import rearrange
import os
sys.path.append(os.getcwd())# m_seed 1
# # 设置seed
# torch.manual_seed(m_seed)
# torch.cuda.manual_seed_all(m_seed)def to_3d(x):return rearrange(x, b c h w - b (h w) c)def to_4d(x,h,w):return rearrange(x, b (h w) c - b c h w,hh,ww)class BiasFree_LayerNorm(nn.Module):def __init__(self, normalized_shape):super(BiasFree_LayerNorm, self).__init__()if isinstance(normalized_shape, numbers.Integral):normalized_shape (normalized_shape,)normalized_shape torch.Size(normalized_shape)assert len(normalized_shape) 1self.weight nn.Parameter(torch.ones(normalized_shape))self.normalized_shape normalized_shapedef forward(self, x):sigma x.var(-1, keepdimTrue, unbiasedFalse)return x / torch.sqrt(sigma1e-5) * self.weightclass WithBias_LayerNorm(nn.Module):def __init__(self, normalized_shape):super(WithBias_LayerNorm, self).__init__()if isinstance(normalized_shape, numbers.Integral):normalized_shape (normalized_shape,)normalized_shape torch.Size(normalized_shape)assert len(normalized_shape) 1self.weight nn.Parameter(torch.ones(normalized_shape))self.bias nn.Parameter(torch.zeros(normalized_shape))self.normalized_shape normalized_shapedef forward(self, x):mu x.mean(-1, keepdimTrue)sigma x.var(-1, keepdimTrue, unbiasedFalse)return (x - mu) / torch.sqrt(sigma1e-5) * self.weight self.biasclass LayerNorm(nn.Module):def __init__(self, dim, LayerNorm_type):super(LayerNorm, self).__init__()if LayerNorm_type BiasFree:self.body BiasFree_LayerNorm(dim)else:self.body WithBias_LayerNorm(dim)def forward(self, x):h, w x.shape[-2:]return to_4d(self.body(to_3d(x)), h, w)##########################################################################
## Multi-Scale Feed-Forward Network (MSFN)
class FeedForward(nn.Module):def __init__(self, dim, ffn_expansion_factor, bias):super(FeedForward, self).__init__()hidden_features int(dim*ffn_expansion_factor)self.project_in nn.Conv3d(dim, hidden_features*3, kernel_size(1,1,1), biasbias)self.dwconv1 nn.Conv3d(hidden_features, hidden_features, kernel_size(3,3,3), stride1, dilation1, padding1, groupshidden_features, biasbias)# self.dwconv2 nn.Conv3d(hidden_features, hidden_features, kernel_size(3,3,3), stride1, dilation2, padding2, groupshidden_features, biasbias)# self.dwconv3 nn.Conv3d(hidden_features, hidden_features, kernel_size(3,3,3), stride1, dilation3, padding3, groupshidden_features, biasbias)self.dwconv2 nn.Conv2d(hidden_features, hidden_features, kernel_size(3,3), stride1, dilation2, padding2, groupshidden_features, biasbias)self.dwconv3 nn.Conv2d(hidden_features, hidden_features, kernel_size(3,3), stride1, dilation3, padding3, groupshidden_features, biasbias)self.project_out nn.Conv3d(hidden_features, dim, kernel_size(1,1,1), biasbias)def forward(self, x):x x.unsqueeze(2)x self.project_in(x)x1,x2,x3 x.chunk(3, dim1)x1 self.dwconv1(x1).squeeze(2)x2 self.dwconv2(x2.squeeze(2))x3 self.dwconv3(x3.squeeze(2))# x1 self.dwconv1(x1)# x2 self.dwconv2(x2)# x3 self.dwconv3(x3)x F.gelu(x1)*x2*x3x x.unsqueeze(2)x self.project_out(x)x x.squeeze(2) return x##########################################################################
## Convolution and Attention Fusion Module (CAFM)
class Attention(nn.Module):def __init__(self, dim, num_heads, bias):super(Attention, self).__init__()self.num_heads num_headsself.temperature nn.Parameter(torch.ones(num_heads, 1, 1))self.qkv nn.Conv3d(dim, dim*3, kernel_size(1,1,1), biasbias)self.qkv_dwconv nn.Conv3d(dim*3, dim*3, kernel_size(3,3,3), stride1, padding1, groupsdim*3, biasbias)self.project_out nn.Conv3d(dim, dim, kernel_size(1,1,1), biasbias)self.fc nn.Conv3d(3*self.num_heads, 9, kernel_size(1,1,1), biasTrue)self.dep_conv nn.Conv3d(9*dim//self.num_heads, dim, kernel_size(3,3,3), biasTrue, groupsdim//self.num_heads, padding1)def forward(self, x):b,c,h,w x.shapex x.unsqueeze(2)qkv self.qkv_dwconv(self.qkv(x))qkv qkv.squeeze(2)f_conv qkv.permute(0,2,3,1) f_all qkv.reshape(f_conv.shape[0], h*w, 3*self.num_heads, -1).permute(0, 2, 1, 3) f_all self.fc(f_all.unsqueeze(2))f_all f_all.squeeze(2)#local convf_conv f_all.permute(0, 3, 1, 2).reshape(x.shape[0], 9*x.shape[1]//self.num_heads, h, w)f_conv f_conv.unsqueeze(2)out_conv self.dep_conv(f_conv) # B, C, H, Wout_conv out_conv.squeeze(2)# global SAq,k,v qkv.chunk(3, dim1) q rearrange(q, b (head c) h w - b head c (h w), headself.num_heads)k rearrange(k, b (head c) h w - b head c (h w), headself.num_heads)v rearrange(v, b (head c) h w - b head c (h w), headself.num_heads)q torch.nn.functional.normalize(q, dim-1)k torch.nn.functional.normalize(k, dim-1)attn (q k.transpose(-2, -1)) * self.temperatureattn attn.softmax(dim-1)out (attn v)out rearrange(out, b head c (h w) - b (head c) h w, headself.num_heads, hh, ww)out out.unsqueeze(2)out self.project_out(out)out out.squeeze(2)output out out_convreturn output##########################################################################
## CAMixing Block
class TransformerBlock(nn.Module):def __init__(self, dim, num_heads, ffn_expansion_factor, bias, LayerNorm_type):super(TransformerBlock, self).__init__()self.norm1 LayerNorm(dim, LayerNorm_type)self.attn Attention(dim, num_heads, bias)self.norm2 LayerNorm(dim, LayerNorm_type)self.ffn FeedForward(dim, ffn_expansion_factor, bias)def forward(self, x):x x self.attn(self.norm1(x))x x self.ffn(self.norm2(x))return xclass OverlapPatchEmbed(nn.Module):def __init__(self, in_c31, embed_dim48, biasFalse):super(OverlapPatchEmbed, self).__init__()self.proj nn.Conv3d(in_c, embed_dim, kernel_size(3,3,3), stride1, padding1, biasbias)def forward(self, x):x x.unsqueeze(2)x self.proj(x)x x.squeeze(2)return xclass Downsample(nn.Module):def __init__(self, n_feat):super(Downsample, self).__init__()self.body nn.Sequential(nn.Conv2d(n_feat, n_feat//2, kernel_size3, stride1, padding1, biasFalse),nn.PixelUnshuffle(2))def forward(self, x):# x x.unsqueeze(2)x self.body(x)# x x.squeeze(2)return xclass Upsample(nn.Module):def __init__(self, n_feat):super(Upsample, self).__init__()self.body nn.Sequential(nn.Conv2d(n_feat, n_feat*2, kernel_size3, stride1, padding1, biasFalse),nn.PixelShuffle(2))def forward(self, x):# x x.unsqueeze(2)x self.body(x)# x x.squeeze(2)return x##########################################################################
##---------- HCANet -----------------------
class HCANet(nn.Module):def __init__(self, inp_channels31, out_channels31, dim 48,num_blocks [2,3,3,4], num_refinement_blocks 1,heads [1,2,4,8],ffn_expansion_factor 2.66,bias False,LayerNorm_type WithBias,):super(HCANet, self).__init__()self.patch_embed OverlapPatchEmbed(inp_channels, dim)self.encoder_level1 nn.Sequential(*[TransformerBlock(dimdim, num_headsheads[0], ffn_expansion_factorffn_expansion_factor, biasbias, LayerNorm_typeLayerNorm_type) for i in range(num_blocks[0])])self.down1_2 Downsample(dim) self.encoder_level2 nn.Sequential(*[TransformerBlock(dimint(dim*2**1), num_headsheads[1], ffn_expansion_factorffn_expansion_factor, biasbias, LayerNorm_typeLayerNorm_type) for i in range(num_blocks[1])])self.down2_3 Downsample(int(dim*2**1)) self.encoder_level3 nn.Sequential(*[TransformerBlock(dimint(dim*2**2), num_headsheads[2], ffn_expansion_factorffn_expansion_factor, biasbias, LayerNorm_typeLayerNorm_type) for i in range(num_blocks[2])])self.up3_2 Upsample(int(dim*2**2)) self.reduce_chan_level2 nn.Conv3d(int(dim*2**2), int(dim*2**1), kernel_size(1,1,1), biasbias)self.decoder_level2 nn.Sequential(*[TransformerBlock(dimint(dim*2**1), num_headsheads[1], ffn_expansion_factorffn_expansion_factor, biasbias, LayerNorm_typeLayerNorm_type) for i in range(num_blocks[1])])self.up2_1 Upsample(int(dim*2**1)) self.decoder_level1 nn.Sequential(*[TransformerBlock(dimint(dim*2**1), num_headsheads[0], ffn_expansion_factorffn_expansion_factor, biasbias, LayerNorm_typeLayerNorm_type) for i in range(num_blocks[0])])self.refinement nn.Sequential(*[TransformerBlock(dimint(dim*2**1), num_headsheads[0], ffn_expansion_factorffn_expansion_factor, biasbias, LayerNorm_typeLayerNorm_type) for i in range(num_refinement_blocks)])self.output nn.Conv3d(int(dim*2**1), out_channels, kernel_size(3,3,3), stride1, padding1, biasbias)def forward(self, inp_img):inp_enc_level1 self.patch_embed(inp_img)out_enc_level1 self.encoder_level1(inp_enc_level1)inp_enc_level2 self.down1_2(out_enc_level1)out_enc_level2 self.encoder_level2(inp_enc_level2)inp_enc_level3 self.down2_3(out_enc_level2)out_enc_level3 self.encoder_level3(inp_enc_level3)out_dec_level3 out_enc_level3inp_dec_level2 self.up3_2(out_dec_level3)inp_dec_level2 torch.cat([inp_dec_level2, out_enc_level2], 1)inp_dec_level2 self.reduce_chan_level2(inp_dec_level2.unsqueeze(2))inp_dec_level2 inp_dec_level2.squeeze(2)out_dec_level2 self.decoder_level2(inp_dec_level2)inp_dec_level1 self.up2_1(out_dec_level2)inp_dec_level1 torch.cat([inp_dec_level1, out_enc_level1], 1)out_dec_level1 self.decoder_level1(inp_dec_level1)out_dec_level1 self.refinement(out_dec_level1)out_dec_level1 self.output(out_dec_level1.unsqueeze(2)).squeeze(2) inp_imgreturn out_dec_level1if __name__ __main__:model HCANet()# print(model)# summary(model, (1,31,128,128))inputs torch.ones([2,31,128,128]) #[b,c,h,w]outputs model(inputs)print(outputs.size())
三、 改进教程
2.1 修改YAML文件
详细的改进教程以及源码戳这戳这戳这B站AI学术叫叫兽 源码在相簿的链接中动态中也有链接感谢支持祝科研遥遥领先
2.2 新建HCANet.py
详细的改进教程以及源码戳这戳这戳这B站AI学术叫叫兽er 源码在相簿的链接中动态中也有链接感谢支持祝科研遥遥领先
2.3 修改tasks.py
详细的改进教程以及源码戳这戳这戳这B站AI学术叫叫兽er 源码在相簿的链接中动态中也有链接感谢支持祝科研遥遥领先
三、验证是否成功即可
执行命令
python train.py改完收工 关注B站AI学术叫叫兽 从此走上科研快速路 遥遥领先同行
详细的改进教程以及源码戳这戳这戳这B站AI学术叫叫兽er 源码在相簿的链接中动态中也有链接感谢支持祝科研遥遥领先 文章转载自: http://www.morning.lkjzz.cn.gov.cn.lkjzz.cn http://www.morning.bgpch.cn.gov.cn.bgpch.cn http://www.morning.dsgdt.cn.gov.cn.dsgdt.cn http://www.morning.sfdky.cn.gov.cn.sfdky.cn http://www.morning.rmltt.cn.gov.cn.rmltt.cn http://www.morning.ljsxg.cn.gov.cn.ljsxg.cn http://www.morning.mxtjl.cn.gov.cn.mxtjl.cn http://www.morning.clpfd.cn.gov.cn.clpfd.cn http://www.morning.jljiangyan.com.gov.cn.jljiangyan.com http://www.morning.bnpn.cn.gov.cn.bnpn.cn http://www.morning.wmnpm.cn.gov.cn.wmnpm.cn http://www.morning.fsqbx.cn.gov.cn.fsqbx.cn http://www.morning.ccdyc.cn.gov.cn.ccdyc.cn http://www.morning.rwzkp.cn.gov.cn.rwzkp.cn http://www.morning.cnqff.cn.gov.cn.cnqff.cn http://www.morning.wyctq.cn.gov.cn.wyctq.cn http://www.morning.znpyw.cn.gov.cn.znpyw.cn http://www.morning.tpxgm.cn.gov.cn.tpxgm.cn http://www.morning.jgmdr.cn.gov.cn.jgmdr.cn http://www.morning.lrdzb.cn.gov.cn.lrdzb.cn http://www.morning.rrcrs.cn.gov.cn.rrcrs.cn http://www.morning.pfnrj.cn.gov.cn.pfnrj.cn http://www.morning.dbqcw.com.gov.cn.dbqcw.com http://www.morning.pqypt.cn.gov.cn.pqypt.cn http://www.morning.kpzbf.cn.gov.cn.kpzbf.cn http://www.morning.bmmhs.cn.gov.cn.bmmhs.cn http://www.morning.ccffs.cn.gov.cn.ccffs.cn http://www.morning.lswgs.cn.gov.cn.lswgs.cn http://www.morning.kczkq.cn.gov.cn.kczkq.cn http://www.morning.glncb.cn.gov.cn.glncb.cn http://www.morning.ubpsa.cn.gov.cn.ubpsa.cn http://www.morning.dxrbp.cn.gov.cn.dxrbp.cn http://www.morning.kmcby.cn.gov.cn.kmcby.cn http://www.morning.bnlsd.cn.gov.cn.bnlsd.cn http://www.morning.krdb.cn.gov.cn.krdb.cn http://www.morning.2d1bl5.cn.gov.cn.2d1bl5.cn http://www.morning.nlwrg.cn.gov.cn.nlwrg.cn http://www.morning.mhcys.cn.gov.cn.mhcys.cn http://www.morning.gwwky.cn.gov.cn.gwwky.cn http://www.morning.cqyhdy.cn.gov.cn.cqyhdy.cn http://www.morning.cbtn.cn.gov.cn.cbtn.cn http://www.morning.gbfck.cn.gov.cn.gbfck.cn http://www.morning.cpzkq.cn.gov.cn.cpzkq.cn http://www.morning.rdlfk.cn.gov.cn.rdlfk.cn http://www.morning.xctdn.cn.gov.cn.xctdn.cn http://www.morning.rkmsm.cn.gov.cn.rkmsm.cn http://www.morning.ttnfc.cn.gov.cn.ttnfc.cn http://www.morning.nqlnd.cn.gov.cn.nqlnd.cn http://www.morning.hdlhh.cn.gov.cn.hdlhh.cn http://www.morning.mfbcs.cn.gov.cn.mfbcs.cn http://www.morning.mjbkp.cn.gov.cn.mjbkp.cn http://www.morning.gqwbl.cn.gov.cn.gqwbl.cn http://www.morning.dfwkn.cn.gov.cn.dfwkn.cn http://www.morning.rcjwl.cn.gov.cn.rcjwl.cn http://www.morning.yszrk.cn.gov.cn.yszrk.cn http://www.morning.klwxh.cn.gov.cn.klwxh.cn http://www.morning.mzrqj.cn.gov.cn.mzrqj.cn http://www.morning.gmyhq.cn.gov.cn.gmyhq.cn http://www.morning.prgdy.cn.gov.cn.prgdy.cn http://www.morning.kwqt.cn.gov.cn.kwqt.cn http://www.morning.dtpqw.cn.gov.cn.dtpqw.cn http://www.morning.tnyanzou.com.gov.cn.tnyanzou.com http://www.morning.rxnr.cn.gov.cn.rxnr.cn http://www.morning.prgnp.cn.gov.cn.prgnp.cn http://www.morning.fhsgw.cn.gov.cn.fhsgw.cn http://www.morning.rmppf.cn.gov.cn.rmppf.cn http://www.morning.nbgfz.cn.gov.cn.nbgfz.cn http://www.morning.wwgpy.cn.gov.cn.wwgpy.cn http://www.morning.yrjfb.cn.gov.cn.yrjfb.cn http://www.morning.wsrcy.cn.gov.cn.wsrcy.cn http://www.morning.yxyyp.cn.gov.cn.yxyyp.cn http://www.morning.tgpgx.cn.gov.cn.tgpgx.cn http://www.morning.ytmx.cn.gov.cn.ytmx.cn http://www.morning.yrpg.cn.gov.cn.yrpg.cn http://www.morning.krhkn.cn.gov.cn.krhkn.cn http://www.morning.yltnl.cn.gov.cn.yltnl.cn http://www.morning.psqs.cn.gov.cn.psqs.cn http://www.morning.xqgh.cn.gov.cn.xqgh.cn http://www.morning.yuanshenglan.com.gov.cn.yuanshenglan.com http://www.morning.nsmyj.cn.gov.cn.nsmyj.cn