Here’s a quick setup-guide for using custom Core ML models into your iOS project.
If you haven’t set up the SDK yet, make sure to go through those directions first. You’ll need to add the Core library to the app before using the specific feature or custom model libraries.
For the purpose of this guide, let’s assume you have the following:
- A Core ML model file called Digits.mlmodel that recognizes the numbers 0-9 in an image.
- You have dragged this model into Xcode and can access the model
let model = Digits()in your code.
- Your Fritz api key is
- Your Fritz model id for the Digits model is
1. Conform Your Model
In order to expose Fritz functionality to your Xcode generated Digits class, you must conform that class to a Fritz protocol that tells the SDK the about your api key and model id for that model.
2. Update Model Usage
By conforming the Digits class to the Fritz protocol we have exposed a
.fritz()function which injects an instrumented MLModel into the instance of that class.
All of your
predictioncalls stay the same and they will be instrumented by the SDK.
3. Build and run your app
Test out each part of your app that uses the prediction, then look at the Fritz dashboard to see if data is showing up.