遥感影像语义分割:D-LinkNet精度提升Trick(更新中)

一、数据增强

数据增强部分使用的在线数据增强方式,使用的库是albumentations,训练过程中使用了翻转、旋转、色彩变换、缩放等操作。

import albumentations as albu
def get_training_augmentaion():
    train_transform=[
        albu.OneOf([
            albu.HorizontalFlip(p=0.5),
  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 6
    评论
好的,我们可以在SegNet的Decoder部分引入Dense Feature Linking。具体来说,我们可以在Decoder的每一层的输出上,都接入一个1x1的卷积层来产生额外的特征图。然后,将这些额外的特征图与Encoder对应层的输出进行concatenate操作,得到Dense Feature Linking后的特征图。最后,再通过卷积层进行特征融合并得到最终的分割结果。 以下是参考代码: ```python import torch import torch.nn as nn class SegNet(nn.Module): def __init__(self, in_channels, out_channels): super(SegNet, self).__init__() # Encoder部分 self.encoder = nn.Sequential( nn.Conv2d(in_channels, 64, kernel_size=3, padding=1), nn.BatchNorm2d(64), nn.ReLU(inplace=True), nn.Conv2d(64, 64, kernel_size=3, padding=1), nn.BatchNorm2d(64), nn.ReLU(inplace=True), nn.MaxPool2d(kernel_size=2, stride=2), nn.Conv2d(64, 128, kernel_size=3, padding=1), nn.BatchNorm2d(128), nn.ReLU(inplace=True), nn.Conv2d(128, 128, kernel_size=3, padding=1), nn.BatchNorm2d(128), nn.ReLU(inplace=True), nn.MaxPool2d(kernel_size=2, stride=2), nn.Conv2d(128, 256, kernel_size=3, padding=1), nn.BatchNorm2d(256), nn.ReLU(inplace=True), nn.Conv2d(256, 256, kernel_size=3, padding=1), nn.BatchNorm2d(256), nn.ReLU(inplace=True), nn.Conv2d(256, 256, kernel_size=3, padding=1), nn.BatchNorm2d(256), nn.ReLU(inplace=True), nn.MaxPool2d(kernel_size=2, stride=2), nn.Conv2d(256, 512, kernel_size=3, padding=1), nn.BatchNorm2d(512), nn.ReLU(inplace=True), nn.Conv2d(512, 512, kernel_size=3, padding=1), nn.BatchNorm2d(512), nn.ReLU(inplace=True), nn.Conv2d(512, 512, kernel_size=3, padding=1), nn.BatchNorm2d(512), nn.ReLU(inplace=True), nn.MaxPool2d(kernel_size=2, stride=2), nn.Conv2d(512, 512, kernel_size=3, padding=1), nn.BatchNorm2d(512), nn.ReLU(inplace=True), nn.Conv2d(512, 512, kernel_size=3, padding=1), nn.BatchNorm2d(512), nn.ReLU(inplace=True), nn.Conv2d(512, 512, kernel_size=3, padding=1), nn.BatchNorm2d(512), nn.ReLU(inplace=True), nn.MaxPool2d(kernel_size=2, stride=2), ) # Decoder部分 self.decoder = nn.Sequential( nn.ConvTranspose2d(512, 512, kernel_size=3, stride=2, padding=1, output_padding=1), nn.BatchNorm2d(512), nn.ReLU(inplace=True), nn.ConvTranspose2d(512, 512, kernel_size=3, stride=2, padding=1, output_padding=1), nn.BatchNorm2d(512), nn.ReLU(inplace=True), nn.ConvTranspose2d(512, 512, kernel_size=3, stride=2, padding=1, output_padding=1), nn.BatchNorm2d(512), nn.ReLU(inplace=True), nn.ConvTranspose2d(512, 256, kernel_size=3, stride=2, padding=1, output_padding=1), nn.BatchNorm2d(256), nn.ReLU(inplace=True), nn.ConvTranspose2d(256, 256, kernel_size=3, stride=2, padding=1, output_padding=1), nn.BatchNorm2d(256), nn.ReLU(inplace=True), nn.ConvTranspose2d(256, 128, kernel_size=3, stride=2, padding=1, output_padding=1), nn.BatchNorm2d(128), nn.ReLU(inplace=True), nn.ConvTranspose2d(128, 64, kernel_size=3, stride=2, padding=1, output_padding=1), nn.BatchNorm2d(64), nn.ReLU(inplace=True), ) # Dense Feature Linking self.linker_1 = nn.Conv2d(512, 256, kernel_size=1) self.linker_2 = nn.Conv2d(256, 128, kernel_size=1) self.linker_3 = nn.Conv2d(128, 64, kernel_size=1) # 分类器 self.classifier = nn.Conv2d(64, out_channels, kernel_size=1) def forward(self, x): # Encoder部分 enc_outputs = [] enc_outputs.append(x) x = self.encoder[0:4](x) enc_outputs.append(x) x = self.encoder[4:9](x) enc_outputs.append(x) x = self.encoder[9:16](x) enc_outputs.append(x) x = self.encoder[16:23](x) enc_outputs.append(x) x = self.encoder[23:](x) enc_outputs.append(x) # Decoder部分 x = self.decoder[0](x) x = torch.cat((x, enc_outputs[5], self.linker_1(enc_outputs[5])), dim=1) x = self.decoder[1:4](x) x = torch.cat((x, enc_outputs[4], self.linker_2(enc_outputs[4])), dim=1) x = self.decoder[4:7](x) x = torch.cat((x, enc_outputs[3], self.linker_3(enc_outputs[3])), dim=1) x = self.decoder[7:](x) # 分类器 x = self.classifier(x) return x ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

GHZhao_GIS_RS

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值