Ejemplo n.º 1
0
        matrix = MulLayer('r31')
        vgg = encoder3()
        dec = decoder3()
    elif (opt.layer == 'r41'):
        matrix = MulLayer('r41')
        vgg = encoder4()
        dec = decoder4()
    vgg.load_state_dict(torch.load(opt.vgg_dir))
    # dec.load_state_dict(torch.load(opt.decoder_dir))
    vgg5.load_state_dict(torch.load(opt.loss_network_dir))
    matrix.load_state_dict(torch.load(opt.matrixPath))
    for param in vgg.parameters():
        param.requires_grad = False
    for param in vgg5.parameters():
        param.requires_grad = False
    for param in matrix.parameters():
        param.requires_grad = False
    # for param in dec.parameters():
    #     param.requires_grad = False

    ################# LOSS & OPTIMIZER #################
    criterion = LossCriterion(opt.style_layers, opt.content_layers,
                              opt.style_weight, opt.content_weight,
                              opt.sp_weight)
    optimizer = optim.Adam(dec.parameters(), opt.lr)

    ################# GPU  #################
    if (opt.cuda):
        vgg.cuda()
        dec.cuda()
        vgg5.cuda()
Ejemplo n.º 2
0
    dec = decoder4()
vgg.load_state_dict(torch.load(opt.vgg_dir))
dec.load_state_dict(torch.load(opt.decoder_dir))
vgg5.load_state_dict(torch.load(opt.loss_network_dir))

for param in vgg.parameters():
    param.requires_grad = False
for param in vgg5.parameters():
    param.requires_grad = False
for param in dec.parameters():
    param.requires_grad = False

################# LOSS & OPTIMIZER #################
criterion = LossCriterion(opt.style_layers, opt.content_layers,
                          opt.style_weight, opt.content_weight)
optimizer = optim.Adam(matrix.parameters(), opt.lr)

################# GLOBAL VARIABLE #################
contentV = torch.Tensor(opt.batchSize, 3, opt.fineSize, opt.fineSize)
styleV = torch.Tensor(opt.batchSize, 3, opt.fineSize, opt.fineSize)

################# GPU  #################
if (opt.cuda):
    vgg.cuda()
    dec.cuda()
    vgg5.cuda()
    matrix.cuda()
    contentV = contentV.cuda()
    styleV = styleV.cuda()