无法将类型 'MobileNetV2' 的值转换为预期的参数类型 'VNCoreMLModel'
Cannot convert value of type 'MobileNetV2' to expected argument type 'VNCoreMLModel'
我目前正在构建一个新的应用程序,并尝试将 Core ML 模型与 Vision 集成到我的应用程序中...不幸的是,Xcode 向我显示了这条消息:无法转换 [=19= 类型的值] 到预期的参数类型 'VNCoreMLModel'
我该如何解决这个问题?
下面是我的代码:
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()
}
这一行不应该使用 coreMLModel
但 visionModel
:
let classificationRequest = VNCoreMLRequest(model: coreMLModel, completionHandler: classificationCompleteHandler)
我目前正在构建一个新的应用程序,并尝试将 Core ML 模型与 Vision 集成到我的应用程序中...不幸的是,Xcode 向我显示了这条消息:无法转换 [=19= 类型的值] 到预期的参数类型 'VNCoreMLModel'
我该如何解决这个问题?
下面是我的代码:
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()
}
这一行不应该使用 coreMLModel
但 visionModel
:
let classificationRequest = VNCoreMLRequest(model: coreMLModel, completionHandler: classificationCompleteHandler)