Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add iOS On Device Training Tutorial with ONNX Runtime #17146

Merged
merged 45 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
b7b56bd
restructure on device training tutorial content
vraspar Aug 8, 2023
5f3d2c7
fix broken links
vraspar Aug 8, 2023
6b4734d
Merge branch 'gh-pages' of https://github.com/vraspar/onnxruntime int…
vraspar Aug 10, 2023
406f7b2
Add training artifacts and installtion guide
vraspar Aug 10, 2023
8778c6b
Merge branch 'microsoft:gh-pages' into gh-pages
vraspar Aug 10, 2023
5603b17
fix formatting and links
vraspar Aug 10, 2023
0111a73
Merge branch 'gh-pages' of https://github.com/vraspar/onnxruntime int…
vraspar Aug 10, 2023
f1e542c
add recording generation steps
vraspar Aug 10, 2023
27dd7a7
Merge branch 'gh-pages' of https://github.com/vraspar/onnxruntime int…
vraspar Aug 11, 2023
adc7da2
add training model instructions
vraspar Aug 11, 2023
07f4273
Add inference instructions
vraspar Aug 11, 2023
501b5f3
Add recording instructions
vraspar Aug 11, 2023
4fce766
Add Instructions for UI
vraspar Aug 14, 2023
899e6ac
fix spell errors
vraspar Aug 14, 2023
38d7411
add images for running the app section
vraspar Aug 14, 2023
ee0bd85
Fix spelling errors
vraspar Aug 14, 2023
16fde62
Update docs/tutorials/on-device-training/ios-app.md
vraspar Aug 15, 2023
31d7a72
Update docs/tutorials/on-device-training/ios-app.md
vraspar Aug 15, 2023
fedc010
Update docs/tutorials/on-device-training/ios-app.md
vraspar Aug 15, 2023
af7c65a
Update docs/tutorials/on-device-training/ios-app.md
vraspar Aug 15, 2023
45eef1a
Update docs/tutorials/on-device-training/ios-app.md
vraspar Aug 15, 2023
faa55df
Update docs/tutorials/on-device-training/ios-app.md
vraspar Aug 15, 2023
55b2521
Update docs/tutorials/on-device-training/ios-app.md
vraspar Aug 15, 2023
57d5471
Update docs/tutorials/on-device-training/ios-app.md
vraspar Aug 15, 2023
ff2e1e6
Update docs/tutorials/on-device-training/ios-app.md
vraspar Aug 15, 2023
4857b45
Update docs/tutorials/on-device-training/ios-app.md
vraspar Aug 15, 2023
5c9008f
Update docs/tutorials/on-device-training/ios-app.md
vraspar Aug 15, 2023
aa4ecb9
Update docs/tutorials/on-device-training/ios-app.md
vraspar Aug 15, 2023
4e07555
Update docs/tutorials/on-device-training/ios-app.md
vraspar Aug 15, 2023
70fb55d
Update docs/tutorials/on-device-training/ios-app.md
vraspar Aug 15, 2023
ebe213d
Update docs/tutorials/on-device-training/ios-app.md
vraspar Aug 15, 2023
1da52e0
Update docs/tutorials/on-device-training/ios-app.md
vraspar Aug 15, 2023
67f24b9
Update docs/tutorials/on-device-training/ios-app.md
vraspar Aug 15, 2023
1ed87af
Update docs/tutorials/on-device-training/ios-app.md
vraspar Aug 15, 2023
e0cdebc
Update docs/tutorials/on-device-training/ios-app.md
vraspar Aug 15, 2023
2fc9663
Update docs/tutorials/on-device-training/ios-app.md
vraspar Aug 15, 2023
ca07e01
Update docs/tutorials/on-device-training/ios-app.md
vraspar Aug 15, 2023
03a2ce2
Update docs/tutorials/on-device-training/ios-app.md
vraspar Aug 15, 2023
62f945a
Update docs/tutorials/on-device-training/ios-app.md
vraspar Aug 15, 2023
0c38036
Update docs/tutorials/on-device-training/ios-app.md
vraspar Aug 15, 2023
14e91ea
Rename images and fix formatting
vraspar Aug 15, 2023
84def52
Update docs/tutorials/on-device-training/ios-app.md
vraspar Aug 15, 2023
65cb007
Clarify creation of recordings group section
vraspar Aug 15, 2023
4653442
Update docs/tutorials/on-device-training/ios-app.md
vraspar Aug 16, 2023
7cf1b89
add links to model and update pod instructions
vraspar Aug 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
---
title: On-Device Training
nav_order: 11
parent: Tutorials
title: Building an Android Application
description: Building an Android Application using ONNX Runtime's On-Device Training solution.
parent: On-Device Training
grand_parent: Tutorials
nav_order: 1
---

# On-Device Training: Building an Android Application
Expand All @@ -10,7 +12,7 @@ In this tutorial, we will explore how to build an Android application that incor

Here is what the application will look like at the end of this tutorial:

<img src="../../images/on-device-training-application-prediction-tom.jpg" width="30%" height="30%">
<img src="../../../images/on-device-training-application-prediction-tom.jpg" width="30%" height="30%">

## Introduction

Expand Down Expand Up @@ -103,7 +105,7 @@ To follow this tutorial, you should have a basic understanding of Android app de

3. <a name="op3"></a>Generate the training artifacts.

We will use the `CrossEntropyLoss` loss and the `AdamW` optimizer for this tutorial. More details around artifact generation can be found [here](../../docs/api/python/on_device_training/training_artifacts.html).
We will use the `CrossEntropyLoss` loss and the `AdamW` optimizer for this tutorial. More details around artifact generation can be found [here](../../../docs/api/python/on_device_training/training_artifacts.html).

```python
from onnxruntime.training import artifacts
Expand All @@ -127,7 +129,7 @@ To follow this tutorial, you should have a basic understanding of Android app de
1. <a name="tp1"></a>Setting up the project in Android Studio

a. Open Android Studio and click `New Project`
![Android Studio Setup - New Project](../../images/on-device-training-android-studio-setup.png)
![Android Studio Setup - New Project](../../../images/on-device-training-android-studio-setup.png)

b. Click on `Native C++` -> `Next`. Fill out the `New Project` details as follows:

Expand All @@ -137,19 +139,19 @@ To follow this tutorial, you should have a basic understanding of Android app de

Click `Next`.

![Android Studio Setup - Project Name](../../images/on-device-training-android-studio-project-name.png)
![Android Studio Setup - Project Name](../../../images/on-device-training-android-studio-project-name.png)

c. Select the `C++17` toolchain -> `Finish`

![Android Studio Setup - Project C++ ToolChain](../../images/on-device-training-android-studio-toolchain.png)
![Android Studio Setup - Project C++ ToolChain](../../../images/on-device-training-android-studio-toolchain.png)

d. That's it! The Android Studio project has been set up. You should now be able to see the Android Studio editor with some boiler plate code.

2. <a name="tp2"></a>Adding the ONNX Runtime dependency

a. Create two new folders called `lib` and `include\onnxruntime` under the cpp directory in the Android Studio project.

![lib and include folder](../../images/on-device-training-lib-include.png)
![lib and include folder](../../../images/on-device-training-lib-include.png)

b. Head over to [Maven Central](https://central.sonatype.com/artifact/com.microsoft.onnxruntime/onnxruntime-training-android/). Go to `Versions`->`Browse`-> and download the `onnxruntime-training-android` archive package (aar file).

Expand Down Expand Up @@ -274,7 +276,7 @@ To follow this tutorial, you should have a basic understanding of Android app de

The left pane of the project should look like this:

![Project Assets](../../images/on-device-training-project-assets.png)
![Project Assets](../../../images/on-device-training-project-assets.png)

4. <a name="tp4"></a>Interfacing with ONNX Runtime - C++ Code

Expand Down Expand Up @@ -789,7 +791,7 @@ To follow this tutorial, you should have a basic understanding of Android app de

b. Launching the application on the device should look like this:

<img src="../../images/on-device-training-application-landing-page.jpg" width="30%" height="30%">
<img src="../../../images/on-device-training-application-landing-page.jpg" width="30%" height="30%">

2. <a name="tp8"></a>Training with a pre-loaded dataset - Animals

Expand All @@ -803,7 +805,7 @@ To follow this tutorial, you should have a basic understanding of Android app de

e. Use any animal image from your library for inferencing now.

<img src="../../images/on-device-training-application-prediction-cow.jpg" width="30%" height="30%">
<img src="../../../images/on-device-training-application-prediction-cow.jpg" width="30%" height="30%">

As can be seen from the image above, the model correctly predicted `Cow`.

Expand All @@ -823,7 +825,7 @@ To follow this tutorial, you should have a basic understanding of Android app de

g. That's it!. Hopefully the application classified the image correctly.

<img src="../../images/on-device-training-application-prediction-tom.jpg" width="30%" height="30%">
<img src="../../../images/on-device-training-application-prediction-tom.jpg" width="30%" height="30%">


## Conclusion
Expand Down
8 changes: 8 additions & 0 deletions docs/tutorials/on-device-training/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: On-Device Training
parent: Tutorials
has_children: true
nav_order: 11
---

# On-Device Training
Loading
Loading