日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【语义分割】OCRNet:Object-Context Representations for Semantic Segmentation

發布時間:2023/12/15 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【语义分割】OCRNet:Object-Context Representations for Semantic Segmentation 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

文章目錄

    • 一、文章出發點
    • 二、方法
    • 三、效果

一、文章出發點

每個像素點的類別(label)應該是它所屬目標(object)的類別。

所以這篇文章對像素的上下文信息建模

建模方法:求每個像素點和每個類別的相關性

二、方法

# prev_output: 19d的粗糙預測結果 # feats:將hrnet輸出的720d的變成512d # context:每個類別圖和每個特征圖的關系(19x512) # object_context:self-attention

1、prev_output:


2、feats獲得

3、context獲得


4、self-attention

import torch import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import ConvModulefrom mmseg.ops import resize from ..builder import HEADS from ..utils import SelfAttentionBlock as _SelfAttentionBlock from .cascade_decode_head import BaseCascadeDecodeHead # from .Attention_layer import HardClassAttention as HCAclass SpatialGatherModule(nn.Module):"""Aggregate the context features according to the initial predictedprobability distribution.Employ the soft-weighted method to aggregate the context."""def __init__(self, scale):super(SpatialGatherModule, self).__init__()self.scale = scaledef forward(self, feats, probs):"""Forward function."""batch_size, num_classes, height, width = probs.size()channels = feats.size(1)probs = probs.view(batch_size, num_classes, -1)feats = feats.view(batch_size, channels, -1)# [batch_size, height*width, num_classes]feats = feats.permute(0, 2, 1)# [batch_size, channels, height*width]probs = F.softmax(self.scale * probs, dim=2)# [batch_size, channels, num_classes]ocr_context = torch.matmul(probs, feats)ocr_context = ocr_context.permute(0, 2, 1).contiguous().unsqueeze(3)return ocr_context class ClassRelationGatherModule(nn.Module):"""Aggregate the context features according to the initial predictedprobability distribution.Employ the soft-weighted method to aggregate the context."""def __init__(self, scale):super(ClassRelationGatherModule, self).__init__()self.scale = scaledef forward(self, feats, probs):"""Forward function."""batch_size, num_classes, height, width = probs.size()channels = feats.size(1)probs_1 = probs.view(batch_size, num_classes, -1)probs_2 = probs.view(batch_size, num_classes, -1)# [batch_size, height*width, num_classes]probs_2 = probs_2.permute(0, 2, 1)# [batch_size, channels, height*width]probs_1 = F.softmax(self.scale * probs_1, dim=2)# [batch_size, channels, num_classes]class_gather = torch.matmul(probs_1, probs_2)class_gather = class_gather.permute(0, 2, 1).contiguous().unsqueeze(3)return class_gatherclass ObjectAttentionBlock(_SelfAttentionBlock):"""Make a OCR used SelfAttentionBlock."""def __init__(self, in_channels, channels, scale, conv_cfg, norm_cfg,act_cfg):if scale > 1:query_downsample = nn.MaxPool2d(kernel_size=scale)else:query_downsample = Nonesuper(ObjectAttentionBlock, self).__init__(key_in_channels=in_channels,query_in_channels=in_channels,channels=channels,out_channels=in_channels,share_key_query=False,query_downsample=query_downsample,key_downsample=None,key_query_num_convs=2,key_query_norm=True,value_out_num_convs=1,value_out_norm=True,matmul_norm=True,with_out=True,conv_cfg=conv_cfg,norm_cfg=norm_cfg,act_cfg=act_cfg)self.bottleneck = ConvModule(in_channels * 2,in_channels,1,conv_cfg=self.conv_cfg,norm_cfg=self.norm_cfg,act_cfg=self.act_cfg)def forward(self, query_feats, key_feats):"""Forward function."""context = super(ObjectAttentionBlock, self).forward(query_feats, key_feats)output = self.bottleneck(torch.cat([context, query_feats], dim=1))if self.query_downsample is not None:output = resize(query_feats)return output@HEADS.register_module() class OCRHead(BaseCascadeDecodeHead):"""Object-Contextual Representations for Semantic Segmentation.This head is the implementation of `OCRNet<https://arxiv.org/abs/1909.11065>`_.Args:ocr_channels (int): The intermediate channels of OCR block.scale (int): The scale of probability map in SpatialGatherModule inDefault: 1."""def __init__(self, ocr_channels, scale=1, **kwargs):super(OCRHead, self).__init__(**kwargs)self.ocr_channels = ocr_channelsself.scale = scaleself.object_context_block = ObjectAttentionBlock(self.channels,self.ocr_channels,self.scale,conv_cfg=self.conv_cfg,norm_cfg=self.norm_cfg,act_cfg=self.act_cfg)self.spatial_gather_module = SpatialGatherModule(self.scale)self.class_relation_gather_module = ClassRelationGatherModule(self.scale)self.bottleneck = ConvModule(self.in_channels,self.channels,3,padding=1,conv_cfg=self.conv_cfg,norm_cfg=self.norm_cfg,act_cfg=self.act_cfg)def forward(self, inputs, prev_output):"""Forward function."""# concat multi-level img featurex = self._transform_inputs(inputs) # (1,720,128,256) hr18, 512x1024feats = self.bottleneck(x) # (1,512,128,256)context = self.spatial_gather_module(feats, prev_output) # (1,512,19,1)object_context = self.object_context_block(feats, context) #(1,512,128,256)output = self.cls_seg(object_context) # (1,19,128,256)return output

三、效果

經過OCR頭后的效果對比如下圖,每個類別的響應比較全面且穩定。


cityscape類別和通道的對應:


總結

以上是生活随笔為你收集整理的【语义分割】OCRNet:Object-Context Representations for Semantic Segmentation的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 亚洲最大成人综合网 | 欧美三级精品 | 亚洲免费在线观看视频 | 91精品免费观看 | 色秀视频网 | 欧美一级片在线看 | 久久少妇av | 香蕉人妻av久久久久天天 | av电影网站在线观看 | 国产又色又爽无遮挡免费动态图 | 在线国产不卡 | 两根大肉大捧一进一出好爽视频 | 国产国拍精品亚洲 | 亚洲欧美一区二区在线观看 | 国产xxxx在线观看 | 亚洲久热 | 久久久久久久久久av | 99热日韩| 91视频免费 | 人人人人爽| 久久国产加勒比精品无码 | 成年人在线观看av | 国产精品久久久午夜夜伦鲁鲁 | 日本少妇一级 | 日韩毛片在线免费观看 | 日韩一卡二卡三卡四卡 | 国产美女av在线 | 一区二区一级片 | 国产4区 | 免费大片av | 蜜臀av性久久久久蜜臀aⅴ四虎 | 午夜写真片福利电影网 | 日本wwwwww| 国产一级特黄aaa大片 | 欧美老女人性生活 | 国产五十路 | 91成人看片| 在线精品国产 | 叼嘿视频91| 后进极品美女白嫩翘臀 | 亚洲福利一区二区三区 | 中文字幕一区二区在线视频 | 日本少妇全体裸体洗澡 | 日本一区二区视频在线观看 | 色伊人影院 | 久久久久国色av免费观看性色 | 欧美乱强伦 | 一级成人毛片 | 美女视频黄频视频大全 | 一级片免费网址 | 亚洲午夜av在线 | 国产口爆吞精一区二区 | www.色午夜 | 国产精品日韩欧美一区二区三区 | 97久久精品视频 | 91成人免费在线观看 | 欧美456 | 日本伊人色| 精品国产乱码久久久久久影片 | 国产伦精品一区二区三区照片 | 国产日韩欧美在线观看 | 欧美一区二区三区视频在线观看 | 污片免费观看 | 色黄大色黄女片免费中国 | 大肉大捧一进一出好爽mba | 天堂av亚洲av国产av电影 | 国产美女无遮挡永久免费 | 人人模人人爽 | 强开乳罩摸双乳吃奶羞羞www | 国产露脸无套对白在线播放 | 7777av| 精品无码国产一区二区三区51安 | 91 久久 | 97超碰国产精品无码蜜芽 | 日韩精品网址 | 欧美bdsm调教视频 | 亚洲wwwwww | 久久久99精品国产一区二区三区 | 看片免费黄在线观看入口 | 日韩欧美福利视频 | 中文字幕一区二区三区人妻电影 | 欧美特级毛片 | 爱爱一区二区三区 | 男人av在线| 白白色2012年最新视频 | 中国黄色三级视频 | 麻豆一区产品精品蜜桃的特点 | 色片在线播放 | 国产一级做a爰片在线看免费 | 日韩中文字幕高清 | 中文字幕日本在线观看 | 黄色小说在线视频 | 久久久男女 | 欧美成人一区在线观看 | 欧美性粗暴 | 中文字幕88页 | 黄片毛片在线观看 | 狠狠撸在线视频 | 少妇精品一区二区三区 |