Home

Awesome

Editing Out-of-domain GAN Inversion via Differential Activations

This is the official implementation of the paper "Editing Out-of-domain GAN Inversion via Differential Activations"

Prerequisite

Getting Started

Preparation

Run the Model

python image_process.py --device 0
--diffcam_ckpt_path path_to_diffcam_weight
--deghosting_ckpt_path path_to_deghosting_weight
--direction_path ./directions/Beard.npy
--image_dir ./sample_images
--output_dir path_to_output_dir
--psp_ckptpath path_to_psp_encoder_ffhq_weight

Training

In order to train our model, you need to train the Diff-CAM module and deghosting network one by one.

Training Diff-CAM Module

The first step is to train the Diff-CAM module. Run the following command to train the module.

python trainerDA.py --trainset_path path_to_training_dataset
--testset_path path_to_testing_dataset
--device 0
--DA_batch_size your_batch_size
--num_workers your_dataloader_num_workers
--direction_path ./directions
--exp_dir path_to_experiment_directory
--psp_ckptpath path_to_psp_encoder_ffhq_weight

Generating Ghosting Images

Before training the deghosting network, you need to generate the ghosting images dataset. Run the following command to generate ghosting images.

python gen_dataset.py --diffcam_ckpt_path path_to_diffcam_path
--direction_dir ./directions
--src_image_dir path_to_source_dataset
--dst_image_dir path_to_output_ghosting_dataset
--psp_ckptpath path_to_psp_encoder_ffhq_weight

Training Deghosting Network

After generating the ghosting image dataset, you can finally train the deghosting network. Run the following command to train the network.

python train_deghosting.py --trainset_lq_path path_to_trainset_lq
--testset_lq_path path_to_testset_lq
--trainset_tg_path path_to_trainset_tg
--testset_tg_path path_to_testset_tg
--exp_dir path_to_experiment_directory