I'm currently building a new app and trying to integrate a Core ML model with Vision to my app... unfortunately, Xcode shows me this message: Cannot convert value of type 'MobileNetV2' to expected argument type 'VNCoreMLModel'
How may I solve this?
Here's my code below:
let config = MLModelConfiguration()
guard let coreMLModel = try? MobileNetV2(configuration: config),
let visionModel = try? VNCoreMLModel(for: coreMLModel.model) else {
fatalError("Couldn't load model!")
}
let classificationRequest = VNCoreMLRequest(model: coreMLModel, completionHandler: classificationCompleteHandler)
classificationRequest.imageCropAndScaleOption = VNImageCropAndScaleOption.centerCrop
visionRequests = [classificationRequest]
loopCoreMLUpdate()
}
This line shouldn't use coreMLModel
but visionModel
:
let classificationRequest = VNCoreMLRequest(model: coreMLModel, completionHandler: classificationCompleteHandler)