This PyTorch implementation produces results comparable to or better than our original Torch software. If you would like to reproduce the same results as in the papers, check out the original CycleGAN Torch and pix2pix Torch code in Lua/Torch.
Pix2pix: Paper | Tensorflow Core Tutorial | PyTorch Colab
TensorFlow Core pix2pix Tutorial: Google Colab | Code
- Python 3
- CPU or NVIDIA GPU + CUDA CuDNN
- Clone this repo:
git clone https://github.com/saba99/pix2pix-Facades
cd pix2pix-Facades
- Install PyTorch and 0.4+ and other dependencies with
pip install -r requirements.txt
command.
- Download a pix2pix dataset (e.g.facades):
bash ./datasets/download_pix2pix_dataset.sh facades
- To log training progress and test images to W&B dashboard, set the
--use_wandb
flag with train and test script - Train a model:
#!./scripts/train_pix2pix.sh
python train.py --dataroot ./datasets/facades --name facades_pix2pix --model pix2pix --direction BtoA
To see more intermediate results, check out ./checkpoints/facades_pix2pix/web/index.html
.
- Test the model (
bash ./scripts/test_pix2pix.sh
):
#!./scripts/test_pix2pix.sh
python test.py --dataroot ./datasets/facades --name facades_pix2pix --model pix2pix --direction BtoA
- The test results will be saved to a html file here:
./results/facades_pix2pix/test_latest/index.html
. You can find more scripts atscripts
directory. - To train and test pix2pix-based colorization models, please add
--model colorization
and--dataset_mode colorization
.
Download a pre-trained model with ./scripts/download_pix2pix_model.sh
.
- Check here for all the available pix2pix models. For example, if you would like to download label2photo model on the Facades dataset,
bash ./scripts/download_pix2pix_model.sh facades_label2photo
- Download the pix2pix facades datasets:
bash ./datasets/download_pix2pix_dataset.sh facades
- Then generate the results using
python test.py --dataroot ./datasets/facades/ --direction BtoA --model pix2pix --name facades_label2photo_pretrained
-
Note that we specified
--direction BtoA
as Facades dataset's A to B direction is photos to labels. -
If you would like to apply a pre-trained model to a collection of input images (rather than image pairs), please use
--model test
option. See./scripts/test_single.sh
for how to apply a model to Facade label maps (stored in the directoryfacades/testB
).