1.介绍
2.安装
环境为mac10.13.2
2.1安装依赖
2.1.1 Torch
Torch是基于Lua语言的深度学习框架. 安装:
1 | curl -s https://raw.githubusercontent.com/torch/ezinstall/master/install-deps | bash |
第一条命令安装了LuaJIT 和 Torch的依赖库。第二条命令安装LuaJIT, LuaRocks,然后用 LuaRocks (lua 包管理工具)安装核心包:torch, nn and paths, 和其它包。上面命令把 torch 加入到了你的PATH环境变量中了,用 source 更新一下让环境变量生效:
1 | # 在 Linux 上 |
如果你想要卸载 torch,执行:
1 | rm -rf ~/torch |
现在在你可以用 Luarocks 安装新的包
1 | luarocks install image |
安装完之后,你可以在终端用 th 命令运行 torch,现在进入了 torch 的交互模式,类似Python的交互模式。
1 | $ th |
要退出交互模式,两次Ctrl+C,或输入 os.exit()。 要执行 file.lua, 写 th> dofile “file.lua”。 在非交互模式下执行文件:
1 | th file.lua |
th 命令有很多选项,类似 perl 和 ruby。
1 | $ th -h |
安装deep-photo-styletransfer所需依赖:
2.1.2Matlab or Octave
Matlab较大,而且是商用软件,所以选择了octave Octave是一款用于数值计算和绘图的开源软件, 精于矩阵运算:求解联立方程组、计算矩阵特征值和特征向量等等,并能够通过多种形式将数据可视化。Octave最简单的使用方式就是像使用一个计算器一样在命令提示符下输入相应的计算式。Octave能识别通常的计算表达式。例如,在终端输入
1 | octave:##>2+2 |
mac下首先确保自己的Mac安装了Xcode和Command Line Tool,通过以下命令安装Command Line Tool,
1 | xcode-select --install |
之后安装Mac下的包管理神器Homebrew,命令如下,
1 | curl -LsSf http://github.com/mxcl/homebrew/tarball/master | sudo tar xvz -C/usr/local --strip 1 |
通过以下命令升级Homebrew:
1 | sudo brew update && sudo brew upgrade |
之后通过以下命令安装gcc、XQuartz,最后就可以通过Homebrew安装Octave了,
1 | sudo brew install gcc |
mac下使用brew安装的octave是4.2版本,使用imread
等函数时会提示:
1 | error: Magick++ exception: octave-cli-4.2: Unable to access configuration file (delegates.mgk) reported by magick/blob.c:2101 (GetConfigureBlob) |
未找到原因,最后在https://wiki.octave.org/Octave_for_macOS#Simple_Installation_Instructions_2中下载[Mac OS X Bundle](https://sourceforge.net/projects/octave/files/Octave%20MacOSX%20Binary/2016-07-11-binary-octave-4.0.3/octave_gui_403_appleblas.dmg/download)中下载[4.0.3-gui](https://jaist.dl.sourceforge.net/project/octave/Octave%20MacOSX%20Binary/2016-07-11-binary-octave-4.0.3/octave_gui_403_appleblas.dmg)及[4.0.2 command line](https://jaist.dl.sourceforge.net/project/octave/Octave%20MacOSX%20Binary/2016-06-06-binary-octave-4.0.2/octave_cli_402.dmg)执行imread会出现:
1 | warning: your version of GraphicsMagick limits images to <16> bits per pixel |
根据GraphicsMagick中介绍是GraphicsMagick编译是参数不对,后下载(地址)使用
1 | ./configure --with-quantum-depth=16 --enable-shared --disable-static --with-magick-plus-plus=yes |
仍然不对,好像bound包依赖的库不是默认安装路径的. 使用最新的GraphicsMagick为1.3.27,命令行下可以使用gm命令:
1 | $ gm |
可以使用pkg install -forge package安装Octave-Forge 中的包,如默认使用的image包:
1 | pkg install -forge image |
也可以下载其他版本的image包到本地执行pkg install image-2.4.1.tar.gz
pkg list
可列出已安装的包,安装好后不能直接使用,使用前要load
1 | warning: the 'col2im' function belongs to the image package from Octave Forge which you have installed but not loaded. To load the package, run 'pkg load image' from the Octave prompt. |
有人使用docker容器解决了这个问题:https://github.com/martinbenson/deep-photo-styletransfer, 但是未尝试
GraphicsMagick UNIX/Cygwin/MinGW Compilation octave-devel 3.6.3 GraphicsMagick limits images to 8 bits per pixel Octave教程 Octave Tutorial Octave requirements Is removing the Matlab dependency possible? Added Matlab dependency alternative Re: [GM-apis] PythonMagick
2.1.3CUDA cudnn
2.1.4下载VGG-19
1 | sh models/download_models.sh |
2.1.5Compile cuda_utils.cu (Adjust PREFIX and NVCC_PREFIX in makefile for your machine)
遇到问题:
1 | THC.h includes THCGeneral.h, does not exist |
解决:
1 | I've fixed this issue by executing the following commands in terminal: |
可能有xcode Command Line Tool版本不兼容问题:
1 | nvcc fatal : The version ('80100') of the host compiler ('Apple clang') is not supported |
替换版本即可:
1 | 登录 https://developer.apple.com/downloads/ |
相关资源
- 深度摄影风格转换–Deep Photo Style Transfer
- cuDNN
- CUDA从入门到精通
- VGG论文笔记
- deep-photo-styletransfer-tf:Tensorflow (Python API) implementation of Deep Photo Style Transfer
- floydhub/deep-photo-styletransfer:Jupyter Notebook to train photorealistic style transfer
- How do I rebuild Octave and link in GraphicsMagick?
- /gnu/octave/ 的索引
相关问题
configure :error: No usable version of sed found:
I did ./configure to make a makefile
but it ran into an error: configure :error: No usable version of sed found:
I then typed which see
it shows /usr/bin/sed.
so, what’s wrong? why can’t ./configure find sed?
I happened to have this problem on my mac. This is because OS X uses an old version of sed. Installing gnu-sed by brew install gnu-sed
and alias gsed=sed
solved this problem. You may install gnu-sed with other method.
https://stackoverflow.com/questions/26351285/configure-error-no-usable-version-of-sed-found
gm-bin convert: Unable to access configuration file (delegates.mgk) [No such file or directory].
I am attempting to install GraphicsMagick in a hosting account…
I used this info to get it to work in most cases:
How do you specify the location of libraries to a binary? (linux)
However, it still cannot find the delegates.mgk (which is in ./lib/GraphicsMagick-1.3.14/delegates.mgk) as witnessed in this error:
gm-bin convert: Unable to access configuration file (delegates.mgk) [No such file or directory].
Either, a) how do find out where the binary thinks this file should be, or b) how do I extend the wrapper script to help it out?
Figured it out after looking through the binary for /PATH/
The binaries require these additional path variables:
1 | $MAGICK_CONFIG_PATH |
…here is the resulting script modification form my setup:
1 | #!/bin/sh |