[hidecontent type="logged" desc="隐藏内容:登录后可查看"]
git clone https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix
cd pytorch-CycleGAN-and-pix2pix
pip install -r requirements.txt
。conda env create -f environment.yml
.bash ./datasets/download_cyclegan_dataset.sh maps
python -m visdom.server
并单击 URL http://localhost:8097。--use_wandb
使用训练和测试脚本设置标志#!./scripts/train_cyclegan.sh
python train.py --dataroot ./datasets/maps --name maps_cyclegan --model cycle_gan
要查看更多中间结果,请查看./checkpoints/maps_cyclegan/web/index.html
。
#!./scripts/test_cyclegan.sh
python test.py --dataroot ./datasets/maps --name maps_cyclegan --model cycle_gan
./results/maps_cyclegan/latest_test/index.html
。bash ./datasets/download_pix2pix_dataset.sh facades
python -m visdom.server
并单击 URL http://localhost:8097。--use_wandb
使用训练和测试脚本设置标志#!./scripts/train_pix2pix.sh
python train.py --dataroot ./datasets/facades --name facades_pix2pix --model pix2pix --direction BtoA
要查看更多中间结果,请查看 ./checkpoints/facades_pix2pix/web/index.html
。
bash ./scripts/test_pix2pix.sh
):#!./scripts/test_pix2pix.sh
python test.py --dataroot ./datasets/facades --name facades_pix2pix --model pix2pix --direction BtoA
./results/facades_pix2pix/test_latest/index.html
。您可以在目录中找到更多脚本scripts
。--model colorization
和--dataset_mode colorization
。有关详细信息,请参阅我们的培训提示。bash ./scripts/download_cyclegan_model.sh horse2zebra
./checkpoints/{name}_pretrained/latest_net_G.pth
. 在此处查看所有可用的 CycleGAN 模型。bash ./datasets/download_cyclegan_dataset.sh horse2zebra
python test.py --dataroot datasets/horse2zebra/testA --name horse2zebra_pretrained --model test --no_dropout
该选项--model test
仅用于为一侧生成 CycleGAN 结果。此选项将自动设置--dataset_mode single
,仅加载一组中的图像。相反,使用--model cycle_gan
需要双向加载和生成结果,这有时是不必要的。结果将保存在./results/
。用于--results_dir {directory_path_to_save_result}
指定结果目录。
对于 pix2pix 和您自己的模型,您需要明确指定--netG
, --norm
,--no_dropout
以匹配训练模型的生成器架构。有关详细信息,请参阅此常见问题解答。
下载预训练模型./scripts/download_pix2pix_model.sh
。
bash ./scripts/download_pix2pix_model.sh facades_label2photo
bash ./datasets/download_pix2pix_dataset.sh facades
python test.py --dataroot ./datasets/facades/ --direction BtoA --model pix2pix --name facades_label2photo_pretrained
请注意,我们指定--direction BtoA
Facades 数据集的 A 到 B 方向是照片到标签。
如果您想将预训练模型应用于一组输入图像(而不是图像对),请使用--model test
选项。请参阅./scripts/test_single.sh
如何将模型应用于 Facade 标签映射(存储在目录中facades/testB
)。
查看当前可用型号的列表,网址为./scripts/download_pix2pix_model.sh
我们提供了可以运行此代码库的预构建 Docker 映像和 Dockerfile。见Docker。
下载 pix2pix/CycleGAN 数据集并创建您自己的数据集。
如果您计划为您的新应用程序实施自定义模型和数据集,我们提供一个数据集模板和一个模型模板作为起点。
如果您将此代码用于您的研究,请引用我们的论文。
@inproceedings{CycleGAN2017,
title={Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks},
author={Zhu, Jun-Yan and Park, Taesung and Isola, Phillip and Efros, Alexei A},
booktitle={Computer Vision (ICCV), 2017 IEEE International Conference on},
year={2017}
}
@inproceedings{isola2017image,
title={Image-to-Image Translation with Conditional Adversarial Networks},
author={Isola, Phillip and Zhu, Jun-Yan and Zhou, Tinghui and Efros, Alexei A},
booktitle={Computer Vision and Pattern Recognition (CVPR), 2017 IEEE Conference on},
year={2017}
}
[/hidecontent]