来源:互联网 更新时间:2025-07-17 18:25
本文作者引入了上下文编码模块(Context Encoding Module),在语义分割任务中利用全局上下文信息来提升语义分割的效果。本次复现赛要求是在Cityscapes验证集上miou为78.55%,本次复现的miou为79.42%,该算法已被PaddleSeg收录。
PSPNet通过SPP(Spatial Pyramid polling)模块得到不同尺寸的特征图,然后将不同尺寸的特征图结合扩大感受野;DeepLab利用ASPP(Atrous Spatial Pyramid Pooling)来扩大感受野。但是ENCNet提出了一个问题:“Is capturing contextual information the same as increasing the receptive field size?”(增加感受野等于捕获上下文信息吗?)。作者提出一个想法:利用图片的上下文信息来减少图片中像素种类的搜索空间。比如一张卧室的图片,那么该图片中有床、椅子等物体的可能性就会比汽车、湖面等其他物体的概率大很多。本文提出了Context Encoding Module和Semantic Encoding Loss(SE-loss)来学习上下文信息。
class Encoding(nn.Layer): def __init__(self, channels, num_codes): super().__init__() self.channels, self.num_codes = channels, num_codes std = 1 / ((channels * num_codes) ** 0.5) self.codewords = self.create_parameter( shape=(num_codes, channels), default_initializer=nn.initializer.Uniform(-std, std), ) # 编码 self.scale = self.create_parameter( shape=(num_codes,), default_initializer=nn.initializer.Uniform(-1, 0), ) # 缩放因子 self.channels = channels def scaled_l2(self, x, codewords, scale): num_codes, channels = paddle.shape(codewords) reshaped_scale = scale.reshape([1, 1, num_codes]) expanded_x = paddle.tile(x.unsqueeze(2), [1, 1, num_codes, 1]) reshaped_codewords = codewords.reshape([1, 1, num_codes, channels]) scaled_l2_norm = paddle.multiply(reshaped_scale, (expanded_x - reshaped_codewords).pow(2).sum(axis=3)) return scaled_l2_norm def aggregate(self, assignment_weights, x, codewords): num_codes, channels = paddle.shape(codewords) reshaped_codewords = codewords.reshape([1, 1, num_codes, channels]) expanded_x = paddle.tile(x.unsqueeze(2), [1, 1, num_codes, 1]) encoded_feat = paddle.multiply(assignment_weights.unsqueeze(3), (expanded_x - reshaped_codewords)).sum(axis=1) encoded_feat = paddle.reshape(encoded_feat, [-1, self.num_codes, self.channels]) return encoded_feat def forward(self, x): x_dims = x.ndim assert x_dims == 4, ”The dimension of input tensor must equal 4, but got {}.“.format(x_dims) assert paddle.shape(x)[1] == self.channels, ”Encoding channels error, excepted {} but got {}.“.format(self.channels, paddle.shape(x)[1]) batch_size = paddle.shape(x)[0] x = x.reshape([batch_size, self.channels, -1]).transpose([0, 2, 1]) assignment_weights = F.softmax(self.scaled_l2(x, self.codewords, self.scale), axis=2) encoded_feat = self.aggregate(assignment_weights, x, self.codewords) return encoded_feat登录后复制
1、解压cityscapes数据集;2、训练ENCNet,本论文的复现环境是Tesla V100 * 4,想要完整的复现结果请移步脚本任务;3、验证训练结果,如果想要验证复现的结果,需要下载权重,并放入output/best_model文件夹内(权重超出150MB限制,可以分卷压缩上传)。
In [ ]# step 1: unzip data%cd ~/data/data64550!tar -xf cityscapes.tar%cd ~/登录后复制In [ ]
# step 2: training%cd ~/ENCNet_paddle/!python train.py --config configs/encnet/encnet_cityscapes_1024x512_80k.yml --num_workers 16 --do_eval --use_vdl --log_iter 20 --save_interval 5000登录后复制In [ ]
# step 3: val%cd ~/ENCNet_paddle/!python val.py --config configs/encnet/encnet_cityscapes_1024x512_80k.yml --model_path output/best_model/model.pdparams登录后复制
本次复现的目标是Cityscapes 验证集miou 78.55%,复现的为miou 79.42%。环境:Tesla V100 *4PaddlePaddle==2.2.0
悟空浏览器网页版:免费畅游网络世界的极速入口
豆包AI安装需要哪些运行时库 豆包AI系统依赖项完整清单
2025迷你世界雨薇免费激活码
2025崩坏星穹铁道7月3日兑换码
Perplexity AI比Google好吗 与传统搜索引擎对比
ChatGPT如何生成产品原型 ChatGPT产品设计辅助功能
哔哩哔哩教程哪里找
蚂蚁庄园今日最新答案7.10
光遇6.19大蜡烛在哪里
《怪物乐土》哥布林猎手光暗选择技能加点
小米在全球范围推送澎湃OS 2.2 这几款机型现可升级
iPhone11promax升级iOS 17.2之后怎么样
iPhone15pro怎么拍动态照片?
2025原神7月2日兑换码分享
如何轻松在iPhone上安装DeepSeek
光遇7.8免费魔法是什么
剪映人像虚化怎么使用 剪映人像虚化使用方法
iPhone15 Pro Max屏幕一直亮着是什么原因
Edge浏览器怎么关闭某个进程
qq音乐怎么免费听歌?qq音乐免费听歌教程
手机号码测吉凶
本站所有软件,都由网友上传,如有侵犯你的版权,请发邮件haolingcc@hotmail.com 联系删除。 版权所有 Copyright@2012-2013 haoling.cc