Slide 50
Slide 50 text
ML Kit - Custom Local Model
guard let localModelFilePath = Bundle.main.path(
forResource: Constants.quantizedModelFilename,
ofType: DetectorConstants.modelExtension
),
let labelsFilePath = Bundle.main.path(
forResource: Constants.quantizedLabelsFilename,
ofType: DetectorConstants.labelsExtension
)
else {
resultsTextView.text = "Failed to get the paths to the local model and labels files."
return
}
let localModelSource = LocalModelSource(
modelName: Constants.localModelName,
path: localModelFilePath
)
let modelManager = ModelManager.modelManager()
if !modelManager.register(localModelSource) {
print("Model source was already registered with name: \(localModelSource.modelName).")
}
let options = ModelOptions(cloudModelName: nil, localModelName: Constants.localModelName)
detectorService.loadModel(options: options, labelsPath: labelsFilePath)