Input shape of my tflite model - (18, 63) or 1134 numbers.
I get the data itself in objective-c code, and then I send it to swift code and an error already occurs there. In detail I do the following
- Receive the data in NSMutableArray. The length of the array is 1134 NSNumber
- Converting NSMutableArray to NSData
NSData *d = [NSKeyedArchiver archivedDataWithRootObject:_data];
NSLog(@"output: %@", d);
// output: {length = 18181, bytes = 0x62706c69 73743030 d4000100 02000300 ... 00000000 000034fd }
- I send data to the swift code.
Swift code:
@objc public func predict(_ data: NSData) {
guard
let modelPath = Bundle.main.path(forResource: "model", ofType: "tflite")
else {
return
}
do {
let interpreter = try Interpreter(modelPath: modelPath)
try interpreter.allocateTensors()
let inputData: Data = data as Data
try interpreter.copy(inputData, toInputAt: 0) // <-- an error occurs in this line
try interpreter.invoke()
let outputTensor = try interpreter.output(at: 0)
} catch {
print(error)
}
}
- I get an error in the above line of code. Error:
Provided data count 18181 must match the required count 4536.
H