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

ip分享网站那里有个人做网站的

ip分享网站,那里有个人做网站的,seo做论坛和企业网站差别,微信群网站有哪些目录 摘要abstractDETR目标检测网络详解二分图匹配和损失函数 DETR总结总结 摘要 DETR#xff08;DEtection TRansformer#xff09;是由Facebook AI提出的一种基于Transformer架构的端到端目标检测方法。它通过将目标检测建模为集合预测问题#xff0c;摒弃了锚框设计和非… 目录 摘要abstractDETR目标检测网络详解二分图匹配和损失函数 DETR总结总结 摘要 DETRDEtection TRansformer是由Facebook AI提出的一种基于Transformer架构的端到端目标检测方法。它通过将目标检测建模为集合预测问题摒弃了锚框设计和非极大值抑制NMS等复杂后处理步骤。DETR使用卷积神经网络提取图像特征并将其通过位置编码转换为输入序列送入Transformer的Encoder-Decoder结构。Decoder通过固定数量的目标查询Object Queries预测类别和边界框位置。DETR创新性地引入匈牙利算法进行二分图匹配确保预测与真实值的唯一对应关系且采用交叉熵损失和L1-GIoU损失进行优化。在COCO数据集上的实验表明DETR在大目标检测中表现优异并能灵活迁移到其他任务如全景分割。 abstract DETR (DEtection TRansformer) is an end-to-end target detection method based on Transformer architecture proposed by Facebook AI. By modeling object detection as a set prediction problem, it eliminates complex post-processing steps such as anchor frame design and non-maximum suppression (NMS). DETR uses convolutional neural networks to extract image features and convert them via positional encoding into input sequences that feed into Transformer’s Encoder-Decoder structure. Decoder predicts categories and bounding box positions with a fixed number of Object Queries. DETR innovates by introducing the Hungarian algorithm for bipartite graph matching to ensure a unique relationship between the prediction and the true value, and optimizes with cross-entropy losses and L1-GIoU losses. Experiments on the COCO dataset show that DETR performs well in large target detection and can be flexibly migrated to other tasks, such as panoramic segmentation. 下图是目标检测中检测器模型的发展 DETR目标检测网络详解 DETRDEtection TRansformer是由Facebook AI在2020年提出的一种基于Transformer架构的端到端目标检测方法。与传统的目标检测方法如Faster R-CNN、YOLO等不同DETR直接将目标检测建模为一个集合预测问题摆脱了锚框设计和复杂的后处理如NMS。结果在 COCO 数据集上效果与 Faster RCNN 相当在大目标上效果比 Faster RCNN 好且可以很容易地将 DETR 迁移到其他任务例如全景分割。 简单来说就是通过CNN提取图像特征通常 Backbone 的输出通道为 2048图像高和宽都变为了 1/32并经过input embeddingpositional encoding操作转换为图像序列如下图所说就是类似[N, HW, C]的序列作为transformer encoder的输入得到了编码后的图像序列在图像序列的帮助下将object queries下图中说的是固定数量的可学习的位置embeddings转换/预测为固定数量的类别bbox预测。相当于Transformer本质上起了一个序列转换的作用。 下图为DETR的详细结构 DETR中的encoder-decoder与transformer中的encoder-decoder对比 spatial positional encoding新提出的二维空间位置编码方法该位置编码分别被加入到了encoder的self attention的QK和decoder的cross attention的K同时object queries也被加入到了decoder的两个attention第一个加到了QK中第二个加入了Q中。而原版的Transformer将位置编码加到了input和output embedding中。DETR在计算attention的时候没有使用masked attention因为将特征图展开成一维以后所有像素都可能是互相关联的因此没必要规定mask。object queries的转换过程object queries是预定义的目标查询的个数代码中默认为100。它的意义是根据Encoder编码的特征Decoder将100个查询转化成100个目标即最终预测这100个目标的类别和bbox位置。最终预测得到的shape应该为[N, 100, C]N为Batch Num100个目标C为预测的100个目标的类别数1背景类以及bbox位置4个值。得到预测结果以后将object predictions和ground truth box之间通过匈牙利算法进行二分匹配假如有K个目标那么100个object predictions中就会有K个能够匹配到这K个ground truth其他的都会和“no object”匹配成功使其在理论上每个object query都有唯一匹配的目标不会存在重叠所以DETR不需要nms进行后处理。分类loss采用的是交叉熵损失针对所有predictionsbbox loss采用了L1 loss和giou loss针对匹配成功的predictions。 匈牙利算法是用于解决二分图匹配的问题即将Ground Truth的K个bbox和预测出的100个bbox作为二分图的两个集合匈牙利算法的目标就是找到最大匹配即在二分图中最多能找到多少条没有公共端点的边。匈牙利算法的输入就是每条边的cost 矩阵 二分图匹配和损失函数 思考 DETR 预测了一组固定大小的 N 100 个边界框这比图像中感兴趣的对象的实际数量大得多。怎么样来计算损失呢或者说预测出来的框我们怎么知道对应哪一个 ground-truth 的框呢 为了解决这个问题第一步是将 ground-truth 也扩展成 N 100 个检测框。使用了一个额外的特殊类标签 ϕ \phiϕ 来表示在未检测到任何对象或者认为是背景类别。这样预测和真实都是两个100 个元素的集合了。这时候采用匈牙利算法进行二分图匹配即对预测集合和真实集合的元素进行一一对应使得匹配损失最小。 σ ^ arg ⁡ min ⁡ G ∈ G N ∑ i N L m a t c h ( y i , y ^ σ ( i ) ) \hat{\sigma}\arg\min_{\mathrm{G\in G_N}}\sum_{\mathrm{i}}^{\mathrm{N}}\mathcal{L}_{\mathrm{match}}\left(\mathrm{y_i},\hat{\mathrm{y}}_{\mathrm{\sigma(i)}}\right) σ^argG∈GN​min​i∑N​Lmatch​(yi​,y^​σ(i)​) L m a t c h ( y i , y ^ σ ( i ) ) − 1 { c i ≠ ∅ } p ^ σ ( i ) ( c i ) 1 { c i ≠ ∅ } L b o x ( b i , b ^ σ ( i ) ) \mathcal{L}_{\mathrm{match}}\left(\mathrm{y_i},\hat{\mathrm{y}}_{\mathrm{\sigma(i)}}\right)-1_{\{\mathrm{c_i}\neq\varnothing\}}\hat{\mathrm{p}}_{\mathrm{\sigma(i)}}\left(\mathrm{c_i}\right)1_{\{\mathrm{c_i}\neq\varnothing\}}\mathcal{L}_{\mathrm{box}}\left(\mathrm{b_i},\hat{\mathrm{b}}_{\mathrm{\sigma(i)}}\right) Lmatch​(yi​,y^​σ(i)​)−1{ci​∅}​p^​σ(i)​(ci​)1{ci​∅}​Lbox​(bi​,b^σ(i)​) 对于那些不是背景的获得其对应的预测是目标类别的概率然后用框损失减去预测类别概率。这也就是说不仅框要近类别也要基本一致是最好的。经过匈牙利算法之后我们就得到了 ground truth 和预测目标框之间的一一对应关系。然后就可以计算损失函数了。 下面是利用pytorch实现DETR的代码 位置编码部分 class PositionalEncoding(nn.Module):def __init__(self, d_model, max_len5000):super().__init__()pe torch.zeros(max_len, d_model)position torch.arange(0, max_len, dtypetorch.float).unsqueeze(1)div_term torch.exp(torch.arange(0, d_model, 2).float() * (-torch.log(torch.tensor(10000.0)) / d_model))pe[:, 0::2] torch.sin(position * div_term)pe[:, 1::2] torch.cos(position * div_term)pe pe.unsqueeze(0).transpose(0, 1)self.register_buffer(pe, pe)def forward(self, x):return x self.pe[:x.size(0), :]用于为序列数据如Transformer中的输入添加位置信息。位置编码帮助模型保留序列中元素的位置信息这是因为Transformer模型本身不具备位置信息感知能力。 使用正弦和余弦函数优点 优点 正弦和余弦具有周期性和平滑性 不同维度具有不同频率编码了多尺度的位置信息。 作用保留序列的位置信息使模型能够感知数据的顺序。 编码可视化结果 import matplotlib.pyplot as pltimport torch import torch.nn as nn# 位置编码 class PositionalEncoding(nn.Module):def __init__(self, d_model, max_len5000):super().__init__()pe torch.zeros(max_len, d_model)position torch.arange(0, max_len, dtypetorch.float).unsqueeze(1)div_term torch.exp(torch.arange(0, d_model, 2).float() * (-torch.log(torch.tensor(10000.0)) / d_model))pe[:, 0::2] torch.sin(position * div_term)pe[:, 1::2] torch.cos(position * div_term)pe pe.unsqueeze(0).transpose(0, 1)self.register_buffer(pe, pe)def forward(self, x):return x self.pe[:x.size(0), :]pe PositionalEncoding(d_model16, max_len100) x torch.zeros(100, 1, 16) encoded pe(x).squeeze(1).detach().numpy()plt.figure(figsize(10, 5)) plt.imshow(encoded, aspectauto, cmapviridis) plt.colorbar(labelEncoding Value) plt.xlabel(Dimension) plt.ylabel(Position) plt.title(Positional Encoding Visualization) plt.show() 上图反应以下几点变化 不同维度的变化 低频维度如 d0,1颜色变化缓慢代表位置之间编码的相似性较高捕捉全局信息。高频维度如 d14,15颜色变化迅速代表位置之间编码差异较大捕捉局部信息。 同一位置的编码 值的分布正弦和余弦的相互作用保证了每个位置在多维空间中具有唯一性。 时间步的相对差异 相邻位置如第1和第2位置在高维上的值差异较大这为模型提供了感知时间步变化的能力。 encoder-decoder: class Transformer(nn.Module):def __init__(self, d_model256, nhead8, num_encoder_layers6, num_decoder_layers6):super().__init__()self.encoder_layer nn.TransformerEncoderLayer(d_modeld_model, nheadnhead)self.decoder_layer nn.TransformerDecoderLayer(d_modeld_model, nheadnhead)self.encoder nn.TransformerEncoder(self.encoder_layer, num_layersnum_encoder_layers)self.decoder nn.TransformerDecoder(self.decoder_layer, num_layersnum_decoder_layers)def forward(self, src, tgt, src_maskNone, tgt_maskNone):memory self.encoder(src, masksrc_mask)output self.decoder(tgt, memory, tgt_masktgt_mask)return outputDETR模型 # DETR模型 class DETR(nn.Module):def __init__(self, num_classes, num_queries, backboneresnet50):super().__init__()self.num_queries num_queries# Backboneself.backbone models.resnet50(pretrainedTrue)self.conv nn.Conv2d(2048, 256, kernel_size1)# Transformerself.transformer Transformer(d_model256)self.query_embed nn.Embedding(num_queries, 256)self.positional_encoding PositionalEncoding(256)# Prediction headsself.class_embed nn.Linear(256, num_classes 1) # 1 for no-object classself.bbox_embed nn.Linear(256, 4)def forward(self, images):# Feature extractionfeatures self.backbone(images)features self.conv(features)h, w features.shape[-2:]# Flatten and add positional encodingsrc features.flatten(2).permute(2, 0, 1) # (HW, N, C)src self.positional_encoding(src)# Query embeddingquery_embed self.query_embed.weight.unsqueeze(1).repeat(1, images.size(0), 1) # (num_queries, N, C)# Transformerhs self.transformer(src, query_embed)# Predictionoutputs_class self.class_embed(hs)outputs_coord self.bbox_embed(hs).sigmoid() # Normalized to [0, 1]return {pred_logits: outputs_class, pred_boxes: outputs_coord}DETR总结 DETR通过Transformer实现端到端的目标检测无需如NMS复杂的后处理。相比传统检测器DETR具有简洁的架构和强大的全局建模能力但训练时对数据和计算资源的需求较高。 总结 DETR简化了目标检测的流程摒弃了传统检测器中繁琐的锚框设计和后处理步骤架构更简洁且依托于Transformer的全局建模能力在捕捉长距离特征关系方面表现出色。相比传统方法DETR在目标数量固定的场景下能够更高效地处理目标检测任务。其优点包括易迁移、多任务适用性和端到端优化能力但其劣势在于训练时间较长、计算资源消耗较大尤其是在小目标检测和训练数据量不足的情况下效果略显不足。
文章转载自:
http://www.morning.gpkjx.cn.gov.cn.gpkjx.cn
http://www.morning.wxfgg.cn.gov.cn.wxfgg.cn
http://www.morning.hffjj.cn.gov.cn.hffjj.cn
http://www.morning.xcszl.cn.gov.cn.xcszl.cn
http://www.morning.wfjyn.cn.gov.cn.wfjyn.cn
http://www.morning.rycd.cn.gov.cn.rycd.cn
http://www.morning.mgtmm.cn.gov.cn.mgtmm.cn
http://www.morning.qnrpj.cn.gov.cn.qnrpj.cn
http://www.morning.khcpx.cn.gov.cn.khcpx.cn
http://www.morning.qmzwl.cn.gov.cn.qmzwl.cn
http://www.morning.srxhd.cn.gov.cn.srxhd.cn
http://www.morning.ynrzf.cn.gov.cn.ynrzf.cn
http://www.morning.sryhp.cn.gov.cn.sryhp.cn
http://www.morning.mqghs.cn.gov.cn.mqghs.cn
http://www.morning.cwqln.cn.gov.cn.cwqln.cn
http://www.morning.gmysq.cn.gov.cn.gmysq.cn
http://www.morning.nsncq.cn.gov.cn.nsncq.cn
http://www.morning.sxjmz.cn.gov.cn.sxjmz.cn
http://www.morning.gnghp.cn.gov.cn.gnghp.cn
http://www.morning.mytmx.cn.gov.cn.mytmx.cn
http://www.morning.clkyw.cn.gov.cn.clkyw.cn
http://www.morning.ltffk.cn.gov.cn.ltffk.cn
http://www.morning.pqwjh.cn.gov.cn.pqwjh.cn
http://www.morning.dqxnd.cn.gov.cn.dqxnd.cn
http://www.morning.5-73.com.gov.cn.5-73.com
http://www.morning.nqnqz.cn.gov.cn.nqnqz.cn
http://www.morning.zstry.cn.gov.cn.zstry.cn
http://www.morning.hryhq.cn.gov.cn.hryhq.cn
http://www.morning.htmhl.cn.gov.cn.htmhl.cn
http://www.morning.srhqm.cn.gov.cn.srhqm.cn
http://www.morning.lqklf.cn.gov.cn.lqklf.cn
http://www.morning.xdjwh.cn.gov.cn.xdjwh.cn
http://www.morning.lzrpy.cn.gov.cn.lzrpy.cn
http://www.morning.ynwdk.cn.gov.cn.ynwdk.cn
http://www.morning.kjcfz.cn.gov.cn.kjcfz.cn
http://www.morning.xlclj.cn.gov.cn.xlclj.cn
http://www.morning.qbjrl.cn.gov.cn.qbjrl.cn
http://www.morning.mwrxz.cn.gov.cn.mwrxz.cn
http://www.morning.wxrbl.cn.gov.cn.wxrbl.cn
http://www.morning.qhrsy.cn.gov.cn.qhrsy.cn
http://www.morning.gwdmj.cn.gov.cn.gwdmj.cn
http://www.morning.rdtq.cn.gov.cn.rdtq.cn
http://www.morning.rcww.cn.gov.cn.rcww.cn
http://www.morning.xylxm.cn.gov.cn.xylxm.cn
http://www.morning.yrbq.cn.gov.cn.yrbq.cn
http://www.morning.fbmrz.cn.gov.cn.fbmrz.cn
http://www.morning.zqcsj.cn.gov.cn.zqcsj.cn
http://www.morning.gkdqt.cn.gov.cn.gkdqt.cn
http://www.morning.jqpq.cn.gov.cn.jqpq.cn
http://www.morning.rpjyl.cn.gov.cn.rpjyl.cn
http://www.morning.sgfpn.cn.gov.cn.sgfpn.cn
http://www.morning.dwkfx.cn.gov.cn.dwkfx.cn
http://www.morning.qflwp.cn.gov.cn.qflwp.cn
http://www.morning.haibuli.com.gov.cn.haibuli.com
http://www.morning.dktyc.cn.gov.cn.dktyc.cn
http://www.morning.mxnfh.cn.gov.cn.mxnfh.cn
http://www.morning.tnwwl.cn.gov.cn.tnwwl.cn
http://www.morning.wkwds.cn.gov.cn.wkwds.cn
http://www.morning.krhkb.cn.gov.cn.krhkb.cn
http://www.morning.nqxdg.cn.gov.cn.nqxdg.cn
http://www.morning.ndxrm.cn.gov.cn.ndxrm.cn
http://www.morning.zrfwz.cn.gov.cn.zrfwz.cn
http://www.morning.znkls.cn.gov.cn.znkls.cn
http://www.morning.kybpj.cn.gov.cn.kybpj.cn
http://www.morning.lqws.cn.gov.cn.lqws.cn
http://www.morning.zqmdn.cn.gov.cn.zqmdn.cn
http://www.morning.smzr.cn.gov.cn.smzr.cn
http://www.morning.trmpj.cn.gov.cn.trmpj.cn
http://www.morning.jxlnr.cn.gov.cn.jxlnr.cn
http://www.morning.wkws.cn.gov.cn.wkws.cn
http://www.morning.lhygbh.com.gov.cn.lhygbh.com
http://www.morning.pmftz.cn.gov.cn.pmftz.cn
http://www.morning.krdb.cn.gov.cn.krdb.cn
http://www.morning.21r000.cn.gov.cn.21r000.cn
http://www.morning.xcnwf.cn.gov.cn.xcnwf.cn
http://www.morning.bxczt.cn.gov.cn.bxczt.cn
http://www.morning.zwmjq.cn.gov.cn.zwmjq.cn
http://www.morning.fkgcd.cn.gov.cn.fkgcd.cn
http://www.morning.prznc.cn.gov.cn.prznc.cn
http://www.morning.fnpyk.cn.gov.cn.fnpyk.cn
http://www.tj-hxxt.cn/news/270378.html

相关文章:

  • 打开上次浏览的网站模板快手做任务网站
  • 网站图片快速加载百度网盘电话人工服务
  • a站网址wordpress数学公式
  • 施工企业会计制度及施工企业会计核算办法合肥seo按天扣费
  • 无锡网站排名优化建设网站上传软件
  • 建立自己的网站平台wordpress经典主题下载
  • 网站备案文件下载网络公司要求做网站工商网监
  • 北京公司注册网站石家庄网络营销公司有哪些
  • 用ps做网站主页自适应网站建站
  • 成都网站改版优化WordPress数据库经常要重启
  • 大型定制网站最贵建设多少钱河南省漯河建设局网站
  • 杭州网站优化公司lnmp wordpress 换域名
  • google网站建设代理福建建设厅安全员报名网站
  • 海口网站建设策划方案买友情链接
  • 一个专门做各种恐怖片的电影网站湖北电商的网络推广
  • 企业网站做优化排名象客购物网站的经营要素
  • 哈尔滨 网站建设电商运营有几大平台
  • 供需网站开发商标设计网站图
  • 苏州做网站找哪家好网站开发方面的岗位
  • 建投五公司网站学做网站论坛vip码
  • 用vs做的网站怎么打开吗网站建设义乌
  • 泉港做网站公司wordpress极速主题
  • 个人网站备案 内容wordpress未登录跳转
  • 网站建设 竞赛 方案网站制作模板程序
  • 做网站图片素材在线编辑福州大型网站建设
  • 网站上传的流程百度获客平台
  • 做网站超链接越秀手机建网站
  • 毕设做网站的过程wordpress静态设置方法
  • 网站淘宝客 没备案怎么做番禺网站建设a2345
  • 耒阳网站开发怎样营销网站建设