StyleCoreML conversion that enables Fast-Neural-Style-Transfer to be used on iOS and MacOS

MLBoy
3 min readFeb 25, 2022

How to use Fast-Neural-Style-Transfer on iOS

Converted Model:

Conversion Script:

Let’s make a style conversion app

Fast-Neural-Style-Transfer is a model that can convert the style of painting.
If you use it on iOS, you can create a style conversion application for images and videos.

Convert to CoreML and use on iOS and MacOS devices

Method

Clone the repository and download the pre-trained weights from the repository link.

Restore the model from pre-trained weights.

Convert.

Since the model inputs are normalized, the CoreML inputs are set to be preprocessed as well.

Create a Neural Network Builder from your model and check the output name.

To make the output of the model an RGB image, the output must also be denormalized for preprocessing.

Split tensor into color channels.
For each color channel, activate the tensor in reverse of the preprocessing and add a layer to recombine.
var_293 is the output name of the original model.

Set the output to an RGB image.

Run in Swift

🐣

I’m a freelance engineer.
Work consultation
Please feel free to contact us with a brief development description.
rockyshikoku@gmail.com

I am making an app that uses Core ML and ARKit.
We send machine learning / AR related information.

GitHub

Twitter
Medium

--

--