Skip to content

Commit

Permalink
initial release of ai-solutions
Browse files Browse the repository at this point in the history
Signed-off-by: quic-ppant <[email protected]>
  • Loading branch information
quic-ppant committed Dec 21, 2023
1 parent ee9b36c commit d681ce7
Show file tree
Hide file tree
Showing 247 changed files with 58,645 additions and 0 deletions.
142 changes: 142 additions & 0 deletions ai-solutions/QCS8550-embedded-linux/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
## Table of Contents

- [Table of Contents](#table-of-contents)
- [LE Build setup](#le-build-setup)
- [Generating ai-solutions binary](#generating-ai-solutions-binary)
- [Running ai-solutions application](#running-ai-solutions-application)

## LE Build setup

1. Follow "00067.1 Release Note for QCS8550.LE.1.0" to Setup "qti-distro-rb-debug" LE.1.0 build server for QCS8550
2. Make sure "bitbake qti-robotics-image" is successful
3. Verify the "qti-distro-rb-debug" build by flashing on target using "fastboot". Commands to flash:

```
cd build-qti-distro-rb-debug/tmp-glibc/deploy/images/kalama/qti-robotics-image/
adb root
adb reboot bootloader
fastboot flash abl_a abl.elf
fastboot flash abl_b abl.elf
fastboot flash dtbo_a dtbo.img
fastboot flash dtbo_b dtbo.img
fastboot flash boot_a boot.img
fastboot flash boot_b boot.img
fastboot flash system_a system.img
fastboot flash system_b system.img
fastboot flash userdata userdata.img
fastboot flash persist persist.img
fastboot reboot
```
## Generating ai-solutions binary
1. Copy snpe-2.x folder to "<APPS_ROOT>/poky/meta-qti-ml-prop/recipes/snpe-sdk/files/snpe/".
```
cp -r <SNPE_ROOT>/* <APPS_ROOT>/poky/meta-qti-ml-prop/recipes/snpe-sdk/files/snpe/
```
2. Copy "meta-qti-ai-solutions" into "<APPS_ROOT>/poky/" folder
```
cp -r meta-qti-ai-solutions <APPS_ROOT>/poky/
```
3. Copy SNPE,DiagLog,DlContainer,DlSystem and Wrapper.hpp
```
cp -r <SNPE_ROOT>/include/SNPE/Dl* <APPS_ROOT>/poky/meta-qti-ai-solutions/recipes/ai-solutions/files/app/inc/
cp -r <SNPE_ROOT>/include/SNPE/DiagLog/ <APPS_ROOT>/poky/meta-qti-ai-solutions/recipes/ai-solutions/files/app/inc/
cp -r <SNPE_ROOT>/include/SNPE/Wrapper.hpp <APPS_ROOT>/poky/meta-qti-ai-solutions/recipes/ai-solutions/files/app/inc/
cp -r <SNPE_ROOT>/include/SNPE/SNPE/ <APPS_ROOT>/poky/meta-qti-ai-solutions/recipes/ai-solutions/files/app/inc/
```
4. Update "snpe.bb" in "poky/meta-qti-ml-prop/recipes/snpe-sdk" folder
1. Make sure platform "aarch64-oe-linux-gcc11.2" is selected
2. Update DSP lib path
```
-- install -m 0755 ${S}/lib/dsp/* ${D}/${libdir}/rfsa/adsp
++ install -m 0755 ${S}/lib/hexagon-v73/unsigned/lib* ${D}/${libdir}/rfsa/adsp
```
5. Run the following commands
```
cd <APPS_ROOT>/LE.PRODUCT.2.1.r1/apps_proc/poky
export MACHINE=kalama DISTRO=qti-distro-rb-debug
source qti-conf/set_bb_env.sh
export PREBUILT_SRC_DIR="<APPS_ROOT>/prebuilt_HY11"
bitbake qti-robotics-image
```
6. Flash the latest build on target. (Note: Check if "ai-solutions" binary is generated in the "build-qti-distro-fullstack-debug/tmp-glibc/work/qrb5165_rb5-oe-linux/qti-robotics-image/1.0-r0/rootfs/usr/bin/" path)
## Running ai-solutions application
1. Execute the following commands to remount the target
```
adb root
adb disable-verity
adb reboot
adb root
adb shell "mount -o remount,rw /"
```
2. Push "meta-qti-ai-solutions/recipes/ai-solutions/files/app/" and "SNPE-2.14" onto the device
```
adb push <file> <path_on_target>
```
3. Execute the following commands to setup snpe on target
```
adb shell
cd <SNPE_ROOT>
cp -r lib/aarch64-oe-linux-gcc11.2/lib* /usr/lib/
cp bin/aarch64-oe-linux-gcc11.2/snpe-net-run /usr/bin/
cp -r lib/hexagon-v73/unsigned/lib* /usr/lib/rfsa/adsp/
chmod +x /usr/bin/snpe-net-run
snpe-net-run --version
```
Expected output: SNPE v2.14.2.230905160328_61726
4. Run ai-solutions application
```
adb shell
cd <app_path>
ai-solutions -c <path to config.json> -i <path to Input image> -o <path to Output image>
```
Example:
```
ai-solutions -c data/config.json -i Sample1.jpg -o output.jpg
```
### Details on Input arguments:
#### Sample config.json
```json
"model-configs":[
"model-name":"QSrnet-medium", -> model name which is used while enabling solution
"model-type":"superresolution", -> To specify the use case such superresolution or detection or segmentation etc..
"model-path":"models/quicksrnet_medium_quantized.dlc", -> Path at which model is located on target
"runtime":"DSP", -> Select Runtime either CPU or DSP
"input-layers":[ -> Input layer of the model
"t.1"
],
"output-layers":[
"depth_to_space#1" -> Output layer of the model
],
"output-tensors":[
"65" -> Output node for post processing
]
]
```
solution-config:
```json
"solution-configs":[
{
"solution-name":"AI-Solutions", -> To identify usecase
"model-name":"SESR", -> Specify model name to be executed
"input-config-name":"image", -> To read input from image
"Enable":0 -> Enable specific solution
},
{
"solution-name":"AI-Solutions",
"model-name":"SRGAN",
"input-config-name":"image",
"Enable":1
}
]
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
BBFILES += "${LAYERDIR}/recipes/*/*.bb ${LAYERDIR}/recipes/*/*.bbappend ${LAYERDIR}/recipes-*/*/*.bb ${LAYERDIR}/recipes-*/*/*.bbappend"
BBPATH .= ":${LAYERDIR}"
BBFILE_COLLECTIONS += "ai-solutions"
BBFILE_PRIORITY_ai-solutions = "17"
BBFILE_PATTERN_ai-solutions := "^${LAYERDIR}/"
LAYERSERIES_COMPAT_ai-solutions = " dunfell kirkstone "
IMAGE_INSTALL:append = " ai-solutions "
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
inherit cmake pkgconfig

HOMEPAGE = "http://support.cdmatech.com"
LICENSE = "Qualcomm-Technologies-Inc.-Proprietary"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta-qti-bsp-prop/files/qcom-licenses/\
${LICENSE};md5=92b1d0ceea78229551577d4284669bb8"

SUMMARY = "AI-Solutions on QCS8550"
DESCRIPTION = "AI-Solutions"

LICENSE = "Qualcomm-Technologies-Inc.-Proprietary"

SRC_URI = "file://app"
S = "${WORKDIR}/app"

DEPENDS += " jsoncpp json-glib gflags gstreamer1.0 gstreamer1.0-plugins-base opencv snpe"

do_install(){
install -d ${D}/${bindir}
install -m 0777 ${WORKDIR}/build/out/ai-solutions ${D}/${bindir}
}

INSANE_SKIP_${PN} += "arch"

FILES_${PN} += "${bindir}/*"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
find_package(PkgConfig)
pkg_search_module(GLIB REQUIRED glib-2.0)
pkg_check_modules(GSTREAMER REQUIRED gstreamer-1.0)
pkg_check_modules(GST_APP REQUIRED gstreamer-app-1.0)
pkg_check_modules(GST_VIDEO REQUIRED gstreamer-video-1.0)
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# CMake lowest version requirement
cmake_minimum_required(VERSION 3.5.1)

# project information
project(AI-SOLUTIONS)

include(FindPkgConfig)
pkg_check_modules(JSONCPP REQUIRED jsoncpp)
pkg_check_modules(JSON REQUIRED json-glib-1.0)
pkg_check_modules(GFLAGS REQUIRED gflags)

set(PROJECT_ROOT ${CMAKE_CURRENT_LIST_DIR})
set(CMAKE_MODULE_PATH ${PROJECT_ROOT}/CMake)
set(CMAKE_CXX_STANDARD 17)

find_package(GStreamer REQUIRED)
find_package(OpenCV REQUIRED )

add_subdirectory("./src")

link_directories(
${JSONCPP_LIBRARY_DIRS}
${JSON_LIBRARY_DIRS}
${GFLAGS_LIBRARY_DIRS}
)
Loading

0 comments on commit d681ce7

Please sign in to comment.