How to use coremltools from Apple ?

CoreMLTools are a great set of tools to make use of any neural network in Cocoa Frameworks (iOS, macOS, tvOS, watchOS). It allows you to convert your well trained (or well searched on google) neural network to a format that Apple OSs (Oses? Oss?) will understand, but most of all, will exploit lightning fast on Apple devices.

I have struggled a lot to make this works, not because coremltools is hard to use, but because python on macOS is a mess.

So long story short, here is the solution : You need to create a virtual env with Python2.7 on macOS running the right version of everything, to make coremltools actually works.

But here is the tips : nothing will work if you have a space in any folder that relates to your python file. It means that all the path to your working directory (where you do your coremltools stuff) must be “space” free.

Then launch your tool !

Since you have that virtual env the cool part is that your global python configuration is not affected, and you basically do what you want in the bash sinc you are in this env. To exit just tap deactivate in the env context to leave.

Xcode 9 issue

You can have a issue with Xcode that ignore your core ml model at compile time. I have discussed it with some Apple engineers, and it comes that is a bug in XCode. So the only way is to create another project and to prey.

It will probably be fixed anytime soon, since XCode 9 is in beta.