每日Attention学习6——Context Aggregation Module

模块出处

[link] [code] [IJCAI 22] Boundary-Guided Camouflaged Object Detection


模块名称

Context Aggregation Module (CAM)


模块作用

增大感受野,全局特征提取


模块结构

模块代码
python 复制代码
import torch
import torch.nn as nn
import torch.nn.functional as F


class ConvBNR(nn.Module):
    def __init__(self, inplanes, planes, kernel_size=3, stride=1, dilation=1, bias=False):
        super(ConvBNR, self).__init__()

        self.block = nn.Sequential(
            nn.Conv2d(inplanes, planes, kernel_size, stride=stride, padding=dilation, dilation=dilation, bias=bias),
            nn.BatchNorm2d(planes),
            nn.ReLU(inplace=True)
        )

    def forward(self, x):
        return self.block(x)


class Conv1x1(nn.Module):
    def __init__(self, inplanes, planes):
        super(Conv1x1, self).__init__()
        self.conv = nn.Conv2d(inplanes, planes, 1)
        self.bn = nn.BatchNorm2d(planes)
        self.relu = nn.ReLU(inplace=True)

    def forward(self, x):
        x = self.conv(x)
        x = self.bn(x)
        x = self.relu(x)

        return x
    

class CAM(nn.Module):
    def __init__(self, hchannel, channel):
        super(CAM, self).__init__()
        self.conv1_1 = Conv1x1(hchannel + channel, channel)
        self.conv3_1 = ConvBNR(channel // 4, channel // 4, 3)
        self.dconv5_1 = ConvBNR(channel // 4, channel // 4, 3, dilation=2)
        self.dconv7_1 = ConvBNR(channel // 4, channel // 4, 3, dilation=3)
        self.dconv9_1 = ConvBNR(channel // 4, channel // 4, 3, dilation=4)
        self.conv1_2 = Conv1x1(channel, channel)
        self.conv3_3 = ConvBNR(channel, channel, 3)

    def forward(self, lf, hf):
        if lf.size()[2:] != hf.size()[2:]:
            hf = F.interpolate(hf, size=lf.size()[2:], mode='bilinear', align_corners=False)
        x = torch.cat((lf, hf), dim=1)
        x = self.conv1_1(x)
        xc = torch.chunk(x, 4, dim=1)
        x0 = self.conv3_1(xc[0] + xc[1])
        x1 = self.dconv5_1(xc[1] + x0 + xc[2])
        x2 = self.dconv7_1(xc[2] + x1 + xc[3])
        x3 = self.dconv9_1(xc[3] + x2)
        xx = self.conv1_2(torch.cat((x0, x1, x2, x3), dim=1))
        x = self.conv3_3(x + xx)

        return x

    
if __name__ == '__main__':
    x1 = torch.randn([3, 256, 16, 16])
    x2 = torch.randn([3, 512, 8, 8])
    cam = CAM(hchannel=512, channel=256)
    out = cam(x1, x2)
    print(out.shape)  # 3, 256, 16, 16

原文表述

为了将多层次的融合特征整合到伪装物体预测中,我们设计了一个上下文聚合模块(CAM)来挖掘上下文语义,以增强物体检测,如图5所示。不同于BBSNet中的全局上下文模块不考虑各分支之间的语义关联,CAM考虑到跨尺度交互作用以增强特征表示。

相关推荐
张较瘦_2 小时前
[论文阅读] AI + 软件工程 | GenAI 赋能自适应系统:从技术突破到研究蓝图,一文看懂核心价值与挑战
论文阅读·人工智能·软件工程
张较瘦_3 小时前
[论文阅读] 软件工程 - 供应链 | 从Log4Shell到Go组件漏洞:一篇文看懂开源依赖安全的核心痛点与解决方案
论文阅读·golang·开源
有Li7 小时前
一种交互式可解释人工智能方法,用于改进数字细胞病理学癌症亚型分类中的人机协作|文献速递-文献分享
大数据·论文阅读·人工智能·文献
iiiiii117 小时前
【论文阅读笔记】FOCAL 离线元强化学习,从静态数据中快速适应新任务
论文阅读·人工智能·笔记·学习·机器学习·学习方法·具身智能
川川子溢8 小时前
【论文阅读】SegEarth-OV:面向遥感图像的免训练开放词汇分割
论文阅读
m0_6501082410 小时前
BEVFormer:基于时空 Transformer 的多相机鸟瞰图表征学习
论文阅读·自动驾驶·相机-based 3d感知·bev表征·时空信息融合·端到端感知·bevformer
sca1p311 天前
新南威尔士大学 LiM
论文阅读·人工智能·加密流量分类
m0_650108241 天前
Lift, Splat, Shoot:自动驾驶多视图相机的 BEV 语义表示学习
论文阅读·自动驾驶·数据驱动·lss·纯视觉bev感知·bev 语义分割·可解释的端到端轨迹规划
m0_650108241 天前
Sparse4D v3:端到端 3D 检测与跟踪的技术突破
论文阅读·自动驾驶·sparse4d v3·端到端3d感知框架·去噪思想·端到端跟踪·纯视觉感知
m0_650108242 天前
VADv2:基于概率规划的端到端矢量化自动驾驶
论文阅读·自动驾驶·端到端矢量化·驾驶场景中的不确定性·概率场建模·多模态编码·vadv2