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

鄂尔多斯市东胜区城市建设局网站购物网站建设项目策划书

鄂尔多斯市东胜区城市建设局网站,购物网站建设项目策划书,用meteor框架做的微博网站,php做学校网站免费下载Detr作为目标检测的算法#xff0c;不同于之前算法的就是注意力机制#xff0c;注意力机制能够直观看出来模型对图像关注的点#xff0c;这个直观到底怎么直观呢#xff0c;我们只听别人说肯定是不行的#xff0c;上手测试才是最好的方式#xff0c;像论文中插图那样的使…Detr作为目标检测的算法不同于之前算法的就是注意力机制注意力机制能够直观看出来模型对图像关注的点这个直观到底怎么直观呢我们只听别人说肯定是不行的上手测试才是最好的方式像论文中插图那样的使用热度图的方式来展现注意力关注的重点才能叫做直观。幸运的是官方hands_on手册中给了模型可视化的方式我也搬过来用一下方便后续查看。如果有其他模型可视化的操作也可以借鉴这些代码。 代码是接着上一篇文章的推理模块来的如果需要运行测试请先运行上面的代码。 1.可视化编解码多头注意力权重encoder-decoder multi-head attention weights 获取权重参数 # use lists to store the outputs via up-values conv_features, enc_attn_weights, dec_attn_weights [], [], []hooks [model.backbone[-2].register_forward_hook(lambda self, input, output: conv_features.append(output)),model.transformer.encoder.layers[-1].self_attn.register_forward_hook(lambda self, input, output: enc_attn_weights.append(output[1])),model.transformer.decoder.layers[-1].multihead_attn.register_forward_hook(lambda self, input, output: dec_attn_weights.append(output[1])), ]# propagate through the model outputs model(img)for hook in hooks:hook.remove()# dont need the list anymore conv_features conv_features[0] enc_attn_weights enc_attn_weights[0] dec_attn_weights dec_attn_weights[0]可视化展示 # get the feature map shape h, w conv_features[0].tensors.shape[-2:]fig, axs plt.subplots(ncolslen(bboxes_scaled), nrows2, figsize(22, 7)) colors COLORS * 100 for idx, ax_i, (xmin, ymin, xmax, ymax) in zip(keep.nonzero(), axs.T, bboxes_scaled):ax ax_i[0]ax.imshow(dec_attn_weights[0, idx].view(h, w))ax.axis(off)ax.set_title(fquery id: {idx.item()})ax ax_i[1]ax.imshow(im)ax.add_patch(plt.Rectangle((xmin, ymin), xmax - xmin, ymax - ymin,fillFalse, colorblue, linewidth3))ax.axis(off)ax.set_title(CLASSES[probas[idx].argmax()]) fig.tight_layout()2.可视化编码自注意力权重encoder self-attention weights 查看编码权重shape # output of the CNN f_map conv_features[0] print(Encoder attention: , enc_attn_weights[0].shape) print(Feature map: , f_map.tensors.shape)# output results # Encoder attention: torch.Size([850, 850]) # Feature map: torch.Size([1, 2048, 25, 34])转换权重矩阵 [H * W, H * W] - [H,W,H,W] # get the HxW shape of the feature maps of the CNN shape f_map.tensors.shape[-2:] # and reshape the self-attention to a more interpretable shape sattn enc_attn_weights[0].reshape(shape shape) print(Reshaped self-attention:, sattn.shape)查看部分点位 # downsampling factor for the CNN, is 32 for DETR and 16 for DETR DC5 fact 32# lets select 4 reference points for visualization idxs [(200, 200), (280, 400), (200, 600), (440, 800),]# here we create the canvas fig plt.figure(constrained_layoutTrue, figsize(25 * 0.7, 8.5 * 0.7)) # and we add one plot per reference point gs fig.add_gridspec(2, 4) axs [fig.add_subplot(gs[0, 0]),fig.add_subplot(gs[1, 0]),fig.add_subplot(gs[0, -1]),fig.add_subplot(gs[1, -1]), ]# for each one of the reference points, lets plot the self-attention # for that point for idx_o, ax in zip(idxs, axs):idx (idx_o[0] // fact, idx_o[1] // fact)ax.imshow(sattn[..., idx[0], idx[1]], cmapcividis, interpolationnearest)ax.axis(off)ax.set_title(fself-attention{idx_o})# and now lets add the central image, with the reference points as red circles fcenter_ax fig.add_subplot(gs[:, 1:-1]) fcenter_ax.imshow(im) for (y, x) in idxs:scale im.height / img.shape[-2]x ((x // fact) 0.5) * facty ((y // fact) 0.5) * factfcenter_ax.add_patch(plt.Circle((x * scale, y * scale), fact // 2, colorr))fcenter_ax.axis(off)
http://www.pierceye.com/news/896604/

相关文章:

  • 柳州网站建设优化推广wordpress 不显示菜单
  • 网站死循环网站备案和域名备案区别
  • 做网站要学会什么语言装修公司网站模板下载
  • 门户网站建设自查报告网站关键词快速排名技术
  • 如何建网站费用多少全国工商企业查询平台
  • 兰州新区建站什么是网络营销取得成功的基础
  • 南昌 网站 公司wordpress迁移后媒体库丢失
  • 做移动网站点击软件cnzz网站建设
  • 高质量网站外链建设大揭秘做网站之前需要准备什么条件
  • 睢宁做网站百度一下做网站
  • 做国外购物网站国家高职示范校建设网站
  • 网站建设福州公司山西省大同市网站建设公司
  • 浙江网站建设推荐wordpress 增加小工具
  • 个人网站是商业的吗北京网站建设设计
  • 手机网站收费怎么停止网站
  • 网站建设 金疙瘩计划杭州小程序制作公司排行榜
  • 德泰诺网站建设软件著作权登记证书
  • 商标设计网页seo外包公司兴田德润官方地址
  • 网站开发人员岗位成功营销案例分享
  • 赤峰做网站的公司湘潭哪里做网站
  • 免费自助建站郑州官网seo费用
  • 称心的常州网站建设wordpress怎么用两个主题
  • 建设银行北京分行网站做视频网站用什么服务器配置
  • 网站备案流程实名认证医疗网站建设资讯
  • 一个做问卷调查的网站好wordpress七比2
  • 西双版纳网站制作公司临沂企业网站建站模板
  • 培训做网站国内适合个人做外贸的网站有哪些
  • 我想卖自己做的鞋子 上哪个网站好中信银行网站怎么做的怎么烂
  • 在线网站建设工程标准godaddy 上传网站
  • 营销型网站方案ppt模板手机建站平台微点