# Neural style transfer in processing

**URL:** https://discourse.processing.org/t/neural-style-transfer-in-processing/3497
**Category:** Libraries
**Created:** [September 12, 2018, 11:33pm UTC](https://discourse.processing.org/t/neural-style-transfer-in-processing/3497 "2018-09-12T23:33:25Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![molo32](https://avatars.discourse-cdn.com/v4/letter/m/a87d85/32.png) [@molo32](https://discourse.processing.org/u/molo32)
#### Post date: [September 12, 2018, 11:33pm UTC](https://discourse.processing.org/t/neural-style-transfer-in-processing/3497/1 "2018-09-12T23:33:25Z")

</div>

Does anyone know if it can be done in processing or are there similar examples?

---

<div class="post-metadata">

### Author: ![Kevin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kevin/32/2297_2.png) [@Kevin](https://discourse.processing.org/u/Kevin)
#### Post date: [September 13, 2018, 3:00am UTC](https://discourse.processing.org/t/neural-style-transfer-in-processing/3497/2 "2018-09-13T03:00:34Z")

</div>

Sure, it can be done. But this is not exactly a trivial task. What do you have so far?

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [September 15, 2018, 12:23am UTC](https://discourse.processing.org/t/neural-style-transfer-in-processing/3497/3 "2018-09-15T00:23:43Z")

</div>

Here are some pointers for getting started with Processing and neural style transfer. (I am not an expert):

### perspective

An interesting overview from Hannu Töyrylä on switching from using Processing to neural style transfer, then re-incorporating it into a Processing workflow.

> **[Neural networks, style transfer and artistic process – Erratic Explorations](https://liipetti.net/erratic/2016/12/11/neural-networks-style-transfer-and-artistic-process/)**

…more related posts:

> **[neural networks – Erratic Explorations](https://liipetti.net/erratic/category/neural-networks/)**

### try it out

If you are looking to try out a working sketch in Processing, Bryan Chung of Magic & Love has [a neural style blog post](http://www.magicandlove.com/blog/2018/08/27/neural-network-style-transfer-in-opencv-with-processing/) with results from a Processing (Java) sketch that applies pre-trained Torch models to live video.

The Processing sketch is here:

> <https://github.com/chungbwc/Magicandlove/blob/master/ml20180827a/ml20180827a.pde>

I believe Bryan gets the models from Johnson et al’s “fast-neural-style” feed-forward neural transfer system. That code (and a model download script) is here:

> **[GitHub - jcjohnson/fast-neural-style: Feedforward style transfer](https://github.com/jcjohnson/fast-neural-style)**
>
> Feedforward style transfer

…specifically, I think the sketch needs the resource “composition\_vii.t7”, which is available here:

> <https://github.com/jcjohnson/fast-neural-style/blob/master/models/download_style_transfer_models.sh>

### implement a full system

If you are interested in doing it end-to-end in Processing(Java), one way might be to incorporate dl4j. They have a neural style transfer example in their examples list, and you could try include the library and the example class in a Processing sketch and then calling it.

> <https://github.com/klevis/dl4j-examples/blob/master/dl4j-examples/src/main/java/org/deeplearning4j/examples/styletransfer/NeuralStyleTransfer.java>

There is a related dl4j Java tutorial here:

[https://dzone.com/articles/java-art-generation-with-neural-style-transfer](https://dzone.com/articles/java-art-generation-with-neural-style-transfer)

Note that another route is using TensorFlow.

### do it with python

If you are thinking about Python rather than Java,

There is an introductory walkthrough in Python here, there is a great step-by-step tutorial walkthrough here:

[https://medium.com/artists-and-machine-intelligence/neural-artistic-style-transfer-a-comprehensive-look-f54d8649c199](https://medium.com/artists-and-machine-intelligence/neural-artistic-style-transfer-a-comprehensive-look-f54d8649c199)

…so you could walk through the example in Python 3 and then use p5py to incorporate it into a Processing-like API.

> Note this requires p5py, as the examples are written in Python 3 and more importantly use PyTorch, which I believe is not compatible with Processing.py (Python mode) even in older 2.7-compatible versions due to the reliance on CPython.
