Creates a Core ML model object from a compiled model file.
SDKs
- iOS 11.0+
- macOS 10.13+
- Mac Catalyst 13.0+
- tvOS 11.0+
- watchOS 4.0+
Framework
- Core ML
Declaration
convenience init(contentsOf url: URL) throws
Parameters
contentsOf
The path to a compiled model file (ModelName
.mlmodelc
), typically with theURL
returned fromcompile
.Model(at:)
Discussion
In most cases your app won't need to create a model object directly. First consider using the wrapper class that Xcode generates automatically, as described in Add a Model to Your Xcode Project.
However, if the wrapper class doesn't meet your app's needs, then use this initializer to create a model object from any compiled model file your app has access to. 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.