You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/learning-paths/mobile-graphics-and-gaming/onnx/01_Fundamentals.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,9 @@ weight: 2
6
6
7
7
layout: "learningpathall"
8
8
---
9
-
The goal of this tutorial is to provide developers with a practical, end-to-end pathway for working with Open Neural Network Exchange (ONNX) in real-world scenarios. Starting from the fundamentals, we will build a simple neural network model in Python, export it to the ONNX format, and demonstrate how it can be used for both inference and training on Arm64 platforms. Along the way, we will cover model optimization techniques such as layer fusion, and conclude by deploying the optimized model into a fully functional Android application. By following this series, you will gain not only a solid understanding of ONNX’s philosophy and ecosystem but also the hands-on skills required to integrate ONNX into your own projects—from prototyping to deployment.
9
+
The goal of this tutorial is to provide developers with a practical, end-to-end pathway for working with Open Neural Network Exchange (ONNX) in real-world scenarios. Starting from the fundamentals, we will build a simple neural network model in Python, export it to the ONNX format, and demonstrate how it can be used for both inference and training on Arm64 platforms. Along the way, we will cover model optimization techniques such as layer fusion, and conclude by deploying the optimized model into a fully functional Android application. By following this series, you will gain not only a solid understanding of ONNX’s philosophy and ecosystem but also the hands-on skills required to integrate ONNX into your own projectsfrom prototyping to deployment.
10
10
11
-
In this first step, we will introduce the ONNX standard and explain why it has become a cornerstone of modern machine learning workflows. You will learn what ONNX is, how it represents models in a framework-agnostic format, and why this matters for developers targeting different platforms such as desktops, Arm64 devices, or mobile environments. We will also discuss the role of ONNX Runtime as the high-performance engine that brings these models to life, enabling efficient inference and even training across CPUs, GPUs, and specialized accelerators. Finally, we will outline the typical ONNX workflow—from training in frameworks like PyTorch or TensorFlow, through export and optimization, to deployment on edge and Android devices—which we will gradually demonstrate throughout the tutorial.
11
+
In this first step, we will introduce the ONNX standard and explain why it has become a cornerstone of modern machine learning workflows. You will learn what ONNX is, how it represents models in a framework-agnostic format, and why this matters for developers targeting different platforms such as desktops, Arm64 devices, or mobile environments. We will also discuss the role of ONNX Runtime as the high-performance engine that brings these models to life, enabling efficient inference and even training across CPUs, GPUs, and specialized accelerators. Finally, we will outline the typical ONNX workflow, from training in frameworks like PyTorch or TensorFlow, through export and optimization, to deployment on edge and Android devices, which we will gradually demonstrate throughout the tutorial.
12
12
13
13
## What is ONNX
14
14
The ONNX is an open standard for representing machine learning models in a framework-independent format. Instead of being tied to the internal model representation of a specific framework—such as PyTorch, TensorFlow, or scikit-learn—ONNX provides a universal way to describe models using a common set of operators, data types, and computational graphs.
@@ -17,7 +17,7 @@ At its core, an ONNX model is a directed acyclic graph (DAG) where nodes represe
17
17
18
18
ONNX was originally developed by Microsoft and Facebook to address a growing need in the machine learning community: the ability to move models seamlessly between training environments and deployment targets. Today, it is supported by a wide ecosystem of contributors and hardware vendors, making it the de facto choice for interoperability and cross-platform deployment.
19
19
20
-
For developers, this means flexibility: you can train your model in PyTorch, export it to ONNX, run it with ONNX Runtime on an Arm64 device such as a Raspberry Pi, and later deploy it inside an Android application without rewriting the model. This portability is the main reason ONNX has become a central building block in modern AI workflows.
20
+
For developers, this means flexibility. You can train your model in PyTorch, export it to ONNX, run it with ONNX Runtime on an Arm64 device such as a Raspberry Pi, and later deploy it inside an Android application without rewriting the model. This portability is the main reason ONNX has become a central building block in modern AI workflows.
21
21
22
22
A useful way to think of ONNX is to compare it to a PDF for machine learning models. Just as a PDF file ensures that a document looks the same regardless of whether you open it in Adobe Reader, Preview on macOS, or a web browser, ONNX ensures that a machine learning model behaves consistently whether you run it on a server GPU, a Raspberry Pi, or an Android phone. It is this “write once, run anywhere” principle that makes ONNX especially powerful for developers working across diverse hardware platforms.
Copy file name to clipboardExpand all lines: content/learning-paths/mobile-graphics-and-gaming/onnx/03_PreparingData.md
+1-2Lines changed: 1 addition & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,6 @@ By generating synthetic Sudoku pages directly from the parquet dataset, we get:
23
23
4. Scalability. With millions of Sudoku solutions available, we can easily generate tens of thousands of training samples in minutes, ensuring a dataset that is both large and diverse.
24
24
25
25
This synthetic data generation strategy allows us to create a custom-fit dataset for our Sudoku digit recognition problem, bridging the gap between clean digital puzzles and noisy real-world inputs.
26
-
In this Learning Path, you have created an Android application to capture and process camera images using OpenCV.
27
26
28
27
## What we’ll produce
29
28
By the end of this step, you will have two complementary datasets:
Copy file name to clipboardExpand all lines: content/learning-paths/mobile-graphics-and-gaming/onnx/04_Training.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -192,7 +192,7 @@ Right after export, the script runs a parity test: it feeds the same randomly ge
192
192
To run the training script, type:
193
193
194
194
```console
195
-
python 03_Training.py
195
+
python3 03_Training.py
196
196
```
197
197
198
198
The script will train, validate, export, and verify the digit recognizer in one go. After it finishes, you’ll have both a portable ONNX model and a PyTorch checkpoint ready for the next step—building the image processor that detects the Sudoku grid, rectifies it, segments cells, and performs batched ONNX inference to reconstruct the board for solving.
Copy file name to clipboardExpand all lines: content/learning-paths/mobile-graphics-and-gaming/onnx/06_SudokuProcessor.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -375,6 +375,8 @@ The processor saves several artifacts to help debugging and demonstration:
375
375
-`artifacts/overlay_solution.png` – solution digits overlaid onto the original image (if solved).
376
376
- (Optional) `artifacts/recognized_board.png`, `artifacts/solved_board.png`, `artifacts/boards_side_by_side.png` – clean board renderings if you enabled those helpers.
377
377
378
+
The driver script below saves warped.png and overlay_solution.png by default.
379
+
378
380
## Running the processor
379
381
A small driver script (05_RunSudokuProcessor.py) demonstrates how to use the SudokuProcessor:
Copy file name to clipboardExpand all lines: content/learning-paths/mobile-graphics-and-gaming/onnx/07_Optimisation.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,7 @@ To quantify these contributions, we will add simple timing measurements around e
21
21
* preprocess_ms – total time spent preprocessing all 81 cells
22
22
* onnx_ms – time spent running batched ONNX inference
23
23
* solve_ms – time spent solving the Sudoku
24
+
* split_ms – time spent splitting the warped grid into 81 cells
24
25
* total_ms – end-to-end processing time
25
26
26
27
## Performance measurements
@@ -195,7 +196,7 @@ The single-image measurements introduced earlier are useful for understanding th
195
196
196
197
To obtain more reliable performance numbers, we extend the evaluation to multiple images and compute aggregated statistics. This allows us to track not only average performance, but also variability and tail latency, which are particularly important for interactive applications.
197
198
198
-
To do this, we add two helper functions to 05_RunSudokuProcessor.py.
199
+
To do this, we add two helper functions to 05_RunSudokuProcessor.py, and make sure you have import glob and import numpy as np at the top of the runner script.
199
200
200
201
The first function, summarize, computes basic statistics from a list of timing measurements:
This result is expected for such a small model: ONNX inference is already efficient, and the dominant costs lie in image preprocessing and occasional solver backtracking. This highlights why system-level profiling is essential before focusing on model-level optimizations.
321
322
322
323
## Quantize the model (FP32 -> INT8)
323
-
Quantization is one of the most impactful optimizations for Arm64 and mobile deployments because it reduces both model size and compute cost. The simplest approach is dynamic quantization, which requires no calibration dataset and is quick to apply.
324
+
Quantization is one of the most impactful optimizations for Arm64 and mobile deployments because it reduces both model size and compute cost. For CNNs, the most compatible approach is static INT8 quantization in QDQ format. This uses a small calibration set to estimate activation ranges and typically works well across runtimes.
Copy file name to clipboardExpand all lines: content/learning-paths/mobile-graphics-and-gaming/onnx/08_Android.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1055,5 +1055,6 @@ From here, there are many natural directions for improvement. You could enhance
1055
1055
This concludes the learning path and provides a solid foundation for building, optimizing, and deploying ONNX-based machine learning applications on Arm64 and mobile platforms.
0 commit comments