0

I converted an ONNX model to mlmodel and I'm unable to use the prediction function. here is my model's input and output: [enter image description here][1] [1]: https://i.stack.imgur.com/6mY4H.png

i'm initializing the model and the input like this:

var model: dont_touch_model! 
var modelInputVector = try! MLMultiArray(shape: [1,1,13], dataType: MLMultiArrayDataType.float32)

I fill the vector with motion data like this:

modelInputVector[[0, 0, 0] as [NSNumber]] = deviceMotion.userAcceleration.x as NSNumber
modelInputVector[[0, 0, 1] as [NSNumber]] = deviceMotion.userAcceleration.y as NSNumber
modelInputVector[[0, 0, 2] as [NSNumber]] = deviceMotion.userAcceleration.z as NSNumber

I try to execute a prediction:

let modelInput = dont_touch_modelInput(sequenceinput: modelInputVector)
var modelOutput = try! model.prediction(input: modelInput)

and I get this error message:

"Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value"

can someone please help?

Yarden
  • 11
  • 3

0 Answers0