We have a few models that we want to run on iOS using CoreML. Currently the models are in ONNX format using OnnxRuntime to perform inference. We'd like to convert the models and perform inference on the Neural Engine chip.
Deliverable should be:
1. Any scripts required to convert the model to CoreML format
2. Convert a sample program to run the models on iOS using CoreML for inference.
3. A sample iOS program that can simply press a button to load a JPEG image and run it through the inference code and output the processing time in milliseconds.
You will be needed to know neural network models (pytorch, onnx, etc)
I'll prep a c++ package for you with some instructions. This will be our inference on c++. The goal is to convert the model to coreml and swap out the OCR code for obj c so that it can run on the I using the neural engine chip
Here's a sample OCR C++ inference example. To set it up:
1. Download a prebuilt OnnxRuntime package.
2. Update your [login to view URL] to point to your OnnxRuntime lib and header path:
SET(ONNXRUNTIME_LIBS
/storage/projects/alpr/libraries/libonnxruntime/build/Linux/Release/libonnxruntime.so.1.4.0
)
SET(ONNXRUNTIME_INCLUDE
/storage/projects/alpr/libraries/libonnxruntime/include/
)
3. Update [login to view URL] to point to your "runtime" folder full path:
std::string ocr_root = "/home/mhill/Downloads/ocr_test/runtime";
4. Install OpenCV to your system. cmake should find it automatically
5. From the root directory, to build:
mkdir build/
cd build/
cmake ..
make -j8
6. To run:
./ocr_test ../[login to view URL]
Expected output:
Processing: ../[login to view URL]
Processing time (1 crops): 0.10924
Region: za-ec : 99.9968
: 0 - F - 94.9996
: 1 - F - 94.9988
: 2 - N - 94.9996
: 3 - 2 - 94.9996
: 4 - 0 - 94.9996
: 5 - 6 - 94.9994
: 6 - E - 94.9996
: 7 - C - 94.9996
If you make your changes in a new file (e.g., [login to view URL]) and make sure it's API compatible with ocr.h, we should be able to swap it in when IOS is used.
Once we get this working on iPhone we can send over a sample for the next two models
Please send us an update at least every 2nd day (what you're working on currently, if you're stuck on anything, and if there's any decisions that need to be made)
The ocr_x file is ONNX
Attaching pytorch model as well. We'd prefer to convert from Onnx, but can convert from Pytorch to if necessary
Files:
[login to view URL]
[login to view URL]