This is the procedure for introducing the unique model trained in Create ML App into the app.
macOS 10.15.7 Xcode 12.1 Swift 5.3
This is done in the Create ML App. I created a model to identify Tomica (minicar toy).
The .mlmodel format model file exported from Create ML App can be incorporated into Xcode by simply dragging and dropping it. At the same time, the code that defines the classes for the ML model is automatically generated.
Some of the code at the time the CoreML framework was announced has been deprecated. You can now create an instance with the following code:
Create an instance of the model
let modelURL = Bundle.main.url(forResource: "MyTomicaClassifier", withExtension: "mlmodelc")!
let tomicaClassifier = try! VNCoreMLModel(for: MLModel(contentsOf: modelURL))