AIToolKit / AidLite SDK Development Documents.md
qc903113684's picture
Update AidLite SDK Development Documents.md
120ddab verified

AidLite SDK Development Documents

CONTENTS

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:

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

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

AidLite SDK features are shown in the figure

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

the password is aidlux

  1. Install AidLite in terminal
# 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:

# 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

  1. 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

  1. Add dependencies: Add dependencies under the dependencies of build.gradle in the main application app directory
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'
  1. Add permissions and attribute configurations to the app/mainifests/AndroidManifest.xml file under the Android view

image/png

<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" />
  1. Add packagingOptions in build.gradle file
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.
# Demo files path
/usr/local/share/aidlite/examples
  1. Use ls to show file structure
ls /usr/local/share/aidlite/examples

|__cpp
|__data
|__python
  1. Run demo

C++ demo

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

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:

API Documents