I am new to CoreML, and am having difficulties with turning a MLMultiArray
(named modelInput
) into the required type MLFeatureProvider
to feed as a parameter when using myMLModel.prediction(from: modelInput)
. The error reads:
Argument type 'MLMultiArray' does not conform to expected type 'MLFeatureProvider'
From what I've read, I believe I have to create a class that subclasses 'MLFeatureProvider' that allows me to initialize modelInput
as an 'MLFeatureProvider'. But I'm stuck on how to do this.
Are these files generated by Xcode, as suggested by this article? Or must I create these on my own?
Any input is appreciated.
//function inside of Predictor class
func makePrediction(){
let model: MLModel = configureModel(url: url)
let poseMultiArrays = [MLMultiArray] = getPoseMultiArrays()
let modelInput = MLMultiArray(concatenating: poseMultiArrays, axis: 0, dataType: .float)
//Perform prediction
var prediction: MLFeatureProvider?
do{
prediction = try? model.prediction(from: modelInput) //< The error occurs here
}catch{print(error)}
}