Using the TensorFlow Lite model on iOS [Machine learning]
TensorflowLite is the machine learning model format for mobile.
It would be convenient if the tflite model could be used on iOS.
add TensorFlowLite with CocoaPods, and
Interpreter will initialize the model, create an input tensor from the image, infer, and do it with class methods.
Import TensorFlow Lite
Add TensorFlowLitePod (pod install) with CocoaPod.
Drop and bundle your TensorFlowLite model into your Xcode project.
If you use labels, drop the label file and bundle it as well.
Also read the class label as an array of Strings.
Preparing for input
Enter the CVPixelBuffer that matches the input format of the model.
Set to kCMPixelFormat_32BGRA format to use the PixelBuffer conversion method of the official TensorFlow esample project.
Crop the PixelBuffer into a square.
Set PixelBuffer to 3 channels (with VImage). A quote from the official TensorFlow example project.
Extension for the above method
If the output is uInt8, fix it to Float.
The result is an array of Float.
In the case of image recognition this time, it is returned as the reliability of all class labels.
For example, for a 1000 class, there are 1000 Floats.
I am making an app that uses Core ML and ARKit.
We send machine learning / AR related information.
Thank you very much.