This contains an ocaml implementation of Neural Style transfer using a VGG-19 convolutional network.
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
.
Original image
Style
Result
Original image
Style
Result
Original image
Style
Result