Home

Awesome

deepfillv2

The PyTorch implementations and guideline for Gated Convolution based on ICCV 2019 oral paper: free-form inpainting (deepfillv2).

We are focusing on Gated Conv so do not implement original paper completely, and implement it as a coarse-to-fine manner.

1 Implementations

Before running it, please ensure the environment is Python 3.6 and PyTorch 1.0.1.

1.1 Train

If you train it from scratch, please specify following hyper-parameters. For other parameters, we recommend the default settings.

python train.py     --epochs 40
                    --lr_g 0.0001
                    --batch_size 4
                    --perceptual_param 10
                    --gan_param 0.01
                    --baseroot [the path of training set, like Place365]
                    --mask_type 'free_form' [or 'single_bbox' or 'bbox']
                    --imgsize 256
if you have more than one GPU, please change following codes:
python train.py     --multi_gpu True
                    --gpu_ids [the ids of your multi-GPUs]

1.2 Test

At testing phase, please download the pre-trained model first. (including deepfillv2 network for RGB images and grayscale images)

For small image patches, make sure that all the dataset settings are the same as training part:

python test.py 	    --load_name '*.pth' (please ensure the pre-trained model is in same path)
                    --baseroot [the path of testing set]
                    --mask_type 'free_form' [or 'single_bbox' or 'bbox']
                    --imgsize 256

There are some examples:

<img src="./images/result1.png" width="1000"/> <img src="./images/result2.png" width="1000"/>

The corresponding ground truth is:

<img src="./images/gt.png" width="1000"/>

1.3 PSNR experiment on 15 images

item123456789101112131415
mask region13.2318.2317.0613.1619.4111.4729.5815.5114.7125.9920.5419.2115.8611.7910.73
full image26.5045.0132.3529.5931.6524.5748.4430.2732.2451.1835.1536.7530.5627.2129.13

2 Acknowledgement

@inproceedings{yu2019free,
  title={Free-form image inpainting with gated convolution},
  author={Yu, Jiahui and Lin, Zhe and Yang, Jimei and Shen, Xiaohui and Lu, Xin and Huang, Thomas S},
  booktitle={Proceedings of the IEEE International Conference on Computer Vision},
  pages={4471--4480},
  year={2019}
}