We want to use animation conversion on iPhone — — How to convert AnimeGAN2 to CoreML

How to convert AnimeGAN2-pytorch to a format that can be used on iPhone

Make AnimeGAN2, an anime conversion machine learning model, available in the iPhone app.

If you just want converted CoreML model:

AnimeGAN is cool, but Python. .. ..

To use the Python model in our application, uploading an image to the server and processing it seems to be little bit complex.

If we convert to CoreML, we can use the model on iPhone

With CoreML format, we can easily incorporate AnimeGAN into our iPhone app.

procedure

Load the model from Torch-Hub.

Convert the model.

The output shape of the model is [1,3,512,512].
Since the dimension with only the first dimension is unnecessary and
we want to make the shape [3,512,512] for image output,
add a layer to reduce the first dimension.

Since the model input is normalized to the range -1 to 1
, add an activation layer that returns to a value in the range 0 to 255.

Explicitly specify the output name of the activation layer in the output name of the model.
Otherwise, the output of the model will remain output from the original var_444 layer, which is a necessary step.

Specify an image as the output type of the model.

Save the model.

How to use on iOS

Execute the request in Vision.

Conversion Colab is here:

🐣

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

--

--

--

Freelance iOS developer. You can ask me for a job from any country. rockyshikoku@gmail.com https://github.com/john-rocky https://twitter.com/JackdeS11

Love podcasts or audiobooks? Learn on the go with our new app.

How to Take UI Debugging to the Next Level With LLDB

AppStorage — save array

Higher-Order Functions in Swift

Introducing Swift’s New Modern Date Picker

Accessibility on Apple’s platforms

If you want to filter existing videos, you should process them one by one.

Making a Complex UICollectionViewLayout With Self Sizing Cells (Part 2)

An Introduction to Core Data, Part 1

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
MLBoy

MLBoy

Freelance iOS developer. You can ask me for a job from any country. rockyshikoku@gmail.com https://github.com/john-rocky https://twitter.com/JackdeS11

More from Medium

How to create a model based on Emotion Recognition using the LiDAR sensor behind FaceID

Check UITableViewCell currently exists before tableview reloadRows刷新Cell前檢查Cell當下元件是否已生成

Split mirror photo effect for iOS

Thirty Days of Metal — Day 23: Interaction