Example #1
0
    def __init__(self, configer):
        super(CycleGAN, self).__init__()
        # load/define networks
        # The naming conversion is different from those used in the paper
        # Code (paper): G_A (G), G_B (F), D_A (D_Y), D_B (D_X)
        self.configer = configer
        self.netG_A = SubNetSelector.generator(
            net_dict=self.configer.get('network', 'generatorA'),
            use_dropout=self.configer.get('network', 'use_dropout'),
            norm_type=self.configer.get('network', 'norm_type'))
        self.netG_B = SubNetSelector.generator(
            net_dict=self.configer.get('network', 'generatorB'),
            use_dropout=self.configer.get('network', 'use_dropout'),
            norm_type=self.configer.get('network', 'norm_type'))

        self.netD_A = SubNetSelector.discriminator(
            net_dict=self.configer.get('network', 'discriminatorA'),
            norm_type=self.configer.get('network', 'norm_type'))
        self.netD_B = SubNetSelector.discriminator(
            net_dict=self.configer.get('network', 'discriminatorB'),
            norm_type=self.configer.get('network', 'norm_type'))

        self.fake_A_pool = ImagePool(
            self.configer.get('network', 'imgpool_size'))
        self.fake_B_pool = ImagePool(
            self.configer.get('network', 'imgpool_size'))
        # define loss functions
        self.criterionGAN = GANLoss(
            gan_mode=self.configer.get('loss', 'params')['gan_mode'])
        self.criterionCycle = nn.L1Loss()
        self.criterionIdt = nn.L1Loss()
Example #2
0
    def __init__(self, configer):
        super(CycleGAN, self).__init__()
        # load/define networks
        # The naming conversion is different from those used in the paper
        # Code (paper): G_A (G), G_B (F), D_A (D_Y), D_B (D_X)
        self.configer = configer
        self.netG_A = SubnetSelector.generator(
            self.configer.get('network', 'generatorA'))
        self.netG_B = SubnetSelector.generator(
            self.configer.get('network', 'generatorB'))

        self.netD_A = SubnetSelector.discriminator(
            self.configer.get('network', 'discriminatorA'))
        self.netD_B = SubnetSelector.discriminator(
            self.configer.get('network', 'discriminatorB'))

        self.fake_A_pool = ImagePool(
            self.configer.get('network', 'discriminatorA')['pool_size'])
        self.fake_B_pool = ImagePool(
            self.configer.get('network', 'discriminatorB')['pool_size'])
        # define loss functions
        self.criterionGAN = GANLoss(
            use_lsgan=self.configer.get('loss', 'use_lsgan'))
        self.criterionCycle = nn.L1Loss()
        self.criterionIdt = nn.L1Loss()
Example #3
0
    def __init__(self, configer):
        super(Pix2Pix, self).__init__()
        self.configer = configer
        # load/define networks
        self.netG = SubnetSelector.generator(net_dict=self.configer.get('network', 'generator'))
        self.netD = SubnetSelector.discriminator(net_dict=self.configer.get('network', 'discriminator'))

        self.fake_AB_pool = ImagePool(self.configer.get('network', 'imgpool_size'))
        # define loss functions
        self.criterionGAN = GANLoss(gan_mode=self.configer.get('loss', 'gan_mode'))
        self.criterionL1 = nn.L1Loss()
Example #4
0
    def initialize(self, opt):

        # load/define networks
        self.netG = SubnetSelector.generator(
            self.configer.get('network', 'generator'))
        self.netD = SubnetSelector.discriminator(
            self.configer.get('network', 'discriminator'))

        self.fake_AB_pool = ImagePool(opt.pool_size)
        # define loss functions
        self.criterionGAN = GANLoss(
            use_lsgan=self.configer.get('loss', 'use_lsgan'))
        self.criterionL1 = nn.L1Loss()