From 5b9df04cbe0120ace29e0977fc623c176939322f Mon Sep 17 00:00:00 2001 From: Dawid Borycki Date: Sun, 22 Sep 2024 16:50:44 +0200 Subject: [PATCH] Init version --- .../user-interface.md | 292 +++++++++++++++++ .../Figures/01.png | Bin 0 -> 754424 bytes .../Figures/02.png | Bin 0 -> 743231 bytes .../_index.md | 44 +++ .../_next-steps.md | 43 +++ .../_review.md | 55 ++++ .../app.md | 31 ++ .../intro.md | 24 ++ .../prepare-data.md | 66 ++++ .../user-interface.md | 307 ++++++++++++++++++ 10 files changed, 862 insertions(+) create mode 100644 content/learning-paths/cross-platform/pytorch-digit-classification-inference-android-app/user-interface.md create mode 100644 content/learning-paths/smartphones-and-mobile/pytorch-digit-classification-inference-android-app/Figures/01.png create mode 100644 content/learning-paths/smartphones-and-mobile/pytorch-digit-classification-inference-android-app/Figures/02.png create mode 100644 content/learning-paths/smartphones-and-mobile/pytorch-digit-classification-inference-android-app/_index.md create mode 100644 content/learning-paths/smartphones-and-mobile/pytorch-digit-classification-inference-android-app/_next-steps.md create mode 100644 content/learning-paths/smartphones-and-mobile/pytorch-digit-classification-inference-android-app/_review.md create mode 100644 content/learning-paths/smartphones-and-mobile/pytorch-digit-classification-inference-android-app/app.md create mode 100644 content/learning-paths/smartphones-and-mobile/pytorch-digit-classification-inference-android-app/intro.md create mode 100644 content/learning-paths/smartphones-and-mobile/pytorch-digit-classification-inference-android-app/prepare-data.md create mode 100644 content/learning-paths/smartphones-and-mobile/pytorch-digit-classification-inference-android-app/user-interface.md diff --git a/content/learning-paths/cross-platform/pytorch-digit-classification-inference-android-app/user-interface.md b/content/learning-paths/cross-platform/pytorch-digit-classification-inference-android-app/user-interface.md new file mode 100644 index 000000000..e0f5e98ed --- /dev/null +++ b/content/learning-paths/cross-platform/pytorch-digit-classification-inference-android-app/user-interface.md @@ -0,0 +1,292 @@ +--- +# User change +title: "Create an Android App" + +weight: 3 + +layout: "learningpathall" +--- + +In this section you will create an Android App to run digit classifier. The application will load a randomly selected image containing a handwritten digit, and its true label. Then you will be able to run an inference on this image to predict the digit. + +Start by creating a project and an user interface: +1. Open Android Studio and create a new project with an “Empty Views Activity.” +2. Set the project name to **ArmPyTorchMNISTInference**, set the package name to: **com.arm.armpytorchmnistinference**, select **Kotlin** as the language, and set the minimum SDK to **API 27 ("Oreo" Android 8.1)**. + +We set the API to Android 8.1 (API level 27) as it introduced NNAPI, providing a standard interface for running computationally intensive machine learning models on Android devices. Devices with ARM-based SoCs and corresponding hardware accelerators can leverage NNAPI to offload ML tasks to specialized hardware, such as NPUs (Neural Processing Units), DSPs (Digital Signal Processors), or GPUs (Graphics Processing Units). + +## User interface +You will design the user interface to contain the following: +1. A header. +2. An ImageView and TextView to display the image and its true label. +3. A button to load the image. +4. A button to run inference. +5. Two TextView controls to display the predicted label and inference time. + +To do so, replace the contents of activity_main.xml (located under src/main/res/layout) with the following code: + +```XML + + + + + + + + + + + + + +