Exemplo n.º 1
0
Arquivo: run.py Projeto: KSRawal/fsgan
    def __init__(self):
        weights_dir = '../weights'
        finetune_iterations = 100
        seg_remove_mouth = True
        seg_batch_size = 2
        batch_size = 2

        detection_model = os.path.join(weights_dir, 'v2/WIDERFace_DSFD_RES152.pth')
        pose_model = os.path.join(weights_dir, 'shared/hopenet_robust_alpha1.pth')
        lms_model = os.path.join(weights_dir, 'v2/hr18_wflw_landmarks.pth')
        seg_model = os.path.join(weights_dir, 'v2/celeba_unet_256_1_2_segmentation_v2.pth')
        reenactment_model = os.path.join(weights_dir, 'v2/nfv_msrunet_256_1_2_reenactment_v2.1.pth')
        completion_model = os.path.join(weights_dir, 'v2/ijbc_msrunet_256_1_2_inpainting_v2.pth')
        blending_model = os.path.join(weights_dir, 'v2/ijbc_msrunet_256_1_2_blending_v2.pth')
        criterion_id_path = os.path.join(weights_dir, 'v2/vggface2_vgg19_256_1_2_id.pth')
        criterion_id = VGGLoss(criterion_id_path)
        self.model = FaceSwapping(
                detection_model=detection_model, pose_model=pose_model, lms_model=lms_model,
                seg_model=seg_model, reenactment_model=reenactment_model,
                completion_model=completion_model, blending_model=blending_model,
                criterion_id=criterion_id,
                finetune=True, finetune_save=True, finetune_iterations=finetune_iterations,
                seg_remove_mouth=finetune_iterations, batch_size=batch_size,
                seg_batch_size=seg_batch_size, encoder_codec='mp4v')
Exemplo n.º 2
0
     '/data/datasets/ijb-c/ijbc_cropped/ijbc_cropped_r256_cs1.2',
     'val_list.txt',
     frame_window=1,
     ignore_landmarks=True,
     same_prob=0.0)
 numpy_transforms = [RandomHorizontalFlip(), Pyramids(2)]
 tensor_transforms = [ToTensor()]
 resolutions = [128, 256]
 lr_gen = [1e-4, 4e-5]
 lr_dis = [1e-5, 4e-6]
 epochs = [24, 50]
 iterations = ['20k']
 batch_size = [32, 16]
 workers = 32
 pretrained = False
 criterion_id = VGGLoss('../../weights/vggface2_vgg19_256_1_2_id.pth')
 criterion_attr = VGGLoss('../../weights/celeba_vgg19_256_2_0_28_attr.pth')
 criterion_gan = GANLoss(use_lsgan=True)
 generator = MultiScaleResUNet(in_nc=7,
                               out_nc=3,
                               flat_layers=(2, 2, 2, 2),
                               ngf=128)
 discriminator = MultiscaleDiscriminator(use_sigmoid=True, num_D=2)
 optimizer = partial(optim.Adam, betas=(0.5, 0.999))
 scheduler = partial(lr_scheduler.StepLR, step_size=10, gamma=0.5)
 reenactment_model = '../results/reenactment/ijbc_msrunet_reenactment_attr_no_seg/G_latest.pth'
 seg_model = '../../weights/lfw_figaro_unet_256_segmentation.pth'
 lms_model = '../../weights/hr18_wflw_landmarks.pth'
 rec_weight = 1.0
 gan_weight = 0.1
 background_value = -1.0
Exemplo n.º 3
0
batch_size = 8

detection_model = os.path.join(weights_dir, 'v2/WIDERFace_DSFD_RES152.pth')
pose_model = os.path.join(weights_dir, 'shared/hopenet_robust_alpha1.pth')
lms_model = os.path.join(weights_dir, 'v2/hr18_wflw_landmarks.pth')
seg_model = os.path.join(weights_dir,
                         'v2/celeba_unet_256_1_2_segmentation_v2.pth')
reenactment_model = os.path.join(
    weights_dir, 'v2/nfv_msrunet_256_1_2_reenactment_v2.1.pth')
completion_model = os.path.join(weights_dir,
                                'v2/ijbc_msrunet_256_1_2_inpainting_v2.pth')
blending_model = os.path.join(weights_dir,
                              'v2/ijbc_msrunet_256_1_2_blending_v2.pth')
criterion_id_path = os.path.join(weights_dir,
                                 'v2/vggface2_vgg19_256_1_2_id.pth')
criterion_id = VGGLoss(criterion_id_path)

face_swapping = FaceSwapping(detection_model=detection_model,
                             pose_model=pose_model,
                             lms_model=lms_model,
                             seg_model=seg_model,
                             reenactment_model=reenactment_model,
                             completion_model=completion_model,
                             blending_model=blending_model,
                             criterion_id=criterion_id,
                             finetune=True,
                             finetune_save=True,
                             finetune_iterations=finetune_iterations,
                             seg_remove_mouth=finetune_iterations,
                             batch_size=batch_size,
                             seg_batch_size=seg_batch_size,