基于cpu运行CycleGAN实现风格迁移

介绍、论文、视频:

CycleGAN主页

实现:

CycleGAN的github链接

环境:

Linux系统(我用的是WSL,WSL是一个在win10 下运行的linux子系统,比虚拟机,双系统安装和运行都更加方便,可以参考:WSL介绍)

基于cpu运行

详细步骤参考:

[1] https://github.com/junyanz/CycleGAN/tree/253a5a65cb64823748e8e8e851acabad7840b9a1

[2] http://torch.ch/docs/getting-started.html#_

[3] https://blog.csdn.net/dcz1994/article/details/89461181

报错归总:

1.
sudo bash install-deps
#报错:
# E: Package 'python-software-properties' has no installation candidate

#解决:
sudo apt-get install software-properties-common

#原因:
# software-properties-common package is an alternate one for python-software-properties

#参考:
# https://askubuntu.com/questions/422975/e-package-python-software-properties-has-no-installation-candidate

2.
sudo ./install.sh

#报错:
# ./install.sh: line 73: cmake: command not found

#解决:
sudo apt install cmake
sudo ./install.sh

3.
luarocks install image

#报错:
Command 'luarocks' not found

#解决:
sudo apt install luarocks

4.

#报错:
Error: No results matching query were found.

#解决:
sudo ~/torch/install/bin/luarocks install image

#原因:
# luarocks在安装torch时一般已经安装,需要保证luarocks调用的是~/torch/install/bin/下的luarocks,且用sudo执行。

#参考:https://blog.csdn.net/qq_33591712/article/details/84653341

#同理
sudo ~/torch/install/bin/luarocks install nngraph
sudo ~/torch/install/bin/luarocks install class

5.

#报错:
 libjpeg package not found, please install libjpeg

#解决:
sudo apt-get install libpng-dev
sudo apt-get install zlib1g-dev
sudo apt-get install libjpeg-dev

#参考:
# https://askubuntu.com/questions/508934/how-to-install-libpng-and-zlib/508937


6.
luarocks install https://raw.githubusercontent.com/szym/display/master/display-scm-0.rockspec

#报错:
# error: this statement may fall through [-Werror=implicit-fallthrough=]         found_at = 1;
# Error: Failed installing dependency: https://raw.githubusercontent.com/torch/rocks/master/async-scm-1.rockspec - Build error: Failed building.

#解决:
#by downgrading my gcc version using following commands
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-5 g++-5
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /usr/bin/g++ g++ /usr/bin/g++-5

#原因: 不是很理解

# 参考:
# https://stackoverflow.com/questions/48940431/luarocks-fails-install-async

6.
DATA_ROOT=./datasets/ae_photos name=style_cezanne_pretrained model=one_direction_test phase=test loadSize=256 fineSize=256 resize_or_crop="scale_width" th test.lua

#报错
# module 'cutorch' not found:No LuaRocks module found for cutorch

#原因:
# cutorch: A CUDA backend for Torch7 - GitHub
# 而此处我们使用的是cpu,不含CUDA,需要将相关参数设为0

DATA_ROOT=./datasets/ae_photos name=style_cezanne_pretrained model=one_direction_test phase=test loadSize=256 fineSize=256 resize_or_crop="scale_width" gpu=0 cudnn=0 th test.lua

卸载torch的命令:

rm -rf ~/torch

需要提前安装好的包(不然后续步骤中会出错误):

# image, nngraph, class, display
$ luarocks install image #An Image toolbox for Torch
$ luarocks install nngraph
$ luarocks install class
$ luarocks install https://raw.githubusercontent.com/szym/display/master/display-scm-0.rockspec
 

你可能感兴趣的:(style,transfer,pytorch,深度学习)