xunhuang1995 / AdaIN-style

Arbitrary Style Transfer in Real-time with Adaptive Instance Normalization

Home Page:https://arxiv.org/abs/1703.06868

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AdaIN-style iOS App

ArtlyStyles opened this issue · comments

Hey, I'm looking into doing something of that effect for a project. Did you convert the t7 to mlmodels or did you go directly with torch-ios?

commented

I extracted the raw weights/bias from the model and save them as binary file without any format/header etc to save space.

Ok, do you use a library to use that binary in the app or do you do that manually?

commented

Everything is kind of "manual". I used some of the Metal Performance Shader layers, as documented in this page https://developer.apple.com/documentation/metalperformanceshaders. But MPS does not have all the layers needed for AdaIN. So I implemented some myself using Metal Shading Language (https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf#//apple_ref/doc/uid/TP40014364) for the GPU on iPhone. I had to debug line-by-line to make sure my layer produced the same result as Torch.

Apple later released CoreML. But it seems CoreML still does not have all the layers needed for the Fast Neural Style (Stanford version and my app "Artly") and AdaIn.

If you want to programming MPS and have questions, I can definitely help you.

Thank you that was very helpful!
I am a newbie in ML and never used MPS but I'll look into all that. I am very impressed by your application!