• Stars
    star
    546
  • Rank 80,864 (Top 2 %)
  • Language
    Python
  • Created almost 9 years ago
  • Updated almost 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

"A neural algorithm of Artistic style" in tensorflow

"Neural Art" in TensorFlow

An implementation of "A neural algorithm of Artistic style" in TensorFlow, for

  • Introductory, hackable demos for TensorFlow, and
  • Demonstrating the use of importing various Caffe cnn models (VGG and illustration2vec) in TF.

In this work, I put effort in putting the code simple as possible, for being a good introductory code to TF. For this reason, I also implemented very basic uses of TensorBoard (the visualizer). I also aimed on demonstrating the use of importing various Caffe models from *.caffemodel files into TensorFlow, especially models that seemed not to be imported by anybody yet in TF (as far as I know). Based on https://github.com/ethereon/caffe-tensorflow, I modified the importer so that it can import illustration2vec (http://illustration2vec.net/), which is another CNN available as a Caffe model. Using different CNNs yields different results, which reflects the characteristics of the model.

In the Neural Art problem setting, the weights of the CNN are fixed, and the input image into the CNN is the only "trainable" variable, making the code easy to understand (the optimized/trained image is the output image). I hope this example serves as a good introduction to TensorFlow as well as for entertainment purposes.

(VGG, default settings, 70 iterations)

(illustration2vec, width=500, beta=10000, 100 iterations)

##Usage

Step 0: Prepare the Caffe model

First, download either the VGG model or the illustration2vec model (*.caffemodel), along with the prototxt (*.prototxt):

Then, convert the model to a binary format recognizable to TensorFlow:

python ./kaffe/kaffe.py [path.prototxt] [path.caffemodel] [output-path]

Note that Caffe is not required for conversion.

The converter included in this repo (all code inside ./kaffe) is a modified version of (an old version of) https://github.com/ethereon/caffe-tensorflow . The converter is modified to be capable of handling the illusration2vec neural network. Since the newer version of the converter requires preprocessing with the Caffe framework for old-format Caffe models (at the time of writing), I have included the converter which is based on the older code, which is capable of handling old-format Caffe models.

Step 1: Neural Art

python neural-art-tf.py

Running neural-art-tf.py without options yields the default settings and input images. Available options are:

  • -m, --model: Model type - Use vgg or i2v
  • -mp, --modelpath: Model file path - The path to the converted Caffe model in Step 0
  • -c, --content: Content image path
  • -s, --style: Style image path
  • -w, --width: Output image width
  • -i, --iters: Number of iterations
  • -a, --alpha: alpha (content weight)
  • -b, --beta: beta (style weight)

For example:

python neural-art-tf.py -m vgg -mp ./vgg -c ./images/sd.jpg -s ./images/style.jpg -w 800

You can view the progress on tensorboard by running

tensorboard --logdir=/tmp/na-logs

References

More Repositories

1

lambda-8cc

x86 C compiler written in untyped lambda calculus
Common Lisp
616
star
2

lisp-in-life

A Lisp interpreter implemented in Conway's Game of Life
C
448
star
3

lambdalisp

A Lisp interpreter written in untyped lambda calculus
Common Lisp
226
star
4

lambdavm

A programmable virtual CPU written in untyped lambda calculus
Common Lisp
46
star
5

sectorlisp-nn

A neural network written in pure Lisp without built-in numbers
Common Lisp
32
star
6

lambdacraft

Common Lisp DSL for building untyped lambda calculus expressions
Common Lisp
23
star
7

py2hy

A Python to Hy (https://github.com/hylang/hy) compiler
Hy
22
star
8

sectorlisp-examples

Example programs written for SectorLISP
Common Lisp
19
star
9

lambda-calculus-devkit

A collection of lambda calculus interpreters and development tools
Makefile
14
star
10

numsectorlisp

Fixed-point scalar and matrix multiplication library for SectorLISP
Common Lisp
12
star
11

vgg-visualizer-tf

VGG feature visualizer in TensorFlow
Python
11
star
12

sectorlisp-ref-in-bf

SectorLISP C reference implementation in BF
Brainfuck
5
star
13

CriticalHit

A damage calculator for competitive Pokemon / ็ซถๆŠ€ใƒใ‚ฑใƒขใƒณใฎ็‚บใฎใƒ€ใƒกใƒผใ‚ธ่จˆ็ฎ—ใƒ„ใƒผใƒซ
JavaScript
4
star
14

growth

Yet Another obuscated MATLAB code.
MATLAB
4
star
15

grassvm

A programmable virtual CPU for the Grass programming language
OpenEdge ABL
3
star
16

MATLABvargraph

MATLAB variable dependency analyzer (beta)
Python
2
star
17

TeXReport

Simple template/shellscript for TeX reports/articles based on Make.
Shell
2
star
18

ensemble

A service to fInd some time for your music experience.
CSS
1
star
19

gridfigure

Automatically makes MATLAB figure windows appear organized in grid style & Command to organize figures
MATLAB
1
star