多尺度特征融合超分辨率(论文实验)

from torch import nn
import torch
import os
os.environ['CUDA_VISIBLE_DEVICES']='1'

class CALayer(nn.Module):
    def __init__(self, in_channel=64, reduction=16):
        super(CALayer, self).__init__()

        self.avg_pool = nn.AdaptiveAvgPool2d(1)

        self.max_pool = nn.AdaptiveMaxPool2d(1)
        self.conv_du = nn.Sequential(
            nn.Conv2d(in_channel, in_channel // reduction, 1, padding=0, bias=True),
            nn.ReLU(inplace=False),
            nn.Conv2d(in_channel // reduction, in_channel, 1, padding=0, bias=True),
            nn.Sigmoid()
        )

    def forward(self, x):
        # y = self.avg_pool(x)+self.max_pool(x)
        y = self.avg_pool(x)
        y = self.conv_du(y)
        return y*x

class CharbonnierLoss(nn.Module):
    """L1 Charbonnierloss."""
    def __init__(self):
        super(CharbonnierLoss, self).__init__

猜你喜欢

转载自blog.csdn.net/qq_40107571/article/details/126998996