Continuously train CoreML model after shipping

前端 未结 7 844
梦毁少年i
梦毁少年i 2020-12-28 08:51

In looking over the new CoreML API, I don\'t see any way to continue training the model after generating the .mlmodel and bundling it in your app. This makes me think that I

7条回答
  •  温柔的废话
    2020-12-28 09:14

    As alternative to bundling an mlmodel with application, you can download and then compile models within your CoreML app. For this you just need to download the model definition file onto the user’s device by using, for example, URLSession. And after this you have to compile the model definition by calling a throwing compileModel(at:) type method.

    let newCompiledModel = try MLModel.compileModel(at: modelDescriptionURL)
    

    You'll get a new compiled model file with the same name as the model description but its ending will be mlmodelc. Eventually, create a new MLModel instance by passing the compiled model URL to its initialiser.

    let model = try MLModel(contentsOf: newCompiledModel)
    

    However, remember that compiling process may be time consuming and it shouldn't be done on main thread.

提交回复
热议问题