def __init__(self, in_nc, out_nc, nf, nb, gc=32, upscale=4, norm_type=None, act_type='leakyrelu', \
            mode='CNA', res_scale=1, upsample_mode='upconv'):
        super(RRDB_Net, self).__init__()
        n_upscale = int(math.log(upscale, 2))
        if upscale == 3:
            n_upscale = 1

        fea_conv = B.conv_block(in_nc, nf, kernel_size=3, norm_type=None, act_type=None)
        rb_blocks = [B.RRDB(nf, kernel_size=3, gc=32, stride=1, bias=True, pad_type='zero', \
            norm_type=norm_type, act_type=act_type, mode='CNA') for _ in range(nb)]
        LR_conv = B.conv_block(nf, nf, kernel_size=3, norm_type=norm_type, act_type=None, mode=mode)

        if upsample_mode == 'upconv':
            upsample_block = B.upconv_blcok
        elif upsample_mode == 'pixelshuffle':
            upsample_block = B.pixelshuffle_block
        else:
            raise NotImplementedError('upsample mode [%s] is not found' % upsample_mode)
        if upscale == 3:
            upsampler = upsample_block(nf, nf, 3, act_type=act_type)
        else:
            upsampler = [upsample_block(nf, nf, act_type=act_type) for _ in range(n_upscale)]
        HR_conv0 = B.conv_block(nf, nf, kernel_size=3, norm_type=None, act_type=act_type)
        HR_conv1 = B.conv_block(nf, out_nc, kernel_size=3, norm_type=None, act_type=None)

        self.model = B.sequential(fea_conv, B.ShortcutBlock(B.sequential(*rb_blocks, LR_conv)),\
            *upsampler, HR_conv0, HR_conv1)
 def __init__(self, ch_in=64, ch_out=64, res_type='res'):
     super(TopDownBlock, self).__init__()
     if res_type == 'rrdb':
         self.res_block = B.RRDB(ch_in, kernel_size=3, gc=32, stride=1, bias=True, pad_type='zero', \
                                 norm_type=None, act_type='leakyrelu', mode='CNA')
     else:
         self.res_block = ResidualBlock(ch_in=ch_in, ch_out=ch_out)
         # self.res_block = ResidualInceptionBlock(ch_in=ch_in, ch_out=ch_out)
     self.pool = nn.MaxPool2d(kernel_size=2)
    def __init__(self, ch_in=64, ch_out=64, res_type='res'):
        super(BottomUpBlock, self).__init__()
        if res_type == 'rrdb':
            self.res_block = B.RRDB(ch_in, kernel_size=3, gc=32, stride=1, bias=True, pad_type='zero', \
                                    norm_type=None, act_type='leakyrelu', mode='CNA')
        else:
            self.res_block = ResidualBlock(ch_in=ch_in, ch_out=ch_out)
            # self.res_block = ResidualInceptionBlock(ch_in=ch_in, ch_out=ch_out)

        self.upsample = nn.Upsample(scale_factor=2, mode='nearest')
Пример #4
0
    def __init__(self, in_nc=1, out_nc=1, nf=16, nb=16, gc=16, norm_type=None, act_type='leakyrelu', mode='CNA'):
        super(DenoseNet, self).__init__()
        fea_conv = B.conv_block(in_nc, nf, kernel_size=3, norm_type=None, act_type=None)
        rb_blocks = [B.RRDB(nf, kernel_size=3, gc=gc, stride=1, bias=True, pad_type='zero',
                            norm_type=norm_type, act_type=act_type, mode='CNA', dilation=(1, 2, 4), groups=1) for _ in
                     range(nb)]
        LR_conv = B.conv_block(nf, nf, kernel_size=3, norm_type=norm_type, act_type=None, mode=mode)
        HR_conv0 = B.conv_block(nf, nf, kernel_size=3, norm_type=None, act_type=act_type)
        HR_conv1 = B.conv_block(nf, out_nc, kernel_size=3, norm_type=None, act_type=None)

        self.model = B.sequential(fea_conv, B.ShortcutBlock(B.sequential(*rb_blocks, LR_conv))
                                  , HR_conv0, HR_conv1, nn.Sigmoid())
Пример #5
0
    def __init__(self,
                 in_nc,
                 out_nc,
                 nf,
                 nb,
                 gc=32,
                 upscale=4,
                 norm_type=None,
                 act_type='leakyrelu',
                 res_scale=1):
        super(RRDB_Net, self).__init__()
        n_upscale = int(math.log(upscale, 2))

        fea_conv = B.conv_block(in_nc,
                                nf,
                                kernel_size=3,
                                norm_type=None,
                                act_type=None)
        rb_blocks = [
            B.RRDB(nf,
                   kernel_size=3,
                   gc=32,
                   stride=1,
                   bias=True,
                   norm_type=norm_type,
                   act_type=act_type) for _ in range(nb)
        ]
        LR_conv = B.conv_block(nf,
                               nf,
                               kernel_size=3,
                               norm_type=norm_type,
                               act_type=None)

        upsample_block = B.upconv_blcok

        upsampler = [
            upsample_block(nf, nf, act_type=act_type) for _ in range(n_upscale)
        ]
        HR_conv0 = B.conv_block(nf,
                                nf,
                                kernel_size=3,
                                norm_type=None,
                                act_type=act_type)
        HR_conv1 = B.conv_block(nf,
                                out_nc,
                                kernel_size=3,
                                norm_type=None,
                                act_type=None)

        self.model = B.sequential(
            fea_conv, B.ShortcutBlock(B.sequential(*rb_blocks, LR_conv)),
            *upsampler, HR_conv0, HR_conv1)