How to use CoreML model output MLMultiArray
MultiArray is not a built-in datatype. Use the variable name:
var result: MLMultiArray //Your populated array
let a = result[[z, y, x] as [NSNumber]].floatValue
Also you might want to check out Swiftier MultiArray. Follow the CoreMLHelpers install instructions.
EDIT:
MLMultiArray
is part of the CoreML
framework. To use it, you must import the framework like this:
import CoreML
How to create CoreML MLMultiArray for a 4D data for prediction on iOS with Swift?
If you're going to use a Float
array to initialize the MLMultiArray, it needs be a 1-dimensional array. This means you need to "flatten" your 4D data into a 1D array first.
(This is why MLMultiArray has a strides
property. You need to use these strides to calculate the position of each element in the flattened array.)
Dealing with MLMultiArray from MLModel
The number 1917 tells me you're most likely using MobileNet + SSD.
I wrote a number of blog posts that explain how this sort of thing works. Here is a blog post that explains how to do the decoding for MobileNetV2+SSDLite, but the same logic works for other versions of MobileNet and SSD as well: https://machinethink.net/blog/mobilenet-ssdlite-coreml/
Related Topics
Swift: How to Fix Infinite Loop When Adding a Value to a Firebase Variable
Why Upload Alamofire Background Request Don't Executes in Background
How to Make a Custom Mkannotationview with Xib
Hide View Item of Nsstackview with Animation
Swiftui - Show the Data Fetched from Firebase in View
Crash When Running on Device After Second Launch
Tvos Textfield Transparent Background
Swift: Generic Overloads, Definition of "More Specialized"
Characters Is Unavailable' Please Use String Directly
Scenekit Shape Between 4 Points
Why Do Two Distinct Array Literals Equal Each Other in Swift
How to Wait for Http Requests to Finish
Swift Realm: After Writing Transaction Reference Set to Nil
Swift 5, How to Execute Code After Fetching All Childadded from Firebase
Play Segment of Avaudiopcmbuffer
Googlesignin - Always Return "The User Canceled the Sign-In Flow." in iOS 11