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, args, conv=common.default_conv): super(SFNet, self).__init__() n_resblocks = args.n_resblocks n_feats = args.n_feats kernel_size = 3 scale = args.scale act = nn.LeakyReLU(0.2, inplace=True) # act = nn.ReLU(True) # 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.o_colors, kernel_size) ] self.head = nn.Sequential(*m_head) self.body = nn.Sequential(*m_body) self.downscaled = nn.Aver(3, stride=2) self.tail = nn.Sequential(*m_tail)
def __init__(self, conv=common.default_conv): super(Net, self).__init__() pos_head = [conv(1, 128, 7)] pos_body = [common.ResBlock(conv, 128, 3, res_scale=1) for _ in range(8)] pos_tail = [conv(128, 4, 3), nn.Tanh()] self.pos_head = nn.Sequential(*pos_head) self.pos_body = nn.Sequential(*pos_body) self.pos_tail = nn.Sequential(*pos_tail) def block(in_channel, out_channel): return nn.Sequential( nn.Conv2d(in_channels=in_channel, out_channels=in_channel, kernel_size=3, padding=1), nn.ReLU(inplace=False), nn.Conv2d(in_channels=in_channel, out_channels=out_channel, kernel_size=3, padding=1), nn.ReLU(inplace=False), nn.MaxPool2d(kernel_size=2, stride=2) ) offset_head = [conv(2, 256, 7)] offset_body = [block(256, 128), block(128, 64), block(64, 32), block(32, 16), block(16, 8), block(8, 4)] self.offset_head = nn.Sequential(*offset_head) self.offset_body = nn.Sequential(*offset_body)
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, conv=common.default_conv, n_view=9, scale=2): super(resLF, self).__init__() # 4 resblock in each image stack n_resblock = 4 # 4 resblock in the global part n_mid_resblock = 4 n_feats = 32 kernel_size = 3 act = nn.ReLU(True) n_colors = 1 self.n_view = n_view # define head module m_head = [conv(n_view, n_feats, kernel_size)] central_head = [conv(n_colors, n_feats, kernel_size)] # define body module m_mid_body = [ common.ResBlock(conv, n_feats, kernel_size, act=act, res_scale=1) for _ in range(n_mid_resblock) ] m_body = [ common.ResBlock(conv, n_feats * 4, kernel_size, act=act, res_scale=1) for _ in range(n_resblock) ] m_body.append(conv(n_feats * 4, 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.head = nn.Sequential(*m_head) self.central_head = nn.Sequential(*central_head) self.midbody = nn.Sequential(*m_mid_body) 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(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(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)
def __init__(self, n1=9, n2=3, n_feats=64, kp_size=3, conv=common.default_conv): super(DKPNet, self).__init__() padding = 1 img_channels = 1 kernel_size = 3 n1_resblocks = n1 n2_resblocks = n2 res_scale = 1 act = nn.ReLU(True) self.kernel_pred = KernelConv(kp_size) head = [conv(img_channels, n_feats, kernel_size)] # define the structure of shared feature extraction m_sfe = [ common.ResBlock(conv, n_feats, kernel_size, act=act, res_scale=res_scale) for _ in range(n1_resblocks) ] m_sfe.append(conv(n_feats, n_feats, kernel_size)) # define the structure of branch feature extraction # d1,d2,d3 branches share the same structure, but of individual entities m_b1fe = [ ResDltBlock(1, n_feats, kernel_size, act=act, res_scale=res_scale) for _ in range(n2_resblocks) ] m_b1fe.append(conv(n_feats, n_feats, kernel_size)) m_b2fe = [ ResDltBlock(2, n_feats, kernel_size, act=act, res_scale=res_scale) for _ in range(n2_resblocks) ] m_b2fe.append(conv(n_feats, n_feats, kernel_size)) m_b3fe = [ ResDltBlock(3, n_feats, kernel_size, act=act, res_scale=res_scale) for _ in range(n2_resblocks) ] m_b3fe.append(conv(n_feats, n_feats, kernel_size)) # The main pipeline of the network self.head = nn.Sequential(*head) self.sfe = nn.Sequential(*m_sfe) # Compressed feature map self.cmprss = conv(n_feats, 1, kernel_size) #self.cmprss = DeformConv2d(n_feats, 1, kernel_size, padding=1, bias=False, modulation=True) # Feature branches self.d1fe = nn.Sequential(*m_b1fe) self.d2fe = nn.Sequential(*m_b2fe) self.d3fe = nn.Sequential(*m_b3fe) # generate kernel-prediction filter of dilations 1,2,3 self.d1kp = conv(n_feats, kp_size * kp_size, kernel_size) self.d2kp = conv(n_feats, kp_size * kp_size, kernel_size) self.d3kp = conv(n_feats, kp_size * kp_size, kernel_size) # kernel core fusion self.fusion = conv(3 * kp_size * kp_size, kp_size * kp_size, kernel_size) # 3x3 reconstrution convolution, channel 1->1 self.rec = conv(1, 1, kernel_size)
def __init__(self, ker_size=3, n_kers=64, n1_nodes=800, n2_nodes=800, conv=common.default_conv): super(CNNIQAnet, self).__init__() self.conv1 = nn.Conv2d(1, n_kers, 3, padding=1) m_body1 = [ common.ResBlock2(conv, 128, 3, 1, act=nn.ReLU(True)) for _ in range(1) ] m_body11 = [ common.ResBlock(conv, 128, 3, 1, act=nn.ReLU(True)) for _ in range(1) ] m_body111 = [ common.ResBlock(conv, 128, 3, 1, act=nn.ReLU(True)) for _ in range(1) ] self.body1 = nn.Sequential(*m_body1) self.body11 = nn.Sequential(*m_body11) self.body111 = nn.Sequential(*m_body111) m_body2 = [ common.ResBlock2(conv, 256, 3, 1, act=nn.ReLU(True)) for _ in range(1) ] m_body22 = [ common.ResBlock(conv, 256, 3, 1, act=nn.ReLU(True)) for _ in range(1) ] m_body222 = [ common.ResBlock(conv, 256, 3, 1, act=nn.ReLU(True)) for _ in range(1) ] self.body2 = nn.Sequential(*m_body2) self.body22 = nn.Sequential(*m_body22) self.body222 = nn.Sequential(*m_body222) m_body3 = [ common.ResBlock2(conv, 512, 3, 1, act=nn.ReLU(True)) for _ in range(1) ] m_body33 = [ common.ResBlock(conv, 512, 3, 1, act=nn.ReLU(True)) for _ in range(1) ] m_body333 = [ common.ResBlock(conv, 512, 3, 1, act=nn.ReLU(True)) for _ in range(1) ] self.body3 = nn.Sequential(*m_body3) self.body33 = nn.Sequential(*m_body33) self.body333 = nn.Sequential(*m_body333) self.conv5 = nn.Conv2d(128, 128, 3, padding=1) self.conv6 = nn.Conv2d(128, 128, 3, padding=1) self.conv7 = nn.Conv2d(128, 128, 3, padding=1) self.convdel4 = nn.Conv2d(512, 128, 1) self.convdel3 = nn.Conv2d(256, 128, 1) self.convdel2 = nn.Conv2d(128, 128, 1) self.conv11 = nn.Conv2d(in_channels=1, out_channels=16, kernel_size=3, stride=1, padding=1) self.pyconv1 = PyConv2d(in_channels=16, out_channels=[16, 16, 32], pyconv_kernels=[3, 5, 7], pyconv_groups=[1, 4, 8]) self.pyconv2 = PyConv2d(in_channels=64, out_channels=[16, 16, 32], pyconv_kernels=[3, 5, 7], pyconv_groups=[1, 4, 8]) self.fc1 = nn.Linear(47104, n1_nodes) self.fc2 = nn.Linear(n1_nodes, n2_nodes) self.fc3 = nn.Linear(n2_nodes, 1) self.fc4 = nn.Linear(11782, n1_nodes) self.fc5 = nn.Linear(n1_nodes, n2_nodes) self.fc6 = nn.Linear(n2_nodes, 1)