Skip to content

Commit fdaf696

Browse files
committed
Update readme.
1 parent 573df4e commit fdaf696

File tree

6 files changed

+98
-62
lines changed

6 files changed

+98
-62
lines changed

README.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#### QAI AppBuilder
66
Quick AI Application Builder(this repository) is also referred to as *QAI AppBuilder* in the source and documentation. QAI AppBuilder is extension for Qualcomm® AI Runtime SDK. We need some libraries in Qualcomm® AI Runtime SDK for using QAI AppBuilder. <br>
7-
QAI AppBuilder is designed for developer to using Qualcomm® AI Runtime SDK to execute model on Windows on Snapdragon(WoS) and Linux platforms easily. We encapsulated Qualcomm® AI Runtime SDK APIs to several simple APIs for loading the models to CPU or HTP and executing inference.
7+
QAI AppBuilder is designed for developer to using Qualcomm® AI Runtime SDK to execute model on Windows on Snapdragon(WoS) and Linux platforms easily. We encapsulated Qualcomm® AI Runtime SDK APIs to several simple APIs for loading the models to CPU and HTP and executing inference.
88

99
#### Qualcomm® AI Runtime SDK
1010

@@ -27,37 +27,41 @@ Developers can use QAI AppBuilder in both C++ and Python projects <br>
2727
• Faster for testing models. <br>
2828
• Plenty of sample code. <br>
2929

30-
Using the Python extensions with ARM64 Python will make it easier for developers to build GUI app for Windows on Snapdragon(WoS) platforms. Python 3.12.6 ARM64 version has support for following modules: PyQt6, OpenCV, Numpy, PyTorch*, Torchvision*, ONNX*, ONNX Runtime*. Developers can design apps that benefit from rich Python ecosystem. <br>
30+
** Support ARM64 Windows, Linux and Ubuntu (e.g.: X Elite Windows, QCS8550 Linux and QCM6490 Ubuntu)*
3131

32-
**PyTorch, Torchvision, ONNX, ONNX Runtime: need to compile from source code.* <br>
33-
**Also support using x64 Python to run QNN mode on WoS HTP, with this, we can install all the Python extension directly (Refer to the samples code here for detail: https://github.com/quic/ai-engine-direct-helper/tree/main/samples/python))* <br>
34-
**Support ARM64 Windows, Linux and Ubuntu (e.g.: X Elite Windows, QCS8550 Linux and QCM6490 Ubuntu)*
32+
## Environment Setup
33+
Refere to [python.md](docs/python.md) on how to setup Python environment for using QAI AppBuilder on Windows on Snapdragon (WoS) platforms.
34+
35+
## Samples
36+
We have several [samples](samples/) which can be run directly:<br>
37+
1. [Sample code](samples/python/README.md): Guide to run several [AI-Hub](https://aihub.qualcomm.com/compute/models) models throug sample code.
38+
2. OpenAI Compatibility API Service(LLM Service):<br>
39+
2.1 [Python based service](samples/genie/python/README.md): Guide to run OpenAI compatibility API services developed with python.<br>
40+
2.2 [C++ based service](samples/genie/c++/README.md): Guide to run OpenAI compatibility API services developed with C++.<br>
41+
3. [WebUI samples](samples/webui/README.md): Guide to run several WebUI based AI applications.
3542

3643
## Components
3744
There're two ways to use QAI AppBuilder:
3845
### 1. Using the QAI AppBuilder C++ libraries to develop C++ based AI application.
3946
Download prebuild binary package *QAI_AppBuilder-win_arm64-{Qualcomm® AI Runtime SDK version}-Release.zip* to get these files: https://github.com/quic/ai-engine-direct-helper/releases
4047

41-
**libappbuilder.dll {libappbuilder.lib, LibAppBuilder.hpp}** –– C++ projects can use this lib to run models in HTP.
42-
**QAIAppSvc.exe** –– Due to HTP limitations, we can only load models smaller than 4GB in one process. This app is used to help us load the models in new processes(Multiple processes can be created) and inference to avoid HTP restrictions. [*Depress: the above limitation has been fixed.*]
43-
4448
### 2. Using the QAI AppBuilder Python binding extension to develop Python based AI application.
45-
Download Python extension *qai_appbuilder-{version}-cp312-cp312-win_arm64.whl* and install it with the command below:
49+
Download Python extension *qai_appbuilder-{version}-cp312-cp312-win_amd64.whl* and install it with the command below:
4650
https://github.com/quic/ai-engine-direct-helper/releases
4751

4852
```
49-
pip install qai_appbuilder-{version}-cp312-cp312-win_arm64.whl
53+
pip install qai_appbuilder-{version}-cp312-cp312-win_amd64.whl
5054
```
5155

5256
## User Guide
53-
Please refere to [User Guide](docs/user_guide.md) on how to use QAI AppBuilder in your project.
57+
Refere to [User Guide](docs/user_guide.md) on how to use QAI AppBuilder to program AI application.
5458

5559
## Build
56-
Build project with Visual Studio 2022 on WoS device:<br>
60+
Build QAI AppBuilder from source with Visual Studio 2022 on WoS device:<br>
5761
- Install Visual Studio 2022:
5862
- https://docs.qualcomm.com/bundle/publicresource/topics/80-62010-1/Install-Visual-Studio-2022.html?product=Windows%20on%20Snapdragon
59-
- Install Python-3.12.6 ARM64:
60-
- https://www.python.org/ftp/python/3.12.6/python-3.12.6-arm64.exe
63+
- Install x64 version Python-3.12.6:
64+
- https://www.python.org/ftp/python/3.12.8/python-3.12.8-amd64.exe
6165
- Use the commands below to install Python dependency:
6266
```
6367
pip install wheel setuptools pybind11
@@ -76,7 +80,7 @@ cd C:\Source\ai-engine-direct-helper
7680
python setup.py bdist_wheel
7781
7882
# Install the extension:
79-
pip install dist\qai_appbuilder-2.34.0-cp312-cp312-win_arm64.whl
83+
pip install dist\qai_appbuilder-2.34.0-cp312-cp312-win_amd64.whl
8084
```
8185

8286
## License

docs/python.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# python(x64)
2+
3+
## Introduction
4+
This guide helps developers setup Python environment for using QAI AppBuilder on Windows on Snapdragon (WoS) platforms.
5+
6+
## Setting Up QAI AppBuilder Python Environment:
7+
8+
### Step 1: Install Dependencies
9+
Download and install [git](https://github.com/dennisameling/git/releases/download/v2.47.0.windows.2/Git-2.47.0.2-arm64.exe) and [x64 Python 3.12.8](https://www.python.org/ftp/python/3.12.8/python-3.12.8-amd64.exe)
10+
11+
*Make sure to check 'Add python.exe to PATH' while install Python*
12+
13+
### Step 2: Install basic Python dependencies:
14+
Run below commands in Windows terminal:
15+
```
16+
pip install requests wget tqdm importlib-metadata
17+
```
18+
19+
### Step 3: Download QAI AppBuilder repository:
20+
Run below commands in Windows terminal:
21+
```
22+
git clone https://github.com/quic/ai-engine-direct-helper.git
23+
```
24+
25+
### Step 4: Setup QAI AppBuilder Python Environment:
26+
Run below commands in Windows terminal:
27+
```
28+
cd ai-engine-direct-helper\samples
29+
python python\setup.py
30+
```
31+
32+
### Step 5: Now you can refer to the following contents to experience running the AI model on the WoS platform: <br>
33+
1. Run [sample code](../samples/python/README.md) for the models from Qualcomm [AI-Hub](https://aihub.qualcomm.com/compute/models).
34+
2. Run OpenAI Compatibility API Service(LLM Service):<br>
35+
2.1 [Python based service](../samples/genie/python/README.md)<br>
36+
2.2 [C++ based service](../samples/genie/c++/README.md)<br>
37+
3. Run [WebUI samples](../samples/webui/README.md).

docs/python_arm64.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Using the Python extensions with ARM64 Python will make it easier for developers to build GUI app for Windows on Snapdragon(WoS) platforms. Python 3.12.6 ARM64 version has support for following modules: PyQt6, OpenCV, Numpy, PyTorch*, Torchvision*, ONNX*, ONNX Runtime*. Developers can design apps that benefit from rich Python ecosystem. <br>
2+
3+
**PyTorch, Torchvision, ONNX, ONNX Runtime: need to compile from source code.* <br>
4+

docs/user_guide.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,6 @@
66

77
<b>We need below libraries from QNN SDK for using AppBuilder on Snapdragon X Elite(Windows on Snapdragon device):</b>
88

9-
If use ARM64 Python, use the libraries below from QNN SDK(ARM64 Python has better performance in Snapdragon X Elite platform):
10-
```
11-
C:\Qualcomm\AIStack\QAIRT\{SDK Version}\lib\aarch64-windows-msvc\QnnHtp.dll (backend for running model on HTP)
12-
C:\Qualcomm\AIStack\QAIRT\{SDK Version}\lib\aarch64-windows-msvc\QnnCpu.dll (backend for running model on CPU)
13-
C:\Qualcomm\AIStack\QAIRT\{SDK Version}\lib\aarch64-windows-msvc\QnnHtpPrepare.dll
14-
C:\Qualcomm\AIStack\QAIRT\{SDK Version}\lib\aarch64-windows-msvc\QnnSystem.dll
15-
C:\Qualcomm\AIStack\QAIRT\{SDK Version}\lib\aarch64-windows-msvc\QnnHtpV73Stub.dll
16-
C:\Qualcomm\AIStack\QAIRT\{SDK Version}\lib\hexagon-v73\unsigned\libQnnHtpV73Skel.so
17-
C:\Qualcomm\AIStack\QAIRT\{SDK Version}\lib\hexagon-v73\unsigned\libqnnhtpv73.cat
18-
```
19-
209
If use x64 Python, use the libraries below from QNN SDK:
2110
```
2211
C:\Qualcomm\AIStack\QAIRT\{SDK Version}\lib\arm64x-windows-msvc\QnnHtp.dll (backend for running model on HTP)
@@ -28,6 +17,17 @@ C:\Qualcomm\AIStack\QAIRT\{SDK Version}\lib\hexagon-v73\unsigned\libQnnHtpV73Ske
2817
C:\Qualcomm\AIStack\QAIRT\{SDK Version}\lib\hexagon-v73\unsigned\libqnnhtpv73.cat
2918
```
3019

20+
If use ARM64 Python, use the libraries below from QNN SDK(ARM64 Python has better performance in Snapdragon X Elite platform):
21+
```
22+
C:\Qualcomm\AIStack\QAIRT\{SDK Version}\lib\aarch64-windows-msvc\QnnHtp.dll (backend for running model on HTP)
23+
C:\Qualcomm\AIStack\QAIRT\{SDK Version}\lib\aarch64-windows-msvc\QnnCpu.dll (backend for running model on CPU)
24+
C:\Qualcomm\AIStack\QAIRT\{SDK Version}\lib\aarch64-windows-msvc\QnnHtpPrepare.dll
25+
C:\Qualcomm\AIStack\QAIRT\{SDK Version}\lib\aarch64-windows-msvc\QnnSystem.dll
26+
C:\Qualcomm\AIStack\QAIRT\{SDK Version}\lib\aarch64-windows-msvc\QnnHtpV73Stub.dll
27+
C:\Qualcomm\AIStack\QAIRT\{SDK Version}\lib\hexagon-v73\unsigned\libQnnHtpV73Skel.so
28+
C:\Qualcomm\AIStack\QAIRT\{SDK Version}\lib\hexagon-v73\unsigned\libqnnhtpv73.cat
29+
```
30+
3131
We can copy these libraries to one folder. E.g.: ```C:\<Project Name>\qnn\``` <br>
3232

3333
### 2. Python and common python extensions:

samples/genie/python/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
This sample helps developers use QAI AppBuilder + Python to build Genie based Open AI compatibility API service on Windows on Snapdragon (WoS) platform.
55

66
## Setting Up Environment For Service:
7-
### Step 1: Install basic dependencies
8-
Refer to following link to setup basic dependencies: <br>
9-
https://github.com/quic/ai-engine-direct-helper/blob/main/samples/python/README.md#setting-up-qai-appbuilder-python-environment <br>
7+
8+
### Step 1: Install Dependencies
9+
Refer to [python.md](../../../docs/python.md) on how to setup x64 version Python environment.
1010

1111
### Step 2: Install basic Python dependencies for service
1212
Run following commands in Windows terminal:
@@ -48,4 +48,4 @@ python genie\python\GenieAPIClientImage.py --prompt "<Your prompt>"
4848
| Phi 3.5 mini * | [model files](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/phi_3_5_mini_instruct/v1/snapdragon_x_elite/models.zip)<br>[tokenizer.json](https://huggingface.co/microsoft/Phi-3.5-mini-instruct/resolve/main/tokenizer.json?download=true) |
4949

5050
*. For Phi-3.5-Mini-Instruct model, to see appropriate spaces in the output, remove lines 193-196 (Strip rule) in the tokenizer.json file.<br>
51-
**. Refer to here to [setup Stable Diffusion v2.1 models](../../python/README.md) before run 'GenieAPIService.py'.
51+
**. Refer to [setup Stable Diffusion v2.1 models](../../python/README.md) before run 'GenieAPIService.py' (Our Python version 'GenieAPIService.py' support generating image, it depends on Stable Diffusion v2.1 sample code.)

samples/python/README.md

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,52 @@
11
# README
22

33
## Introduction
4-
This guide helps developers use QAI AppBuilder with the QNN SDK to execute models on Windows on Snapdragon (WoS) platforms.
4+
This guide helps developers setup Python environment for using QAI AppBuilder to run sample code on Windows on Snapdragon (WoS) platforms.
55

6-
## Setting Up QAI AppBuilder Python Environment:
6+
## Setting Up QAI AppBuilder Python Environment
77

88
### Step 1: Install Dependencies
9-
Download and install [git](https://github.com/dennisameling/git/releases/download/v2.47.0.windows.2/Git-2.47.0.2-arm64.exe) and [x64 Python 3.12.8](https://www.python.org/ftp/python/3.12.8/python-3.12.8-amd64.exe)
9+
Refer to [python.md](../../docs/python.md) on how to setup x64 version Python environment.
1010

11-
*Make sure to check 'Add python.exe to PATH' while install Python*
12-
13-
### Step 2: Install basic Python dependencies:
11+
### Step 2: Install basic Python dependencies
1412
Run below commands in Windows terminal:
1513
```
16-
pip install requests wget tqdm importlib-metadata qai-hub qai_hub_models huggingface_hub Pillow numpy opencv-python torch torchvision torchaudio transformers diffusers ultralytics==8.0.193
14+
pip install qai-hub qai_hub_models huggingface_hub Pillow numpy opencv-python torch torchvision torchaudio transformers diffusers ultralytics==8.0.193
1715
```
1816

19-
### Step 3: Download QAI AppBuilder repository:
20-
Run below commands in Windows terminal:
21-
```
22-
git clone https://github.com/quic/ai-engine-direct-helper.git
23-
cd ai-engine-direct-helper\samples
24-
```
17+
### Step 3: Prepare Stable Diffusion models.
18+
Before running Stable Diffusion python script, please download Stable Diffusion models from following AI-Hub website and save them to path: 'samples\python\stable_diffusion_v1_5\models' & 'samples\python\stable_diffusion_v2_1\models' manually.<br>
19+
For other models, the sample python script will download them automatically.
2520

26-
### Step 4: Setup QAI AppBuilder Python Environment:
27-
Run below commands in Windows terminal:
28-
```
29-
python python\setup.py
30-
```
21+
There're 3 models for each Stable Diffusion need to be downloaded: TextEncoderQuantizable, UnetQuantizable, VaeDecoderQuantizable. <br>
22+
Make sure to select the right model when download them:<br>
23+
1. Choose runtime: *Qualcomm® AI Engine Direct*<br>
24+
2. Choose device: *Snapdragon® X Elite*<br>
25+
26+
Do *not* rename the model names, just download and copy them to the 'models' folder. <br>
27+
28+
Models AI-Hub links:<br>
29+
[stable_diffusion_v1_5](https://aihub.qualcomm.com/compute/models/stable_diffusion_v1_5_w8a16_quantized)<br>
30+
[stable_diffusion_v2_1](https://aihub.qualcomm.com/compute/models/stable_diffusion_v2_1_quantized)<br>
3131

32-
### Step 5: Run Model:
32+
### Step 4: Run Model
3333
Run below commands in Windows terminal:
3434
```
35+
cd ai-engine-direct-helper\samples
3536
python <Python script for running model> <Parameter of Python script>
3637
```
3738
Where `<Python script for running model>` is the Python script you want to run. For example, if you want to run `stable_diffusion_v2_1`, you can run below command:
3839
```
40+
cd ai-engine-direct-helper\samples
3941
python python\stable_diffusion_v2_1\stable_diffusion_v2_1.py --prompt "spectacular view of northern lights from Alaska"
4042
```
4143

4244
### Support Automatically Setting Up Model List:
4345

4446
| Model | Command |
4547
| ---- | :---- |
46-
| stable_diffusion_v2_1 * | python python\stable_diffusion_v2_1\stable_diffusion_v2_1.py --prompt "the prompt string ..." |
47-
| stable_diffusion_v1_5 * | python python\stable_diffusion_v1_5\stable_diffusion_v1_5.py --prompt "the prompt string ..." |
48+
| stable_diffusion_v2_1 | python python\stable_diffusion_v2_1\stable_diffusion_v2_1.py --prompt "the prompt string ..." |
49+
| stable_diffusion_v1_5 | python python\stable_diffusion_v1_5\stable_diffusion_v1_5.py --prompt "the prompt string ..." |
4850
| real_esrgan_x4plus | python python\real_esrgan_x4plus\real_esrgan_x4plus.py |
4951
| real_esrgan_general_x4v3 | python python\real_esrgan_general_x4v3\real_esrgan_general_x4v3.py |
5052
| inception_v3 | python python\inception_v3\inception_v3.py |
@@ -55,15 +57,4 @@ python python\stable_diffusion_v2_1\stable_diffusion_v2_1.py --prompt "spectacul
5557
| aotgan | python python\aotgan\aotgan.py |
5658
| | |
5759

58-
*. Before running Stable Diffusion app, please download Stable Diffusion models from following AI-Hub website and save them to path: samples\python\stable_diffusion_v1_5\models & samples\python\stable_diffusion_v2_1\models.<br>
59-
60-
There're 3 models for each Stable Diffusion need to be downloaded: TextEncoderQuantizable, UnetQuantizable, VaeDecoderQuantizable <br>
61-
62-
Choose runtime: Qualcomm® AI Engine Direct<br>
63-
Choose device: Snapdragon® X Elite<br>
64-
65-
Models:<br>
66-
[stable_diffusion_v1_5](https://aihub.qualcomm.com/compute/models/stable_diffusion_v1_5_w8a16_quantized)<br>
67-
[stable_diffusion_v2_1](https://aihub.qualcomm.com/compute/models/stable_diffusion_v2_1_quantized)<br>
68-
6960
*More models will be supported soon!*

0 commit comments

Comments
 (0)