当前位置:网站首页>Acnet: asymmetric convolution for image hypersegmentation (with implementation code)
Acnet: asymmetric convolution for image hypersegmentation (with implementation code)
2022-07-25 07:36:00 【Prodigal private dishes】
https://blog.csdn.net/huohu728/article/details/115448262
class MeanShift(nn.Conv2d):
def __init__(self,
rgb_range=1.0,
rgb_mean=(0.4488, 0.4371, 0.4040),
rgb_std=(1.0, 1.0, 1.0),
sign=-1):
super(MeanShift, self).__init__(3, 3, kernel_size=1)
std = torch.Tensor(rgb_std)
self.weight.data = torch.eye(3).view(3, 3, 1, 1) / std.view(3, 1, 1, 1)
self.bias.data = sign * rgb_range * torch.Tensor(rgb_mean) / std
self.requires_grad = False
class Upsampler(nn.Sequential):
def __init__(self,
scale,
channels,
bn=False,
act=False,
bias=True):
m = []
if (scale & (scale - 1)) == 0:
for _ in range(int(math.log(scale, 2))):
m.append(nn.Conv2d(channels, 4 * channels, 3, 1, 1, bias=bias))
m.append(nn.PixelShuffle(2))
if bn:
m.append(nn.BatchNorm2d(channels))
if act:
m.append(nn.ReLU(inplace=True))
elif scale == 3:
m.append(nn.Conv2d(channels, 9 * channels, 3, 1, 1, bias=bias))
m.append(nn.PixelShuffle(3))
if bn:
m.append(nn.BatchNorm2d(channels))
if act:
m.append(nn.ReLU(inplace=True))
else:
raise NotImplementedError
super().__init__(*m)
class ACBlock(nn.Module):
def __init__(self, in_channels, out_channels):
super(ACBlock, self).__init__()
self.conv1x3 = nn.Conv2d(in_channels, out_channels, (1, 3), 1, (0, 1))
self.conv3x1 = nn.Conv2d(in_channels, out_channels, (3, 1), 1, (1, 0))
self.conv3x3 = nn.Conv2d(in_channels, out_channels, (3, 3), 1, (1, 1))
def forward(self, x):
conv3x1 = self.conv3x1(x)
conv1x3 = self.conv1x3(x)
conv3x3 = self.conv3x3(x)
return conv3x1 + conv1x3 + conv3x3
class ACNet(nn.Module):
def __init__(self,
scale=2,
in_channels=3,
out_channels=3,
num_features=64,
num_blocks=17,
rgb_range=1.0):
super(ACNet, self).__init__()
self.scale = scale
self.num_blocks = num_blocks
self.num_features = num_features
# pre and post process
self.sub_mean = MeanShift(rgb_range=rgb_range, sign=-1)
self.add_mena = MeanShift(rgb_range=rgb_range, sign=1)
# AB module
self.blk1 = ACBlock(in_channels, num_features)
for idx in range(1, num_blocks):
self.__setattr__(f"blk{idx+1}", nn.Sequential(nn.ReLU(inplace=True), ACBlock(num_features, num_features)))
# MEB
self.lff = nn.Sequential(
nn.ReLU(inplace=False),
Upsampler(scale, num_features),
nn.Conv2d(num_features, num_features, 3, 1, 1),
nn.ReLU(inplace=True),
nn.Conv2d(num_features, num_features, 3, 1, 1)
)
self.hff = nn.Sequential(
nn.ReLU(inplace=False),
Upsampler(scale, num_features),
nn.Conv2d(num_features, num_features, 3, 1, 1),
nn.ReLU(inplace=True),
nn.Conv2d(num_features, num_features, 3, 1, 1)
)
# HFFEB
self.fusion = nn.Sequential(
nn.ReLU(inplace=False),
nn.Conv2d(num_features, num_features, 3, 1, 1),
nn.ReLU(inplace=True),
nn.Conv2d(num_features, num_features, 3, 1, 1),
nn.ReLU(inplace=True),
nn.Conv2d(num_features, out_channels, 3, 1, 1),
)
def forward(self, x):
inputs = self.sub_mean(x)
blk1 = self.blk1(inputs)
high = blk1
tmp = blk1
for idx in range(1, self.num_blocks):
tmp = self.__getattr__(f"blk{idx+1}")(tmp)
high = high + tmp
lff = self.lff(blk1)
hff = self.hff(high)
fusion = self.fusion(lff + hff)
output = self.add_mena(fusion)
return output
边栏推荐
- On the peak night of the 8 Oracle ace gathering, what technology hotspots did you talk about?
- Problems in deep learning training and testing: error: the following arguments are required: --dataroot, solution: the configuration method of training files and test files
- What are the types of financial products in 2022? Which is suitable for beginners?
- GBase 8a中关于--skip-networking 问题
- [pytorch] the most common function of view
- RPC通信原理与项目技术选型
- Use cyclegan to train self-made data sets, popular tutorials, and get started quickly
- [cloud native] the ribbon is no longer used at the bottom of openfeign, which started in 2020.0.x
- Lidar construction map (overlay grid construction map)
- Teach you to use cann to convert photos into cartoon style
猜你喜欢

【Unity入门计划】基本概念-预制件 Prefab

Xinku online | cnopendata shareholder information data of A-share listed companies

Problems during nanodet training: modulenotfounderror: no module named 'nanodet' solution
![[paper notes] effective CNN architecture design guided by visualization](/img/aa/aeeac3f970eac7f110987c523602c8.png)
[paper notes] effective CNN architecture design guided by visualization

【Unity入门计划】界面介绍(1)-Scene视图

转行学什么成为了一大部分人的难题,那么为什么很多人学习软件测试呢?

【论文笔记】Progressive Layered Extraction (PLE): A Novel Multi-Task Learning (MTL) Model for Personalized

diagramscene工程难点分析

Analysis of difficulties in diagramscene project
![[dynamic programming] - Knapsack model](/img/0d/c467e70457495f130ec217660cbea7.png)
[dynamic programming] - Knapsack model
随机推荐
Million level element optimization: real-time vector tile service based on PG and PostGIS
Design of workflow system
Polling, interrupt, DMA and channel
J1 common DOS commands (P25)
全新8.6版本SEO快排系统(可源码级搭建)
[paper notes] progressive layered extraction (PLE): a novel multi task learning (MTL) model for personalized
A fast method of data set enhancement for deep learning
Nailing the latest version, how to clear the login phone number history data
Growth path - InfoQ video experience notes [easy to understand]
3. Promise
9 best engineering construction project management systems
【软件测试】包装简历从这几点出发、提升通过率
A domestic open source redis visualization tool that is super easy to use, with a high-value UI, which is really fragrant!!
About --skip networking in gbase 8A
Problems in deep learning training and testing: error: the following arguments are required: --dataroot, solution: the configuration method of training files and test files
RPC communication principle and project technology selection
Huawei wireless device sta black and white list configuration command
Learn no when playing 9 | enterprise knowledge management is so simple because it uses
Day by day, month by month | Shenzhen potential technology released the extreme accelerated version of molecular docking engine uni docking
DJI push code (one code for one use, limited time push)