1. 数据集下载
map数据集为例子:更新🔗
直接运行:
bash ./datasets/download_cyclegan_dataset.sh maps
会出问题:
Specified [maps]
WARNING: timestamping does nothing in combination with -O. See the manual
for details.
--2020-07-17 15:26:59-- https://people.eecs.berkeley.edu/~taesung_park/CycleGAN/datasets/maps.zip
Resolving people.eecs.berkeley.edu (people.eecs.berkeley.edu)... 128.32.189.73
Connecting to people.eecs.berkeley.edu (people.eecs.berkeley.edu)|128.32.189.73|:443... connected.
ERROR: cannot verify people.eecs.berkeley.edu's certificate, issued by ‘emailAddress=mars@doctorcom.com,CN=www.doctorcom.com,OU=2066,O=Dr.COM SSL,L=Guangzhou,ST=GD,C=CN’:
Self-signed certificate encountered.
ERROR: certificate common name ‘www.doctorcom.com’ doesn't match requested host name ‘people.eecs.berkeley.edu’.
To connect to people.eecs.berkeley.edu insecurely, use `--no-check-certificate'.
Archive: ./datasets/maps.zip
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
unzip: cannot find zipfile directory in one of ./datasets/maps.zip or
./datasets/maps.zip.zip, and cannot find ./datasets/maps.zip.ZIP, period.
此处下载facade 的数据集合应用一种房屋🏠像pixel像素转换的类型,不过是paired的具体怎么搞暂不清楚,test前30个图像。
2.训练cyclegan
#!./scripts/train_cyclegan.sh
python train.py --dataroot ./datasets/maps --name maps_cyclegan --model cycle_gan
可以看出其中
- –dataroot 训练数据的根目录
- –name 训练模型的名称
- –model 训练的模型的类型
此处相关信息解释,参考cyclegan概览与运行
此处报错:
----------------- Options ---------------
batch_size: 1
beta1: 0.5
checkpoints_dir: ./checkpoints
continue_train: False
crop_size: 256
dataroot: ./datasets/maps [default: None]
dataset_mode: unaligned
direction: AtoB
display_env: main
display_freq: 400
display_id: 1
display_ncols: 4
display_port: 8097
display_server: http://localhost
display_winsize: 256
epoch: latest
epoch_count: 1
gan_mode: lsgan
gpu_ids: 0
init_gain: 0.02
init_type: normal
input_nc: 3
isTrain: True [default: None]
lambda_A: 10.0
lambda_B: 10.0
lambda_identity: 0.5
load_iter: 0 [default: 0]
load_size: 286
lr: 0.0002
lr_decay_iters: 50
lr_policy: linear
max_dataset_size: inf
model: cycle_gan
n_epochs: 100
n_epochs_decay: 100
n_layers_D: 3
name: maps_cyclegan [default: experiment_name]
ndf: 64
netD: basic
netG: resnet_9blocks
ngf: 64
no_dropout: True
no_flip: False
no_html: False
norm: instance
num_threads: 4
output_nc: 3
phase: train
pool_size: 50
preprocess: resize_and_crop
print_freq: 100
save_by_iter: False
save_epoch_freq: 5
save_latest_freq: 5000
serial_batches: False
suffix:
update_html_freq: 1000
verbose: False
----------------- End -------------------
Traceback (most recent call last):
File "train.py", line 28, in <module>
opt = TrainOptions().parse() # get training options
File "/sata1/lifei/project/pytorch-Cpix/options/base_options.py", line 133, in parse
torch.cuda.set_device(opt.gpu_ids[0])
File "/home/lifei/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/cuda/__init__.py", line 245, in set_device
torch._C._cuda_setDevice(device)
AttributeError: module 'torch._C' has no attribute '_cuda_setDevice'
解决办法:
作者给出了答案
3.pip指定python版本安装
-
安装到python2.7版本中:
-sudo pip2 install 模块名 或 python2 -m pip install 模块名 -
安装到python3.5版本中:
-
sudo pip3 install 模块名 或
python3 -m pip install 模块名
4.linux删除文件
Linux删除目录很简单,很多人还是习惯用rmdir,不过一旦目录非空,就陷入深深的苦恼之中,现在使用rm -rf命令即可。
直接rm就可以了,不过要加两个参数-rf 即:rm -rf 目录名字
5. 测试pytorc+cuda+cuDNN,pytorch的Gpu版本安装是否成功
>>> import torch
>>> torch.cuda.is_available()
False
6.接上面的问题
This is space. It does not cooperate.
You just begin. You do the math. You solve one problem then you solve the next one. And then the next. And if you solve enough problems, you got to come home.
-----‘The Martian’
先上图:
已可正常运行。Thank God!
废话多了,过程很简单,可能是比较幸运。
运行pytorch版本发现没有运行gpu版,尝试进行cpu运行,但时间太长了,图片也就1300多张,但无法忍受,换成gpu版。
conda install pytorch torchvision cudatoolkit=9.0 -c pytorch
就这一行,对!
That’s it!参考链接🔗
p.s.
colab版早就跑出来了,但这个cyclegan的原版的确让我从心里上开始畏惧是7月12日的事儿了。然后实在是多个实验有涉及,真的是躲不开了,周三MltiGAN的路径的确让我状态有点崩,多少也和不自律有点关系,昨天到今天,算是搞出来。
有点长舒一口气,成功的经验还是要积累的,不过,不知道为什么那种特别开心的状态好像好久都没有了。想买个大件,让自己开心一下吧,买了后也发现情绪波动。那可能就是这样吧。2020年,这一年我笑容没那么多了😊😊😊 。