def __init__(self, conv=common.default_conv): super(EDAR, self).__init__() n_resblock = 8 n_feats = 64 kernel_size = 3 #DIV 2K mean rgb_mean = (0.4488, 0.4371, 0.4040) rgb_std = (1.0, 1.0, 1.0) self.sub_mean = common.MeanShift(rgb_mean, rgb_std) # define head module m_head = [conv(3, n_feats, kernel_size)] # define body module m_body = [ common.ResBlock(conv, n_feats, kernel_size) for _ in range(n_resblock) ] m_body.append(conv(n_feats, n_feats, kernel_size)) # define tail module m_tail = [conv(n_feats, 3, kernel_size)] self.add_mean = common.MeanShift(rgb_mean, rgb_std, 1) self.head = nn.Sequential(*m_head) self.body = nn.Sequential(*m_body) self.tail = nn.Sequential(*m_tail)
def __init__(self): super(EDSR, self).__init__() conv = common.default_conv n_resblocks = 16 n_feats = 64 kernel_size = 3 scale = 2 n_colors = 3 res_scale = 0.1 act = nn.ReLU(True) self.sub_mean = common.MeanShift(255) self.add_mean = common.MeanShift(255, sign=1) # define head module m_head = [conv(n_colors, n_feats, kernel_size)] # define body module m_body = [ common.ResBlock(conv, n_feats, kernel_size, act=act, res_scale=res_scale) for _ in range(n_resblocks) ] m_body.append(conv(n_feats, n_feats, kernel_size)) # define tail module m_tail = [ common.Upsampler(conv, scale, n_feats, act=False), conv(n_feats, n_colors, kernel_size) ] self.head = nn.Sequential(*m_head) self.body = nn.Sequential(*m_body) self.tail = nn.Sequential(*m_tail)
def __init__(self, args, inchannels, outchannels, conv=common.default_conv): super(C2D, self).__init__() n_resblock = args.n_resblocks n_feats = args.n_feats kernel_size = 3 #Originally used ReLU act = nn.ELU(inplace=True) rgb_mean = (0.4488, 0.4371, 0.4040) rgb_std = (1.0, 1.0, 1.0) self.sub_mean = common.MeanShift(1, rgb_mean, rgb_std, channels=3 * inchannels) # define head module m_head = [conv(inchannels * 3, n_feats, kernel_size)] # define body module m_body = [ common.ResBlock(conv, n_feats, kernel_size, act=act, res_scale=args.res_scale) for _ in range(n_resblock) ] m_body.append(conv(n_feats, n_feats, kernel_size)) # define tail module m_tail = [ nn.Conv2d(n_feats, outchannels * 3, kernel_size, padding=(kernel_size // 2)), nn.Tanh() ] self.add_mean = common.MeanShift(1, rgb_mean, rgb_std, channels=3 * outchannels, sign=1) self.head = nn.Sequential(*m_head) self.body = nn.Sequential(*m_body) self.tail = nn.Sequential(*m_tail)
def __init__(self, conv=common.default_conv): super(EDSR, self).__init__() # n_resblock = args.n_resblocks n_resblock = 8 # n_feats = args.n_feats n_feats = 64 kernel_size = 3 # scale = args.scale[0] scale = 2 act = nn.ReLU(True) # n_colors = args.n_colors n_colors = 1 n_view = 9 # args.rgb_range rgb_range = 255 rgb_mean = (0.4488, 0.4371, 0.4040) rgb_std = (1.0, 1.0, 1.0) self.sub_mean = common.MeanShift(rgb_range, rgb_mean, rgb_std) # define head module m_head = [conv(n_view, n_feats, kernel_size)] central_head = [conv(n_colors, n_feats, kernel_size)] # define body module # res_scale = args.res_scale m_body = [ common.ResBlock(conv, n_feats, kernel_size, act=act, res_scale=1) for _ in range(n_resblock) ] m_body.append(conv(n_feats, n_feats, kernel_size)) # define tail module m_tail = [ common.Upsampler(conv, scale, n_feats, act=False), nn.Conv2d(n_feats, n_colors, kernel_size, padding=(kernel_size // 2)) ] self.add_mean = common.MeanShift(rgb_range, rgb_mean, rgb_std, 1) self.head = nn.Sequential(*m_head) self.central_head = nn.Sequential(*central_head) self.body = nn.Sequential(*m_body) self.tail = nn.Sequential(*m_tail)
def __init__(self, args, conv=common.default_conv): super(ERCAN, self).__init__() n_resgroups = args.n_resgroups n_resblocks = args.n_resblocks n_feats = args.n_feats kernel_size = 3 reduction = args.reduction scale = args.scale act = nn.ReLU(True) # RGB mean for DIV2K rgb_mean = (0.4488, 0.4371, 0.4040) rgb_std = (1.0, 1.0, 1.0) self.sub_mean = common.MeanShift(args.rgb_range, rgb_mean, rgb_std) # define head module modules_head = [conv(args.n_colors, n_feats, kernel_size)] # define body module modules_body = [ ResidualGroup(conv, n_feats, kernel_size, reduction, act=act, res_scale=args.res_scale, n_resblocks=n_resblocks) for _ in n_resgroups ] modules_body.append(conv(n_feats, n_feats, kernel_size)) # define tail module modules_tail = [ common.Upsampler(conv, scale, n_feats, act=False), conv(n_feats, args.n_colors, kernel_size) ] self.add_mean = common.MeanShift(args.rgb_range, rgb_mean, rgb_std, sign=1) self.head = nn.Sequential(*modules_head) self.body = nn.Sequential(*modules_body) self.tail = nn.Sequential(*modules_tail)
def __init__(self, args, conv=common.default_conv): super(EDSR, self).__init__() n_resblocks = args.n_resblocks n_feats = args.n_feats kernel_size = 3 scale = args.scale[0] act = nn.ReLU(True) url_name = 'r{}f{}x{}'.format(n_resblocks, n_feats, scale) if url_name in url: self.url = url[url_name] else: self.url = None self.sub_mean = common.MeanShift(args.rgb_range) self.add_mean = common.MeanShift(args.rgb_range, sign=1) # define head module m_head = [conv(args.n_colors, n_feats, kernel_size)] # define body module m_body = [ common.ResBlock(conv, n_feats, kernel_size, act=act, res_scale=args.res_scale) for _ in range(n_resblocks) ] m_body.append(conv(n_feats, n_feats, kernel_size)) # define tail module m_tail = [ common.Upsampler(conv, scale, n_feats, act=False), conv(n_feats, args.n_colors, kernel_size) ] self.head = nn.Sequential(*m_head) self.body = nn.Sequential(*m_body) self.tail = nn.Sequential(*m_tail)
def __init__(self, args, conv=common.default_conv): super(RDN, self).__init__() rgb_mean = (0.4488, 0.4371, 0.4040) rgb_std = (1.0, 1.0, 1.0) self.sub_mean = common.MeanShift(args.rgb_range, rgb_mean, rgb_std) kernel_size = 3 self.is_sub_mean = args.is_sub_mean self.conv1 = conv(args.n_channel_in, args.n_feats, kernel_size, bias=True) self.conv2 = conv(args.n_feats, args.n_feats, kernel_size, bias=True) self.RDBs = [] for i in xrange(args.n_denseblocks): RDB = common.RDB(args.n_feats, args.n_layers, args.growth_rate, conv, kernel_size, True) self.add_module('RDB{}'.format(i + 1), RDB) self.RDBs.append(RDB) self.gff_1 = nn.Conv2d(args.n_feats * args.n_denseblocks, args.n_feats, kernel_size=1, padding=0, bias=True) self.gff_3 = conv(args.n_feats, args.n_feats, kernel_size, bias=True) m_tail = [ common.Upsampler(conv, args.scale[0], args.n_feats, act=False), conv(args.n_feats, args.n_channel_out, kernel_size) ] self.tail = nn.Sequential(*m_tail) self.add_mean = common.MeanShift(args.rgb_range, rgb_mean, rgb_std, 1)
def __init__(self, args, conv=common.default_conv): super(SRResNet, self).__init__() kernel_size = 3 scale = args.scale[0] act = nn.LeakyReLU(negative_slope=0.2) self.is_sub_mean = args.is_sub_mean rgb_mean = (0.4488, 0.4371, 0.4040) rgb_std = (1.0, 1.0, 1.0) self.sub_mean = common.MeanShift(args.rgb_range, rgb_mean, rgb_std) head = [ conv(args.n_channel_in, args.n_feats, kernel_size), nn.LeakyReLU(negative_slope=0.2) ] body = [common.ResBlock(conv,args.n_feats,kernel_size,bn=True,act=act) \ for _ in xrange(args.n_resblocks)] body.extend([ conv(args.n_feats, args.n_feats, kernel_size), nn.BatchNorm2d(args.n_feats) ]) tail = [ common.Upsampler(conv, scale, args.n_feats, act=nn.LeakyReLU, act_kwargs={'negative_slope': .2}), conv(args.n_feats, args.n_channel_out, kernel_size) ] self.head = nn.Sequential(*head) self.body = nn.Sequential(*body) self.tail = nn.Sequential(*tail) self.add_mean = common.MeanShift(args.rgb_range, rgb_mean, rgb_std, 1)