Skip to content

Latest commit

 

History

History

neural-style

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

This contains an ocaml implementation of Neural Style transfer using a VGG-19 convolutional network.

Installation

Use opam to install the tensorflow-ocaml package and the other necessary packages.

opam install cmdliner npy stb_image stb_image_write tensorflow

Install the TensorFlow library by following these instructions.

Compile neural_style.ml and the following command:

ocamlbuild neural_style.native -pkg tensorflow -pkg cmdliner -pkg npy -pkg stb_image -pkg stb_image_write -use-ocamlfind -tag thread

Download the pre-trained weights for the VGG-19 network.

You can then run the executable neural_style.native. Depending on the input, the loss function may be tuned using the following command line arguments --content-weight, --style-weight, and --tv-weight.

Example 1: Starry Brooklyn

Original image

#Brooklyn

Style

#Starry

Result

#Starry Brooklyn

Example 2: Cubist New-York

Original image

#New-York

Style

#Cubist

Result

#Cubist New-York

Example 3: Eschery London

Original image

#Lond

Style

#Escher

Result

#Eschery London