File size: 7,118 Bytes
0a85bcb
dd762ae
 
b785a72
120ddab
6783eea
eaacf5e
120ddab
0a85bcb
a76ca7e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d4431d3
a76ca7e
87e895e
 
c6d318b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0a85bcb
c6d318b
 
 
 
 
 
 
 
 
 
 
d60a70d
eaacf5e
d60a70d
 
 
c6d318b
 
 
 
 
fd3f890
 
 
 
 
eaacf5e
fd3f890
 
 
 
 
 
c6d318b
 
eaacf5e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0dc716f
 
d3eb3f5
0dc716f
 
 
 
 
d3eb3f5
 
0dc716f
 
637828b
bb313f3
637828b
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# AidLite SDK Development Documents

## CONTENTS
  - [Introduction](#introduction)
  - [OS Environmental Description](#os-environmental-description)
  - [Installation](#installation)
  - [Tutorial](#tutorial)
  - [API Documents](#api-documents)
## Introduction

**AidLite SDK** (also called **AidSDK**) is the AI inference SDK encapsulated by Aplux. It is aim to use a unified API to load and inference AI model for various mainstream AI frameworks, and to be able to schedule various computing units of the hardware (CPU, GPU, NPU). AidLux SDK is part of the AI tool chain in the AIoT field launched by Aplux Company.

The Aplux AI tool chain covers the entire inference part, as shown in the figure below:

<img src="https://cdn-uploads.huggingface.co/production/uploads/64c1fef5b9d81735a12c3fcc/GX84Ifi8xjyxgfjOQzsly.png" width=800>

Using Aplux AI tool chain can greatly reduce the development cycle in deploying AI models on edge devices.

<img src="https://cdn-uploads.huggingface.co/production/uploads/64c1fef5b9d81735a12c3fcc/jgOWtSxHqpRFMf--hfitN.png" width=800>

AidLite works with AIMO (a model conversion platform), can help developers quickly migrate and deploy existing models to edge devices.

- AIMO online access link: [AI Model Optimization Platform](https://aidlux.com/product/aimo)

**AidLite SDK features are shown in the figure**

<img src="https://cdn-uploads.huggingface.co/production/uploads/64c1fef5b9d81735a12c3fcc/OFMBCLKtMaPkP8aI92GtI.png" width=400>

## OS Environmental Description

AidLite SDK support Android OS, Linux OS and AidLux OS.

**AI runtime support**

||Qualcomm SNPE|Qualcomm QNN|TFLite|RKNN|
|:----:|:----:|:----:|:----:|:----:|
|AidLux OS|βœ…|βœ…|βœ…|βœ…|
|Linux OS|βœ…|βœ…|βœ…|βœ…|
|Android OS|βœ…|🚧|🚧|β›”|

βœ…: Supported

🚧: Supported in the next version

β›”: To be supported

**AI Box support**

||Qualcomm SNPE1.61|Qualcomm SNPE2.1x|Qualcomm QNN|RKNN|
|:----:|:----:|:----:|:----:|:----:|
|QCS6490|βœ…|βœ…|βœ…|❌|
|QCS8250|βœ…|❌|❌|❌|
|QCS8550|❌|βœ…|βœ…|❌|
|RK3588|❌|❌|❌|βœ…|

βœ…: Supported

❌: Unsupported

## Installation

### Installation for AidLux

1. Install AidLite in APP store

<img src="https://cdn-uploads.huggingface.co/production/uploads/64c1fef5b9d81735a12c3fcc/hlo97HWQaECIFQSQMYb4S.png">

> the password is `aidlux`

2. Install AidLite in terminal

```bash
# password is aidlux
# aidlite c++ sdk
sudo aid-pkg -i aidlite-sdk
# aidlite python sdk
python3 -m pip install pyaidlite -i https://mirrors.aidlux.com --trusted-host mirrors.aidlux.com
```

### Installation for Linux

The AidLite SDK is pre-install in AI Box Linux OS.

The update way show blow:

```bash
# password is aidlux
# aidlite c++ sdk
sudo aid-pkg -i aidlite-sdk
# aidlite python sdk
python3 -m pip install pyaidlite -i https://mirrors.aidlux.com --trusted-host mirrors.aidlux.com
```

### Installation for Android

1. Ensure compileSdk=30, minSdk=21, targetSdk=28 in the project build.gradle file

![image/png](https://cdn-uploads.huggingface.co/production/uploads/64c1fef5b9d81735a12c3fcc/m5urbTB5BzWpafib8fRz-.png)

2. Import SDK: Create a new libs folder under the main application app under the project view of android studio, and import AidliteSDK-release.aar and snpe-release.aar into libs

![image/png](https://cdn-uploads.huggingface.co/production/uploads/64c1fef5b9d81735a12c3fcc/6GFfnyBYMqbW7-ngogxlp.png)

3. Add dependencies: Add dependencies under the dependencies of build.gradle in the main application app directory

```java
implementation fileTree(include: ['*.jar', "*.aar"], dir: 'libs')
implementation 'com.github.tiann:FreeReflection:3.1.0'
implementation 'com.elvishew:xlog:1.10.1'
implementation "com.blankj:utilcodex:1.30.6"
implementation 'net.java.dev.jna:jna:5.10.0'

implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation "com.squareup.okhttp3:logging-interceptor:4.9.0"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9'
```

4. Add permissions and attribute configurations to the app/mainifests/AndroidManifest.xml file under the Android view

![image/png](https://cdn-uploads.huggingface.co/production/uploads/64c1fef5b9d81735a12c3fcc/aoxBnWp5V8NgXshfOvxAF.png)

```xml
<uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />  
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>  
<uses-permission android:name="android.permission.READ_PHONE_STATE" />  
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>  
<uses-permission android:name="android.permission.INTERNET" />  
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
```

5. Add packagingOptions in build.gradle file

```java
packagingOptions {  
    doNotStrip "*/arm64-v8a/libsnpe_dsp_v68_domains_v3_skel.so"  
    doNotStrip "*/arm64-v8a/libsnpe_dsp_v66_domains_v2_skel.so"  
    doNotStrip "*/arm64-v8a/libsnpe_dsp_v65_domains_v2_skel.so"  
    doNotStrip "*/arm64-v8a/libsnpe_dsp_domains_v2.so"  
    doNotStrip "*/arm64-v8a/libsnpe_dsp_domains_v3.so"  
    doNotStrip "*/arm64-v8a/libSNPE.so"  
    doNotStrip "*/arm64-v8a/libsnpe-android.so"  
}
```

## Tutorial

### AidLite SDK Demo in AidLux/Linux

1. After installing AidLite SDK, the demo program will download automatically.

```bash
# Demo files path
/usr/local/share/aidlite/examples
```

2. Use `ls` to show file structure

```bash
ls /usr/local/share/aidlite/examples

|__cpp
|__data
|__python
```

3. Run demo

**C++ demo**

```bash
sudo apt update
sudo apt-get install cmake -y

# Our sample program in [/usr/local/share/aidlite/examples/] directory.
# We recommend that you copy the sample program directory to your own working directory.
mkdir -p /home/aidlux/your_work_dir/ && cp -r /usr/local/share/aidlite/examples/ /home/aidlux/your_work_dir/
cd /home/aidlux/your_work_dir/examples/cpp/

# If you do not want to copy the sample program, then next few steps require Sudo permissions
mkdir -p build && cd build
cmake ..
make 

# Run the resulting executable program
./snpe2_yolov5_multi
```

**Python demo**

```bash
sudo cp -r /usr/local/share/aidlite/examples /home/aidlux/examples
cd /home/aidlux/
sudo chown -R aidlux:aidlux ~/examples
cd ~/examples/python
python3 snpe2_yolov5_multi.py
```

### AidLite SDK Demo in Android

AidLite SDK provides a simple and runnable Android project demo, which includes three quantitative models:

- Unet (defect detection)
- ResNet18 (classification)
- YOLOv5s (target detection)
- CPU bind demo

Download Android project and run demo:

- [AidLux SDK Sample(SNPE1.61)](https://aidlux-files.oss-cn-shenzhen.aliyuncs.com/aid-sdk/sample/AidSDKSample(SNPE1.61).zip)
- [AidLux SDK Sample(SNPE2.10)](https://aidlux-files.oss-cn-shenzhen.aliyuncs.com/aid-sdk/sample/AidSDKSample(SNPE2.10).zip)

## API Documents

- [AidLite SDK C++](https://v2.docs.aidlux.com/sdk-api/aidlite-sdk/aidlite-c++)
- [AidLite SDK Python](https://v2.docs.aidlux.com/sdk-api/aidlite-sdk/aidlite-python)
- [AidLite SDK Android](https://v2.docs.aidlux.com/sdk-api/aidlite-sdk/aidlite-android)