init(contentsOf:configuration:)
Creates a Core ML model instance from a compiled model file and a custom configuration.
Declaration
convenience init(contentsOf url: URL, configuration: MLModelConfiguration) throwsParameters
- url:
The path to a compiled model file (ModelName
.mlmodelc), typically with theURLthat Compilemodel(at:) 6442s returns. - configuration:
The runtime settings for the new model instance.
Discussion
In most cases, your app won’t need to create a model object directly. Consider the programmer-friendly wrapper class that Xcode automatically generates when you add a model to your project (see Integrating a Core ML Model into Your App).
If the wrapper class doesn’t meet your app’s needs or you need to customize the model’s configuration, use this initializer to create a model object from any compiled model file you can access. Typically, you use this initializer after your app has downloaded and compiled a model, which is one technique for saving space in your app (see Downloading and Compiling a Model on the User’s Device).