[PYTHON] Try installing chainer-gogh

[Algorithm to convert style] (https://research.preferred.jp/2015/09/chainer-gogh/) Has been released.

I'm new to machine learning and python, but many people want to get it working anyway. Therefore, I will write a supplementary article about the omission.

[mattya/chainer-gogh] (https://github.com/mattya/chainer-gogh)

** Install chainer-gogh.py **

In the upper right [download zip] Get all the above GitHub data from. Unfold it and If you execute chainer-gogh.py in this from the command line with arguments as described in the article, you can execute it from Linux, Windows, MacOSX.

You need to install chainer before running chainer-gogh.py We use a tool called pip. If pip is installed, regardless of OS type The following command will install chainer.

>pip install chainer

** If you don't have python in the first place **

For Windows, Python(x,y) http://python-xy.github.io/

Put in. Since there is no library such as numpy or matplotlib in the installer of Python alone, it is recommended to install Python (x, y) because the number of additional installations will increase.

For Ubuntu, use apt-get, and for MacOSX, use homebrew to install the necessary libraries.

MacOSX folks are encouraged to read the article on installing Python 2.7 in the articles of other MacOSX users. I think it's a good idea to check in advance to prevent the Python environment from colliding with the Python that was originally included in MacOSX and the Python 2.7 that you want to add. You may also want to check pyenv etc. (I'm sorry I can't write properly because I'm not a MacOSX user.)

Check the console to see if pip is installed in your environment >pip --help If the usage is displayed by typing, >pip install chainer Is feasible.

** Install pip **

If not, install pip. (For pip installation, please search for articles for each OS.) Python for Windows installation memo http://www.aoki.ecei.tohoku.ac.jp/~ito/python_windows.html According to setuptools (easy_install) > python ez_setup.py > easy_install pip It seems to be a two-step installation. (I had already installed it on my PC, but I forgot the procedure.)

When I ran it on ubuntu on VirtualBox, the situation was as follows.

VirtualBox:~$ pip The program'pip' is not yet installed. You can install it by typing: sudo apt-get install python-pip

And showed me how to install it. Therefore >sudo apt-get install python-pip And pip was installed. continue >sudo pip install chainer The installation was performed as.

** Running chainer-gogh **

>pip install chainer After that, If it is CPU execution, it can be executed as follows. input.png style.png is For the time being, sample_images/cat.png sample_images/style_0.png I copied and used it.

>python chainer-gogh.py -i input.png -s style.png -o output.png -g -1

Since the result is displayed in the output.png directory I am patient.

CPU execution is a single-core process, so it doesn't finish even if it takes a day.

I want to set the GPU and run the GPU version.

** Note: Please execute with administrator authority when installing. ** **

In the case of Windows, [Start Menu] When selecting [Command Prompt] from, right-click and select [Run with administrator privileges]. In the case of apt-get sudo apt-get Execute with administrator privileges.

As far as it can be executed on the CPU version, all Python relationships worked on the 32-bit version as well.

In order to use GPU, it seems necessary to recreate the environment in consideration of the following. ・ OS: 64-bit version -What is the Python build (64bit or 32bit)? ・ Cuda version and (64bit or 32bit) ・ Numpy etc.

Postscript: When an error occurs

IOError: [Errno 2] No such file or directory: 'nin_imagenet.caffemodel'

https://gist.github.com/mavenlin/d802a5849de39225bcc6 I got the nin_imagenet.caffemodel file from the following site and put it in the execution directory.

caffemodel_url: https://www.dropbox.com/s/0cidxafrb2wuwxw/nin_imagenet.caffemodel?dl=1 Chainer Download model I found it at NIN.

** Addition: Works with different data **

Later, I tried to run chainer-gogh with different data. Compared to when it was operated before, the number of processing increases faster. I haven't investigated yet whether it depends on the processed data or if some calculated cache works, which makes it faster to process after calculating once. Even if you think it's slow with a single CPU, try running it first.

** Addendum: "Chainer Tutorial -for v1.5-ViEW 2015" **

"Chainer Tutorial -for v1.5-ViEW2015" is available on slideshare.

It is now using the Cython language.

Article by the developer Algorithm for converting style

Recommended Posts

Try installing chainer-gogh
Try installing Polynote
Try installing Sonnet (memo)
Try installing OpenAM on Amazon Linux
Try installing OpenCV 3.0 on your AMI
Installing Python 3.4.3.
Try python
try pysdl2
Try PyOpenGL
Try installing only the core part of Ubuntu
Try installing GeoSpark (Apache Sedona) in Python environment