From db6246a3b16b2d17817cd798ec36aa42fec9b38d Mon Sep 17 00:00:00 2001
From: w <27848155+fangxingSR@users.noreply.github.com>
Date: Tue, 7 May 2024 19:29:19 +0800
Subject: [PATCH 1/3] Enhanced 'build_apk.py' logic & 'README.md'
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Enhanced 'build_apk.py' logic & 'README.md'.
There was an issue in 'build_apk.py': when only 'qnnsdk' and 'model_path' were provided as inputs, it incorrectly invoked the 'printmenu()' function to display a model selection menu, despite the model always being renamed to 'classification.tflite'. To address this, I adjusted the logic so that the model selection menu is only printed when neither 'model_name' nor 'model_path' is specified by the user. Specifically, I changed line 45 of 'build_apk.py' to read:
```
if not args.model_name and not args.model_path:
```
Additionally, I made several descriptive improvements to the 'README.md' file. Recognizing that newcomers primarily aim to compile and install the ImageClassification application, I included more concise and efficient instructions tailored to their needs, aiming to minimize their trial-and-error process and facilitate a smoother onboarding experience."
Signed-off-by: w <27848155+fangxingSR@users.noreply.github.com>
---
apps/android/ImageClassification/README.md | 25 ++++++++++++++++---
apps/android/ImageClassification/build_apk.py | 2 +-
2 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/apps/android/ImageClassification/README.md b/apps/android/ImageClassification/README.md
index 84a83be4..04dd5727 100644
--- a/apps/android/ImageClassification/README.md
+++ b/apps/android/ImageClassification/README.md
@@ -2,6 +2,10 @@
1. Java, android-sdk and sdkmanager is already set at user's end
2. User should have Linux QNN SDK in local machine.
+3. If models need to be downloaded during the execution of build_apk.py, qai-hub must be installed first according to the[ README.md in ai-hub-models](https://github.com/quic/ai-hub-models/blob/main/README.md).
+
+4. When downloading [MobileNet_v3_Small](https://aihub.qualcomm.com/mobile/models/mobilenet_v3_small) via the web interface, qai-hub installation can be temporarily skipped.
+
## Info
@@ -53,20 +57,33 @@ Right now we use mobilenet_v3_small.tflite model which takes 224x224 as input an
You have to run build_apk.py for Image Classification. It will generate classification-debug.apk and install it in connected device.
+Please first use `python build_apk.py -h` to understand the parameters.
+
+
+```
+build_apk.py [-h] -q QNNSDK [-m MODEL_NAME] [-path MODEL_PATH]
+```
- build_apk.py [-h] -q QNNSDK (-m MODEL_PATH | -e MODEL_NAME)
+The parameter "-q" must be entered. QNN SDK can be utilized by setting an environment variable or specifying the path directly.
There are three ways to input parameters:
1. Inputting only the parameter "-path"
2. Inputting only the parameter "-m"
3. Neither entering the parameter "-m" nor "-path"
### Example
-Here, with -m, give your tflite model path i.e. till `*.tflite file`, and it will copy model file to assets folder to build andoid app.
+Here, with -path, give your tflite model path i.e. till `*.tflite file`, and it will copy model file to assets folder to build andoid app.
```
- python build_apk.py -q "" -m "Path\to\TFLITE\Model"
+ python build_apk.py -q "" -path "Path/to/TFLITE/Model"
```
+
Also, you can use AI-HUB Model name as mentioned in models directory, to directly export the model from AI-Hub and copy it to app assets.
```
- python build_apk.py -q "" -e
+ python build_apk.py -q "" -m
+```
+
+You can also select the model provided in the list menu during the execution of build_apk.py without specifying the model name and model path.
+
+```
+ python build_apk.py -q ""
```
diff --git a/apps/android/ImageClassification/build_apk.py b/apps/android/ImageClassification/build_apk.py
index 66e6cd0d..8fdbb457 100644
--- a/apps/android/ImageClassification/build_apk.py
+++ b/apps/android/ImageClassification/build_apk.py
@@ -42,7 +42,7 @@ def printmenu():
##based on this pre-post can be decided
-if not args.model_name:
+if not args.model_name and not args.model_path:
printmenu()
inp_model_name = int(input("Please select one: "))
args.model_name = MODELNAME(inp_model_name).name
From 21d35932b4dba7f0ff333d6794fe068938c901ae Mon Sep 17 00:00:00 2001
From: w <27848155+fangxingSR@users.noreply.github.com>
Date: Fri, 10 May 2024 11:26:02 +0800
Subject: [PATCH 2/3] =?UTF-8?q?qai-hub=E5=92=8C[=20READM?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Replace qai-hub with AI Hub Models.
Remove the leading space in the line starting with [ README.md......
Signed-off-by: w <27848155+fangxingSR@users.noreply.github.com>
---
apps/android/ImageClassification/README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/apps/android/ImageClassification/README.md b/apps/android/ImageClassification/README.md
index 04dd5727..12abb76f 100644
--- a/apps/android/ImageClassification/README.md
+++ b/apps/android/ImageClassification/README.md
@@ -2,9 +2,9 @@
1. Java, android-sdk and sdkmanager is already set at user's end
2. User should have Linux QNN SDK in local machine.
-3. If models need to be downloaded during the execution of build_apk.py, qai-hub must be installed first according to the[ README.md in ai-hub-models](https://github.com/quic/ai-hub-models/blob/main/README.md).
+3. If models need to be downloaded during the execution of build_apk.py, AI Hub Models must be installed first according to the[README.md in ai-hub-models](https://github.com/quic/ai-hub-models/blob/main/README.md).
-4. When downloading [MobileNet_v3_Small](https://aihub.qualcomm.com/mobile/models/mobilenet_v3_small) via the web interface, qai-hub installation can be temporarily skipped.
+4. When downloading [MobileNet_v3_Small](https://aihub.qualcomm.com/mobile/models/mobilenet_v3_small) via the web interface, AI Hub Models installation can be temporarily skipped.
From a13cf44de46e6e520cc8a0304f9f9be75b63b0b0 Mon Sep 17 00:00:00 2001
From: w <27848155+fangxingSR@users.noreply.github.com>
Date: Fri, 10 May 2024 13:40:34 +0800
Subject: [PATCH 3/3] Update README.md
Signed-off-by: w <27848155+fangxingSR@users.noreply.github.com>
---
apps/android/ImageClassification/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/apps/android/ImageClassification/README.md b/apps/android/ImageClassification/README.md
index 12abb76f..29945ae2 100644
--- a/apps/android/ImageClassification/README.md
+++ b/apps/android/ImageClassification/README.md
@@ -2,7 +2,7 @@
1. Java, android-sdk and sdkmanager is already set at user's end
2. User should have Linux QNN SDK in local machine.
-3. If models need to be downloaded during the execution of build_apk.py, AI Hub Models must be installed first according to the[README.md in ai-hub-models](https://github.com/quic/ai-hub-models/blob/main/README.md).
+3. If models need to be downloaded during the execution of build_apk.py, AI Hub Models must be installed first according to the [README.md in ai-hub-models](https://github.com/quic/ai-hub-models/blob/main/README.md).
4. When downloading [MobileNet_v3_Small](https://aihub.qualcomm.com/mobile/models/mobilenet_v3_small) via the web interface, AI Hub Models installation can be temporarily skipped.