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/vision-llm-inference-on-android-with-kleidiai-and-mnn/1-devenv-and-model.md
+20-9Lines changed: 20 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
---
2
-
title: Build the MNN Android Demo with GUI
2
+
title: Environment setup and prepare model
3
3
weight: 3
4
4
5
5
### FIXED, DO NOT MODIFY
@@ -9,7 +9,7 @@ layout: learningpathall
9
9
10
10
In this section, you'll set up your development environment by installing dependencies and preparing the Qwen vision model.
11
11
12
-
Install the Android NDK (Native Development Kit) and git-lfs. This Learning Path was tested with NDK version `28.0.12916984` and CMake version `3.31.6`.
12
+
Install the Android NDK (Native Development Kit) and git-lfs. This Learning Path was tested with NDK version `28.0.12916984` and CMake version `4.0.0-rc1`.
13
13
14
14
For Ubuntu or Debian systems, install CMake and git-lfs with the following commands:
15
15
@@ -18,9 +18,9 @@ sudo apt update
18
18
sudo apt install cmake git-lfs -y
19
19
```
20
20
21
-
You can use Android Studio to obtain the NDK.
21
+
You can use Android Studio to obtain the NDK.
22
22
23
-
Click **Tools > SDK Manager** and navigate to the **SDK Tools** tab.
23
+
Click **Tools > SDK Manager** and navigate to the **SDK Tools** tab.
24
24
25
25
Select the **NDK (Side by side)** and **CMake** checkboxes, as shown below:
26
26
@@ -48,7 +48,7 @@ If Python 3.x is not the default version, try running `python3 --version` and `p
48
48
49
49
## Set up Phone Connection
50
50
51
-
You need to set up an authorized connection with your phone. The Android SDK Platform Tools package, included with Android Studio, provides Android Debug Bridge (ADB) for transferring files.
51
+
You need to set up an authorized connection with your phone. The Android SDK Platform Tools package, included with Android Studio, provides Android Debug Bridge (ADB) for transferring files.
52
52
53
53
Connect your phone to your computer using a USB cable, and enable USB debugging on your phone. To do this, tap the **Build Number** in your **Settings** app 7 times, then enable **USB debugging** in **Developer Options**.
54
54
@@ -65,9 +65,18 @@ List of devices attached
65
65
<DEVICE ID> device
66
66
```
67
67
68
-
## Download and Convert the Model
68
+
## Download the quantized Model
69
69
70
-
The following commands download the model from Hugging Face, and clone a tool for exporting the LLM model to the MNN framework.
70
+
The pre-quantized model is available in Hugging Face, you can download with the following command:
If you need to quantize the model with customized parameter, the following commands download the model from Hugging Face, and clone a tool for exporting the LLM model to the MNN framework.
71
80
72
81
```bash
73
82
cd$HOME
@@ -95,11 +104,13 @@ To learn more about the parameters, see the [transformers README.md](https://git
95
104
96
105
Verify that the model was built correctly by checking that the `Qwen2-VL-2B-Instruct-convert-4bit-per_channel` directory is at least 1 GB in size.
Copy file name to clipboardExpand all lines: content/learning-paths/mobile-graphics-and-gaming/vision-llm-inference-on-android-with-kleidiai-and-mnn/2-benchmark.md
+34-34Lines changed: 34 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,15 @@
1
1
---
2
2
title: Build the MNN Command-line ViT Demo
3
-
weight: 5
3
+
weight: 4
4
4
5
5
### FIXED, DO NOT MODIFY
6
6
layout: learningpathall
7
7
---
8
8
## Prepare an Example Image
9
9
10
-
In this section, you'll benchmark model performance with and without KleidiAI kernels. To run optimized inference, you'll first need to compile the required library files. You'll also need an example image to run command-line prompts.
10
+
In this section, you'll benchmark model performance with and without KleidiAI kernels. To run optimized inference, you'll first need to compile the required library files. You'll also need an example image to run command-line prompts.
11
11
12
-
You can use the provided image of the tiger below that this Learning Path uses, or choose your own.
12
+
You can use the provided image of the tiger below that this Learning Path uses, or choose your own.
13
13
14
14
Whichever you select, rename the image to `example.png` to use the commands in the following sections.
If your NDK toolchain isn't set up correctly, you might run into issues with the above script. Make a note of where the NDK was installed - this will be a directory named after the version you downloaded earlier. Try exporting the following environment variables before re-running above commands:
49
+
If your NDK toolchain isn't set up correctly, you might run into issues with the above script. Make a note of where the NDK was installed - this will be a directory named after the version you downloaded earlier. Try exporting the following environment variables before re-running `build_64.sh`:
Run the following commands in the ADB shell. Navigate to the directory you pushed the files to, add executable permissions to the `llm_demo` file and export an environment variable for it to run properly. After this, use the example image you transferred earlier to create a file containing the text content for the prompt.
63
69
64
70
```bash
65
71
cd /data/local/tmp/
66
-
chmod +x vision_llm
72
+
chmod +x llm_demo
67
73
export LD_LIBRARY_PATH=$PWD
68
74
echo"<img>./example.png</img>Describe the content of the image."> prompt
69
75
```
70
76
71
77
Finally, run an inference on the model with the following command:
Copy file name to clipboardExpand all lines: content/learning-paths/mobile-graphics-and-gaming/vision-llm-inference-on-android-with-kleidiai-and-mnn/2-generate-apk.md
0 commit comments