系统相关
首页 > 系统相关> > 在自己的数据集上实现CycleGAN(pytorch linux)

在自己的数据集上实现CycleGAN(pytorch linux)

作者:互联网

代码
https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix
参考文章
https://blog.csdn.net/Gavinmiaoc/article/details/80585531

1.将数据裁成256*256。

2.在datasets目录下新建文件夹label2image,在label2image下新建 trainA 和,trainB,testA,testB,A是你要训练的,B是你想生成的。(把图片放进去,不用成对)

3.在你的pytorch下,
pip install visdom
pip install dominate
python3 -m visdom.server
(and click the URL http://localhost:8097. To see more intermediate results, check out )
./checkpoints/maps_cyclegan/web/index.html

4.运行
python3 train.py --dataroot ./datasets/label2image --name label2image_cyclegan --model cycle_gan --pool_size 50 --no_dropout --gpu_ids 0
模型在checkpoint里

报错点一:
注意 这里–gpu_ids 0 是只有一个显卡,如果有两个上行改–gpu_ids 0,1
https://blog.csdn.net/weixin_43169773/article/details/109462068

报错点二:
ConnectionRefusedError: [Errno 111] Connection refused

https://blog.csdn.net/seamanj/article/details/102467626

This problem is related to visdom. You can start the visdom visualizatoin server by running python -m visdom.server. You can disable the visdom visualization by adding --display_id 0
这是因为可视化的问题,我没想看过程,就直接不可视化了,运行

python3 train.py --dataroot ./datasets/label2image --name label2image_cyclegan --model cycle_gan --pool_size 50 --no_dropout --gpu_ids 0 --display_id 0

报错点三:
python 引用 pillow 报错
ImportError: cannot import name ‘PILLOW_VERSION’

这个问题在引用 pillow 这个包时出现,主要原因是安装的 pillow 时 7.0.0 版本.

而 PILLOW_VERSION 在新版本中没有了。因此切换成旧版本(6.0.0)的 pillow 就可以了。

运行一下语句

pip uninstall pillow
pip install pillow==6
https://www.cnblogs.com/Assist/p/12427278.html

注意,最好先卸载旧版本,再安6.0版本,不然有可能运行时还是7的版本。

5.训练完的测试
运行
python test.py --dataroot ./datasets/label2image --name label2image_cyclegan --model cycle_gan --phase test --no_dropout
然后结果就在results里了

特别简单!!

标签:label2image,visdom,CycleGAN,--,pytorch,报错,https,linux,pillow
来源: https://blog.csdn.net/weixin_49636863/article/details/114499153