Giter VIP home page Giter VIP logo

chainer-gogh's Introduction

chainer-gogh

Implementation of "A neural algorithm of Artistic style" (http://arxiv.org/abs/1508.06576) in Chainer. The Japanese readme can be found here.

(VGG, lam=0.0075, after 5000 iterations)

Usage:

Install Chainer

pip install chainer

See https://github.com/pfnet/chainer for details.

Download the model(s)

There are multiple models to chose from:

Simply specify: (-m nin)

With VGG, it takes a long time to make good looking images. (-m vgg, -m vgg_chainer)

After downloading and using the vgg_chainer model for the first time, all subsequent uses will load the model very fast.(functionality available in chainer 1.19 and above).

About the same as NIN, but there should be potential for good images. The optimum parameters are unknown. (-m googlenet)

Lightweight compared to VGG, should be good for illustrations/anime drawings. Optimal parameters are unknown. (-m i2v)

Run on CPU

python chainer-gogh.py -m nin -i input.png -s style.png -o output_dir -g -1

Run on GPU

python chainer-gogh.py -m nin -i input.png -s style.png -o output_dir -g <GPU number>

Stylize an image with VGG

python chainer-gogh.py -m vgg_chainer -i input.png -s style.png -o output_dir -g 0 --width 256

How to specify the model

-m nin

It is possible to change from nin to vgg, vgg_chainer, googlenet or i2v. To do this, put the model file in the working directory, keeping the default file name.

Generate multiple images simultaneously

  • First, create a file called input.txt and list the input and output file names:
input0.png style0.png
input1.png style1.png
...

then, run chainer-gogh-multi.py:

python chainer-gogh-multi.py -i input.txt

The VGG model uses a lot of GPU memory, be careful!

About the parameters

  • --lr: learning rate. Increase this when the generation progress is slow.
  • --lam: increase to make the output image similar to the input, decrease to add more style.
  • alpha, beta: coefficients relating to the error propagated from each layer. They are hard coded for each model.

Advice

  • At the moment, using square images (e.g. 256x256) is best.

chainer-gogh's People

Contributors

bkvogel avatar mattya avatar stonebig avatar woodrush avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chainer-gogh's Issues

Chainer GPU

For unknown reason, I cannot get the Chainer GPU to work, on Windows, py27. If I install chainer-master, then run the chainer-gogh, it keeps on crashing.

pillow get a float instead of an integer

trying (on Python-3.4 64bit, windows 10):

python chainer-gogh.py -m nin -i cat.png -s style_0.png -o zzz -g -1

I get an error I don't know what to do about:

load model... nin_imagenet.caffemodel
Traceback (most recent call last):
  File "chainer-gogh.py", line 196, in <module>
    img_content,nw,nh = image_resize(args.orig_img, W)
  File "chainer-gogh.py", line 50, in image_resize
    gogh = np.asarray(gogh.resize((new_w,new_h)))[:,:,:3].transpose(2, 0, 1)[::-1].astype(np.float32)
  File "python-3.4.4.amd64\lib\site-packages\PIL\Image.py", line 1554, in resize
    return self.convert('RGBa').resize(size, resample).convert('RGBA')
  File "python-3.4.4.amd64\lib\site-packages\PIL\Image.py", line 1556, in resize
    return self._new(self.im.resize(size, resample))
TypeError: integer argument expected, got float

Is there any English readme here?

hi@pfnet-research
Very good work!
I want to use this project,but I can read the readme in Japanese . Could you please give a simple english readme here?
Thank you very much!

Pre-trained model Always download failed?

cu_00095@gtx1080:/chainer-gogh$ time python chainer-gogh.py -m vgg_chainer -i /home/cu_00095/chainer-gogh/input/photo.png -s /home/cu_00095/chainer-gogh/style/q.png -o /home/cu_00095/chainer-gogh/result -g 0
load model... vgg_chainer
Downloading from http://www.robots.ox.ac.uk/%7Evgg/software/very_deep/caffe/VGG_ILSVRC_16_layers.caffemodel...
Connection to proxy.chongdata.com closed by remote host.cu_00095@gtx1080:
/chainer-gogh$ time python chainer-gogh.py -m vgg_chainer -i /home/cu_00095/chainer-gogh/input/photo.png -s /home/cu_00095/chainer-gogh/style/q.png -o /home/cu_00095/chainer-gogh/result -g 0
load model... vgg_chainer
Downloading from http://www.robots.ox.ac.uk/%7Evgg/software/very_deep/caffe/VGG_ILSVRC_16_layers.caffemodel...
Connection to proxy.chongdata.com closed by remote host.

I try to use vgg_chainer
But Pre-trained model Always download failed?now . I have download the VGG_ILSVRC_16_layers.caffemodel to the chainer root directory;
How should I change the code to skip the connect(Downloading from http://www.robots) step?
It have spend me all days to deal with this..Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.