| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This repository provides a pytorch-based implementation of GLCIC introduced by Iizuka et. al.
Our scripts were tested in the following environment.
You can install all the requirements by executing below.
# in <path-to-this-repo>/
pip install -r requirements.txt -f https://download.pytorch.org/whl/torch_stable.htmlBoth the generator and discriminator were trained on the CelebA dataset. Note that you don't need to have dicriminator when performing image completion (discriminator is needed only during training).
# in <path-to-this-repo>/
python predict.py model_cn config.json images/test_2.jpg test_2_out.jpgLeft: raw input image
Center: masked input image
Right: inpainted output image
This section introduces how to train a glcic model using CelebA dataset.
Download the dataset from this official link.
Then, execute the following commands.
# unzip dataset
unzip img_align_celeba.zip
# move dataset
mv img_align_celeba/ <path-to-this-repo>/datasets/
# move into datasets/ directory
cd <path-to-this-repo>/datasets/
# make dataset
python make_dataset.py img_align_celeba/The last command splits the dataset into training dataset (80%) and test dataset (20%) randomly.
Run the following command.
# in <path-to-this-repo>
python train.py datasets/img_align_celeba results/demo/Training results (model snapshots & test inpainted outputs) are to be saved in results/demo/.
The training procedure consists of the following three phases.
Default settings of train.py are based on the original paper except for batch size. If you need to reproduce the paper result, add --data_parallel --bsize 96 when executing training.
You have to prepare a dataset in the following format.
dataset/ # any name is OK
|____train/ # used for training
| |____XXXX.jpg # .png format is also acceptable.
| |____OOOO.jpg
| |____....
|____test/ # used for test
|____oooo.jpg
|____xxxx.jpg
|____....
Both dataset/train and dataset/test are required.
# in <path-to-this-repo>/
# move dataset
mv dataset/ datasets/
# execute training
python train.py datasets/dataset/ results/result/ [--data_parallel (store true)] [--cn_input_size (int)] [--ld_input_size (int)] [--init_model_cn (str)] [--init_model_cd (str)] [--steps_1 (int)] [--steps_2 (int)] [--steps_3 (int)] [--snaperiod_1 (int)] [--snaperiod_2 (int)] [--snaperiod_3 (int)] [--bsize (int)] [--bdivs (int)]Example: If you train a model with batch size 24 with data_parallel option and leave the other settings as default, run the following command.
# in <path-to-this-repo>/
python train.py datasets/dataset results/result --data_parallel --bsize 24Assume you've finished training and result directory is <path-to-this-repo>/results/result.
# in <path-to-this-repo>/
python predict.py results/result/phase_3/model_cn_step<step-number> results/result/config.json <input_img> <output_img> [--max_holes (int)] [--img_size (int)] [--hole_min_w (int)] [--hole_max_w (int)] [--hole_min_h (int)] [--hole_max_h (int)]Arguments
Example: If you make an inference with an input image <path-to-this-repo>/input.jpg and save output image as <path-to-this-repo>/output.jpg, run the following command.
# in <path-to-this-repo>/
python predict.py results/result/phase_3/model_cn_step{step_number} results/result/config.json input.jpg output.jpg| Back | FazBrowse Home | New Git URL |