Esempio n. 1
0
 def __init__(self, args):
     super(FastDenoisaicking, self).__init__()
     self.pack = layers.PackBayerMosaicLayer(args.bayer_type, pack_depth=1)
     self.GMpreprocess = layers.GMPreprocess()
     self.RBpreprocess = layers.RBPreprocess()
     self.Lpreprocess = layers.LPreprocess()
     self.crop = layers.CropLayer()
     self.down_layer1 = nn.Sequential(
         nn.Conv2d(1, 16, kernel_size=3, stride=1, padding=1),
         nn.LeakyReLU(negative_slope=0.2),
         nn.Conv2d(16, 32, kernel_size=3, stride=1, padding=1),
         nn.LeakyReLU(negative_slope=0.2),
     )
     self.down_layer2 = nn.Sequential(
         nn.Conv2d(32, 64, kernel_size=3, stride=1, padding=1),
         nn.LeakyReLU(negative_slope=0.2),
         nn.Conv2d(64, 128, kernel_size=3, stride=1, padding=1),
         nn.LeakyReLU(negative_slope=0.2),
     )
     self.down_layer3 = nn.Sequential(
         nn.Conv2d(128, 256, kernel_size=3, stride=1, padding=1),
         nn.LeakyReLU(negative_slope=0.2),
         nn.Conv2d(256, 512, kernel_size=3, stride=1, padding=1),
     )
     self.pool = nn.AdaptiveAvgPool2d(1)
     self.fc1 = nn.Sequential(
         nn.Linear(512, 512),
         nn.LeakyReLU(negative_slope=0.2),
     )
     self.h2a = nn.Linear(512, 23**2)
     self.h2b = nn.Linear(512, 23**2)
     self.h1 = nn.Linear(512, 23**2)
     self.init_params()
Esempio n. 2
0
 def __init__(self, args, depth=3):
     super(Submodel, self).__init__()
     self.args = args
     self.depth = depth
     input_channel = 4
     if self.args.add_noise:
         input_channel = 5
     channel = 64 / args.submodel_div
     print('dalong log : check channel in SubModel ={}'.format(channel))
     self.BayerMosaic = layers.BayerMosaicLayer(args.bayer_type)
     self.Crop = layers.CropLayer()
     self.layer1 = OrderedDict()
     self.pack_layer = layers.PackBayerMosaicLayer(args.bayer_type)
     for index in range(depth):
         in_channel = 64
         out_channel = 64
         if index == 0:
             in_channel = input_channel
         if index == depth - 1:
             out_channel = 12
         self.layer1['layer_{}'.format(index)] = nn.Sequential(
             nn.Conv2d(in_channel, out_channel, kernel_size=3, padding=1),
             nn.LeakyReLU(negative_slope=0.2),
         )
     self.layer1 = nn.Sequential(self.layer1)
     self.postLayer1 = nn.Sequential(
         nn.ConvTranspose2d(12, 3, kernel_size=2, stride=2, groups=3),
         nn.LeakyReLU(negative_slope=0.2))
     self.postLayer2 = nn.Sequential(
         nn.Conv2d(6, 3, kernel_size=3, padding=1),
         nn.LeakyReLU(negative_slope=0.2),
         nn.Conv2d(3, 3, kernel_size=3, padding=1),
     )
     self.init_params()
Esempio n. 3
0
 def __init__(self, args):
     super(DeepISP, self).__init__()
     self.args = args
     self.pack = layers.PackBayerMosaicLayer()
     if not self.args.predemosaic:
         self.block1 = layers.isp_block(4)
     else:
         self.block1 = layers.isp_block(3)
     self.block2 = layers.isp_block(64)
     self.block3 = layers.isp_block(64)
     self.block4 = layers.isp_block(64)
     self.block5 = layers.isp_block(64)
     self.block6 = layers.isp_block(64)
     self.block7 = layers.isp_block(64)
     self.block8 = layers.isp_block(64)
     self.block9 = layers.isp_block(64)
     self.block10 = layers.isp_block(64)
     self.block11 = layers.isp_block(64)
     self.block12 = layers.isp_block(64)
     self.block13 = layers.isp_block(64)
     self.block14 = layers.isp_block(64)
     self.block15 = layers.isp_block(64)
     self.block16 = layers.isp_block(64)
     self.block17 = layers.isp_block(64)
     self.block18 = layers.isp_block(64)
     self.block19 = layers.isp_block(64)
     if not self.args.predemosaic:
         self.block20 = nn.Conv2d(64, 12, kernel_size=1, stride=1)
     else:
         self.block20 = layers.isp_block(64)
     self.unpack = nn.ConvTranspose2d(12, 3, 2, stride=2, groups=3)
Esempio n. 4
0
 def __init__(self, args, Identical_Kernel=0):
     super(DeNet, self).__init__()
     self.args = args
     self.pack_layer = layers.PackBayerMosaicLayer()
     self.down_layer0 = nn.MaxPool2d(kernel_size=self.args.scale_factor,
                                     stride=self.args.scale_factor)
     self.down_layer1 = layers.ResnetModule(4, 32, Identical_Kernel)
     self.down_layer2 = layers.ResnetModule(32, 64, Identical_Kernel)
     self.down_layer3 = layers.ResnetModule(64, 128, Identical_Kernel)
     self.down_layer4 = layers.ResnetModule(128, 256, Identical_Kernel)
     self.down_layer5 = layers.ResnetModule(256, 512, Identical_Kernel)
     self.up1 = layers.Upsample_Concat(512, 256)
     self.up_layer1 = layers.ResnetModule(512, 256, Identical_Kernel)
     self.up2 = layers.Upsample_Concat(256, 128)
     self.up_layer2 = layers.ResnetModule(256, 128, Identical_Kernel)
     self.up3 = layers.Upsample_Concat(128, 64)
     self.up_layer3 = layers.ResnetModule(128, 64, Identical_Kernel)
     self.up4 = layers.Upsample_Concat(64, 32)
     self.up_layer4 = layers.ResnetModule(64, 32, Identical_Kernel)
     self.up_layer5 = layers.ResnetModule(32, 4, Identical_Kernel)
     self.post_conv1 = nn.Conv2d(8, 4, kernel_size=3, stride=1, padding=1)
     self.output_layer = nn.ConvTranspose2d(4, 1, 2, stride=2)
     self.up5 = nn.Upsample(scale_factor=self.args.scale_factor,
                            mode='bilinear')
     self.init_params()
Esempio n. 5
0
 def __init__(self, args):
     super(FilterModel, self).__init__()
     self.args = args
     self.model = nn.Sequential(
         layers.PackBayerMosaicLayer(args.bayer_type),
         nn.Conv2d(4, 16, kernel_size=3, stride=1, padding=1),
         nn.LeakyReLU(negative_slope=0.2),
         nn.Conv2d(16, 32, kernel_size=3, stride=1, padding=1),
         nn.LeakyReLU(negative_slope=0.2),
         nn.Conv2d(32, 64, kernel_size=3, stride=1, padding=1),
         nn.LeakyReLU(negative_slope=0.2),
         nn.Conv2d(64, 32, kernel_size=3, stride=1, padding=1),
         nn.LeakyReLU(negative_slope=0.2),
         nn.Conv2d(32, 12, kernel_size=3, stride=1, padding=1),
         nn.ConvTranspose2d(12, 3, 2, stride=2),
     )
Esempio n. 6
0
 def __init__(self, args, Identical_Kernel=0):
     super(UNet, self).__init__()
     self.args = args
     self.pack_layer = layers.PackBayerMosaicLayer()
     self.down_layer1 = layers.ResnetModule(4, 32, Identical_Kernel)
     self.down_layer2 = layers.ResnetModule(32, 64, Identical_Kernel)
     self.down_layer3 = layers.ResnetModule(64, 128, Identical_Kernel)
     self.down_layer4 = layers.ResnetModule(128, 256, Identical_Kernel)
     self.down_layer5 = layers.ResnetModule(256, 512, Identical_Kernel)
     self.up1 = layers.Upsample_Concat(512, 256)
     self.up_layer1 = layers.ResnetModule(512, 256, Identical_Kernel)
     self.up2 = layers.Upsample_Concat(256, 128)
     self.up_layer2 = layers.ResnetModule(256, 128, Identical_Kernel)
     self.up3 = layers.Upsample_Concat(128, 64)
     self.up_layer3 = layers.ResnetModule(128, 64, Identical_Kernel)
     self.up4 = layers.Upsample_Concat(64, 32)
     self.up_layer4 = layers.ResnetModule(64, 32, Identical_Kernel)
     self.up_layer5 = layers.ResnetModule(32, 12, Identical_Kernel)
     self.output_layer = nn.ConvTranspose2d(12, 3, 2, stride=2, groups=3)
     self.init_params()
Esempio n. 7
0
 def __init__(self, args):
     super(UNet2, self).__init__()
     self.args = args
     self.pack_layer = layers.PackBayerMosaicLayer()
     self.down_layer1 = layers.ResnetModule(4, 32)
     self.down_layer2 = layers.ResnetModule(32, 64)
     self.down_layer3 = layers.ResnetModule(64, 128)
     self.down_layer4 = layers.ResnetModule(128, 256)
     self.down_layer5 = layers.ResnetModule(256, 512)
     self.up1 = layers.Upsample_Concat(512, 256)
     self.up_layer1 = layers.isp_block(512, 256 - 3, 3)
     self.up2 = layers.Upsample_Concat(256, 128)
     self.up_layer2 = layers.isp_block(256, 128 - 3, 3)
     self.up3 = layers.Upsample_Concat(128, 64)
     self.up_layer3 = layers.isp_block(128, 64 - 3, 3)
     self.up4 = layers.Upsample_Concat(64, 32)
     self.up_layer4 = layers.isp_block(64, 32 - 3, 3)
     self.up_layer5 = layers.isp_block(32, 12 - 3, 3)
     self.output_layer = nn.ConvTranspose2d(12, 3, 2, stride=2, groups=3)
     self.init_params()
Esempio n. 8
0
 def __init__(self,
              depth,
              channel,
              ksize,
              pad=0,
              batchnorm=True,
              bayer_type='GRBG'):
     super(DemosaicNet, self).__init__()
     self.bayer_type = bayer_type
     # Pack the input to 4D inputs
     self.packmosaic = layers.PackBayerMosaicLayer()
     # conv_block
     self.preconv = layers.lowlevel_block(1, 4, channel, ksize, pad,
                                          batchnorm)
     self.block1 = layers.lowlevel_block(depth - 2, channel, channel, ksize,
                                         pad, batchnorm)
     self.conv15 = layers.lowlevel_block(1,
                                         channel,
                                         12,
                                         ksize,
                                         pad=0,
                                         batchnorm=batchnorm)
     # unpack the residul array to original inputs
     self.unpack = layers.UnpackBayerMosaicLayer()
     # original Mosaic array for 3 channels
     self.mosaic_mask = layers.BayerMosaicLayer(bayer_type=self.bayer_type)
     # crop the input with regard to reference
     self.crop_layer = layers.CropLayer()
     # full resolution convolution
     self.fullres_conv1 = layers.lowlevel_block(1, 6, channel, ksize, pad,
                                                batchnorm)
     self.fullres_conv2 = nn.Conv2d(channel,
                                    3,
                                    kernel_size=1,
                                    stride=1,
                                    padding=pad)
     # init the parameters
     self.init_params()
Esempio n. 9
0
    def __init__(self, args):
        self.args = args
        super(SIDNet, self).__init__()
        self.pack_layer = layers.PackBayerMosaicLayer()
        self.down_layer1 = nn.Sequential(
            nn.Conv2d(4, 32, kernel_size=3, stride=1, padding=1),
            nn.LeakyReLU(negative_slope=0.2),
            nn.Conv2d(32, 32, kernel_size=3, stride=1, padding=1),
            nn.LeakyReLU(negative_slope=0.2),
        )
        self.down_layer2 = nn.Sequential(
            nn.Conv2d(32, 64, kernel_size=3, stride=1, padding=1),
            nn.LeakyReLU(negative_slope=0.2),
            nn.Conv2d(64, 64, kernel_size=3, stride=1, padding=1),
            nn.LeakyReLU(negative_slope=0.2),
        )
        self.down_layer3 = nn.Sequential(
            nn.Conv2d(64, 128, kernel_size=3, stride=1, padding=1),
            nn.LeakyReLU(negative_slope=0.2),
            nn.Conv2d(128, 128, kernel_size=3, stride=1, padding=1),
            nn.LeakyReLU(negative_slope=0.2),
        )
        self.down_layer4 = nn.Sequential(
            nn.Conv2d(128, 256, kernel_size=3, stride=1, padding=1),
            nn.LeakyReLU(negative_slope=0.2),
            nn.Conv2d(256, 256, kernel_size=3, stride=1, padding=1),
            nn.LeakyReLU(negative_slope=0.2),
        )
        self.down_layer5 = nn.Sequential(
            nn.Conv2d(256, 512, kernel_size=3, stride=1, padding=1),
            nn.LeakyReLU(negative_slope=0.2),
            nn.Conv2d(512, 512, kernel_size=3, stride=1, padding=1),
            nn.LeakyReLU(negative_slope=0.2),
        )
        self.up1 = layers.Upsample_Concat(512, 256)
        self.up_layer1 = nn.Sequential(
            nn.Conv2d(512, 256, kernel_size=3, stride=1, padding=1),
            nn.LeakyReLU(negative_slope=0.2),
            nn.Conv2d(256, 256, kernel_size=3, stride=1, padding=1),
            nn.LeakyReLU(negative_slope=0.2),
        )
        self.up2 = layers.Upsample_Concat(256, 128)
        self.up_layer2 = nn.Sequential(
            nn.Conv2d(256, 128, kernel_size=3, stride=1, padding=1),
            nn.LeakyReLU(negative_slope=0.2),
            nn.Conv2d(128, 128, kernel_size=3, stride=1, padding=1),
            nn.LeakyReLU(negative_slope=0.2),
        )
        self.up3 = layers.Upsample_Concat(128, 64)
        self.up_layer3 = nn.Sequential(
            nn.Conv2d(128, 64, kernel_size=3, stride=1, padding=1),
            nn.LeakyReLU(negative_slope=0.2),
            nn.Conv2d(64, 64, kernel_size=3, stride=1, padding=1),
            nn.LeakyReLU(negative_slope=0.2),
        )

        self.up4 = layers.Upsample_Concat(64, 32)
        self.up_layer4 = nn.Sequential(
            nn.Conv2d(64, 32, kernel_size=3, stride=1, padding=1),
            nn.LeakyReLU(negative_slope=0.2),
            nn.Conv2d(32, 32, kernel_size=3, stride=1, padding=1),
            nn.LeakyReLU(negative_slope=0.2),
        )

        self.up_layer5 = nn.Conv2d(32, 12, kernel_size=1, stride=1)
        self.output_layer = nn.ConvTranspose2d(12, 3, 2, stride=2, groups=3)
        self.init_params()
        if args.pretrained:
            self.init_with_pretrained()