Re-importing mlmodel in CreateML

389 Views Asked by At

I'm testing the new awesome CreateML in an XCode playground. I used the MLImageClassifierBuilder() with the live view feature to create my model, and saved it. Now I would like to re-import my .mlmodel file into my playground to run some more tests, but I didn't found a way to do it.

This seemed obvious to me to find this capability when I closed my playground.

1

There are 1 best solutions below

0
On

You can't continue training the same mlmodel. However, you can load the existing mlmodel and use it via the MLModel API, like so:

let compiledUrl = try MLModel.compileModel(at: modelUrl)
let model = try MLModel(contentsOf: compiledUrl)
model.prediction(....)

Never tried it myself, so I'm not 100% sure this works from a playground.