/co-mod-gan-pytorch

pytorch implementation of the paper ``Large Scale Image Completion via Co-Modulated Generative Adversarial Networks"

Primary LanguagePython

co-mod-gan-pytorch

Implementation of the paper ``Large Scale Image Completion via Co-Modulated Generative Adversarial Networks"

official tensorflow version: https://github.com/zsyzzsoft/co-mod-gan

Input image Mask Result

Usage

requirments

conda install pytorch torchvision cudatoolkit=11 -c pytorch
conda install matplotlib jinja2 ninja dill
pip install git+https://github.com/zengxianyu/pytorch-fid

Download the code:

git clone https://github.com/zengxianyu/co-mod-gan-pytorch
git checkout train
git submodule init
git submodule update

inference

  1. download pretrained model using ``download/*.sh" (converted from the tensorflow pretrained model)

e.g. ffhq512

./download/ffhq512.sh

converted model:

  • FFHQ 512 checkpoints/comod-ffhq-512/co-mod-gan-ffhq-9-025000_net_G_ema.pth
  • FFHQ 1024 checkpoints/comod-ffhq-1024/co-mod-gan-ffhq-10-025000_net_G_ema.pth
  • Places 512 checkpoints/comod-places-512/co-mod-gan-places2-050000_net_G_ema.pth
  1. use the following command as a minimal example of usage
./test.sh

or

python test.py \
    --how_many 10 \
	--mixing 0 \
	--batchSize 1 \
	--nThreads 2 \
	--name comod-ffhq-512 \
	--dataset_mode testimage \
	--image_dir ./ffhq_debug/images \
	--mask_dir ./ffhq_debug/masks \
    --output_dir ./ffhq_debug \
	--load_size 512 \
	--crop_size 512 \
	--z_dim 512 \
	--model comod \
	--netG comodgan \
    --which_epoch co-mod-gan-ffhq-9-025000

Training

  1. download example datasets for training and validation
./download/data.sh
  1. use the following command as a minimal example of usage
./train.sh

Demo

Coming soon

Reference

[1] official tensorflow version: https://github.com/zsyzzsoft/co-mod-gan

[2] stylegan2-pytorch https://github.com/rosinality/stylegan2-pytorch

[3] pix2pixHD https://github.com/NVIDIA/pix2pixHD

[4] SPADE https://github.com/NVlabs/SPADE