feat: Update NNSDK path and library linking in CMake configurations and Android build script, and add a new script to build all Android examples.
This commit is contained in:
parent
79a2bd27f6
commit
21105e3db7
35 changed files with 1438 additions and 1222 deletions
29
README.md
29
README.md
|
|
@ -68,6 +68,35 @@ pre-build models:
|
||||||
- means currently supported.
|
- means currently supported.
|
||||||
|
|
||||||
# Examples Compile
|
# Examples Compile
|
||||||
|
## AMLNN SDK Setup
|
||||||
|
|
||||||
|
The C++ demos depend on the **AMLNN nnsdk** runtime library. The build system resolves it using the following priority order:
|
||||||
|
|
||||||
|
**Priority 1 – Environment variable (recommended)**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export AMLNN_HOME=/path/to/amlnn-toolkit
|
||||||
|
```
|
||||||
|
|
||||||
|
**Priority 2 – CMake auto-find (`FindAMLNN.cmake`)**
|
||||||
|
|
||||||
|
Handled automatically via `cmake/FindAMLNN.cmake` in the project root — useful in IDE and CI environments.
|
||||||
|
|
||||||
|
**Priority 3 – Sibling directory fallback**
|
||||||
|
|
||||||
|
If `AMLNN_HOME` is not set, the script automatically looks for `amlnn-toolkit` as a sibling directory:
|
||||||
|
```
|
||||||
|
modelzoo/
|
||||||
|
├── amlnn-model-playground/ ← this repo
|
||||||
|
└── amlnn-toolkit/ ← SDK placed here automatically found
|
||||||
|
```
|
||||||
|
|
||||||
|
Clone it with:
|
||||||
|
```bash
|
||||||
|
git clone git@github.com:Amlogic-NN/amlnn-toolkit.git ../amlnn-toolkit
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Each **example** directory contains a **build-android.sh** and build-linux.sh **script**. For compilation steps, refer to **Chapter 4** of the **README.md** file in the corresponding example directory.
|
Each **example** directory contains a **build-android.sh** and build-linux.sh **script**. For compilation steps, refer to **Chapter 4** of the **README.md** file in the corresponding example directory.
|
||||||
|
|
||||||
|
|
|
||||||
64
cmake/FindAMLNN.cmake
Normal file
64
cmake/FindAMLNN.cmake
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
# FindAMLNN.cmake
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Locates the AMLNN nnsdk headers and libraries.
|
||||||
|
#
|
||||||
|
# Inputs (set before calling find_package):
|
||||||
|
# AMLNN_HOME – root of the amlnn-toolkit (contains nn_runtime/)
|
||||||
|
# May also be supplied as the environment variable AMLNN_HOME.
|
||||||
|
#
|
||||||
|
# Outputs:
|
||||||
|
# AMLNN_INCLUDE_DIR – path to nnsdk include dir
|
||||||
|
# AMLNN_LIBRARY_DIR – path to the ABI-specific library dir (use link_directories)
|
||||||
|
# AMLNN_LIBRARY – "nnsdk" (library name, no prefix/suffix)
|
||||||
|
# AMLNN_FOUND
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Resolve AMLNN_HOME: CMake variable → env var → relative sibling fallbacks
|
||||||
|
if(NOT AMLNN_HOME)
|
||||||
|
if(DEFINED ENV{AMLNN_HOME} AND NOT "$ENV{AMLNN_HOME}" STREQUAL "")
|
||||||
|
set(AMLNN_HOME "$ENV{AMLNN_HOME}")
|
||||||
|
elseif(EXISTS "${CMAKE_SOURCE_DIR}/../../../../../amlnn-toolkit/nn_runtime")
|
||||||
|
set(AMLNN_HOME "${CMAKE_SOURCE_DIR}/../../../../../amlnn-toolkit")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT AMLNN_HOME)
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"AMLNN_HOME not found.\n"
|
||||||
|
"Please set the AMLNN_HOME environment variable (or CMake variable) "
|
||||||
|
"to the root of the amlnn-toolkit directory, e.g.:\n"
|
||||||
|
" export AMLNN_HOME=/path/to/amlnn-toolkit\n"
|
||||||
|
" cmake ... -DAMLNN_HOME=/path/to/amlnn-toolkit")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
get_filename_component(AMLNN_HOME "${AMLNN_HOME}" ABSOLUTE)
|
||||||
|
|
||||||
|
set(AMLNN_NNSDK_ROOT "${AMLNN_HOME}/nn_runtime/nnsdk")
|
||||||
|
set(AMLNN_INCLUDE_DIR "${AMLNN_NNSDK_ROOT}/include")
|
||||||
|
|
||||||
|
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
||||||
|
if(ANDROID_ABI STREQUAL "arm64-v8a")
|
||||||
|
set(AMLNN_LIBRARY_DIR "${AMLNN_NNSDK_ROOT}/android/arm64-v8a")
|
||||||
|
else()
|
||||||
|
set(AMLNN_LIBRARY_DIR "${AMLNN_NNSDK_ROOT}/android/armeabi-v7a")
|
||||||
|
endif()
|
||||||
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||||
|
set(AMLNN_LIBRARY_DIR "${AMLNN_NNSDK_ROOT}/linux/yocto/aarch64-poky-linux")
|
||||||
|
else()
|
||||||
|
set(AMLNN_LIBRARY_DIR "${AMLNN_NNSDK_ROOT}/linux/yocto/aarch64-poky-linux")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(AMLNN_LIBRARY "nnsdk")
|
||||||
|
|
||||||
|
# Validate paths
|
||||||
|
if(NOT EXISTS "${AMLNN_INCLUDE_DIR}")
|
||||||
|
message(FATAL_ERROR "AMLNN include dir not found: ${AMLNN_INCLUDE_DIR}\n(AMLNN_HOME=${AMLNN_HOME})")
|
||||||
|
endif()
|
||||||
|
if(NOT EXISTS "${AMLNN_LIBRARY_DIR}")
|
||||||
|
message(FATAL_ERROR "AMLNN library dir not found: ${AMLNN_LIBRARY_DIR}\n(AMLNN_HOME=${AMLNN_HOME})")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(AMLNN_FOUND TRUE)
|
||||||
|
message(STATUS "Found AMLNN: ${AMLNN_HOME}")
|
||||||
|
message(STATUS " AMLNN_INCLUDE_DIR: ${AMLNN_INCLUDE_DIR}")
|
||||||
|
message(STATUS " AMLNN_LIBRARY_DIR: ${AMLNN_LIBRARY_DIR}")
|
||||||
|
|
@ -41,20 +41,43 @@ while getopts 'a:h' opt; do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -z "${ANDROID_NDK_PATH}" ]; then
|
SCRIPT_DIR=$(cd "$(dirname $0)" && pwd)
|
||||||
if [ -n "${ANDROID_NDK}" ]; then
|
|
||||||
ANDROID_NDK_PATH=${ANDROID_NDK}
|
# Priority 1: Environment variable (recommended)
|
||||||
elif [ -n "${ANDROID_NDK_HOME}" ]; then
|
if [ -n "$AMLNN_HOME" ]; then
|
||||||
ANDROID_NDK_PATH=${ANDROID_NDK_HOME}
|
if [ ! -d "$AMLNN_HOME/nn_runtime" ]; then
|
||||||
else
|
echo "Error: AMLNN_HOME is set to '$AMLNN_HOME' but nn_runtime was not found there."
|
||||||
echo "Error: ANDROID_NDK_PATH is not set."
|
echo "Please check your AMLNN_HOME path."
|
||||||
echo "Please set ANDROID_NDK_PATH to your Android NDK directory."
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
RUNTIME_PATH="$AMLNN_HOME/nn_runtime"
|
||||||
|
echo "Priority 1: Using AMLNN_HOME from environment: $AMLNN_HOME"
|
||||||
|
# Priority 3: Fallback to sibling amlnn-toolkit (compatibility)
|
||||||
|
elif [ -d "${SCRIPT_DIR}/../../amlnn-toolkit/nn_runtime" ]; then
|
||||||
|
export AMLNN_HOME="$(cd "${SCRIPT_DIR}/../../amlnn-toolkit" && pwd)"
|
||||||
|
RUNTIME_PATH="$AMLNN_HOME/nn_runtime"
|
||||||
|
echo "Priority 3: Using sibling amlnn-toolkit as fallback: $AMLNN_HOME"
|
||||||
|
elif [ -d "${SCRIPT_DIR}/../../amlnn-toolkit-a/nn_runtime" ]; then
|
||||||
|
export AMLNN_HOME="$(cd "${SCRIPT_DIR}/../../amlnn-toolkit-a" && pwd)"
|
||||||
|
RUNTIME_PATH="$AMLNN_HOME/nn_runtime"
|
||||||
|
echo "Priority 3: Using sibling amlnn-toolkit-a as fallback: $AMLNN_HOME"
|
||||||
|
else
|
||||||
|
echo ""
|
||||||
|
echo "Error: AMLNN SDK not found."
|
||||||
|
echo ""
|
||||||
|
echo "Please do one of the following:"
|
||||||
|
echo ""
|
||||||
|
echo " Option A (recommended) – set AMLNN_HOME:"
|
||||||
|
echo " export AMLNN_HOME=/path/to/amlnn-toolkit"
|
||||||
|
echo " ./build-android-all.sh"
|
||||||
|
echo ""
|
||||||
|
echo " Option B – clone amlnn-toolkit as a sibling directory:"
|
||||||
|
echo " git clone git@github.com:Amlogic-NN/amlnn-toolkit.git ../../../amlnn-toolkit"
|
||||||
|
echo " ./build-android-all.sh"
|
||||||
|
echo ""
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SCRIPT_DIR=$(cd "$(dirname $0)" && pwd)
|
|
||||||
|
|
||||||
echo "============================================"
|
echo "============================================"
|
||||||
echo "Building all Android examples"
|
echo "Building all Android examples"
|
||||||
echo "NDK_PATH: ${ANDROID_NDK_PATH}"
|
echo "NDK_PATH: ${ANDROID_NDK_PATH}"
|
||||||
|
|
@ -93,6 +116,10 @@ for EXAMPLE in "${EXAMPLES[@]}"; do
|
||||||
echo "Building: ${EXAMPLE}"
|
echo "Building: ${EXAMPLE}"
|
||||||
echo "--------------------------------------------"
|
echo "--------------------------------------------"
|
||||||
|
|
||||||
|
# Clean previous build to avoid stale CMake cache
|
||||||
|
echo "Cleaning: ${EXAMPLE_DIR}/build/android"
|
||||||
|
rm -rf "${EXAMPLE_DIR}/build/android"
|
||||||
|
|
||||||
if bash "${BUILD_SCRIPT}" -a "${TARGET_ABI}"; then
|
if bash "${BUILD_SCRIPT}" -a "${TARGET_ABI}"; then
|
||||||
SUCCEEDED+=("${EXAMPLE}")
|
SUCCEEDED+=("${EXAMPLE}")
|
||||||
echo "[SUCCESS] ${EXAMPLE}"
|
echo "[SUCCESS] ${EXAMPLE}"
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,20 @@ TO DO
|
||||||
|
|
||||||
#### 1. Compile
|
#### 1. Compile
|
||||||
|
|
||||||
|
#### AMLNN SDK Setup
|
||||||
|
|
||||||
|
Resolve the AMLNN nnsdk dependency using one of the following methods:
|
||||||
|
|
||||||
|
- **Priority 1 – Environment variable (recommended)**
|
||||||
|
```bash
|
||||||
|
export AMLNN_HOME=/path/to/amlnn-toolkit
|
||||||
|
```
|
||||||
|
- **Priority 3 – Sibling directory fallback** *(automatic)*
|
||||||
|
Place `amlnn-toolkit` as a sibling to `amlnn-model-playground`:
|
||||||
|
```bash
|
||||||
|
git clone git@github.com:Amlogic-NN/amlnn-toolkit.git ../amlnn-toolkit
|
||||||
|
```
|
||||||
|
|
||||||
**Prerequisites:**
|
**Prerequisites:**
|
||||||
- Android NDK (r25e recommended)
|
- Android NDK (r25e recommended)
|
||||||
- `ANDROID_NDK_PATH` environment variable set
|
- `ANDROID_NDK_PATH` environment variable set
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,8 @@ echo "BUILD_DIR: ${BUILD_DIR}"
|
||||||
mkdir -p ${BUILD_DIR}
|
mkdir -p ${BUILD_DIR}
|
||||||
cd ${BUILD_DIR}
|
cd ${BUILD_DIR}
|
||||||
|
|
||||||
cmake ../../src \
|
cmake -Wno-dev ../../src \
|
||||||
|
-DAMLNN_HOME=${AMLNN_HOME:-} \
|
||||||
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake \
|
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake \
|
||||||
-DANDROID_ABI=${TARGET_ABI} \
|
-DANDROID_ABI=${TARGET_ABI} \
|
||||||
-DANDROID_PLATFORM=android-24 \
|
-DANDROID_PLATFORM=android-24 \
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,13 @@
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.10...3.27)
|
||||||
project(clip_demo)
|
project(clip_demo)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
# Set NNSDK path
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../../../../cmake")
|
||||||
if(NOT DEFINED NNSDK_DIR)
|
find_package(AMLNN REQUIRED)
|
||||||
set(NNSDK_DIR "${CMAKE_SOURCE_DIR}/../../../../../amlnn-toolkit/nn_runtime/nnsdk")
|
include_directories(${AMLNN_INCLUDE_DIR})
|
||||||
endif()
|
link_directories(${AMLNN_LIBRARY_DIR})
|
||||||
set(NNSDK_ROOT "${NNSDK_DIR}")
|
|
||||||
message(STATUS "NNSDK_ROOT: ${NNSDK_ROOT}")
|
|
||||||
|
|
||||||
include_directories(${NNSDK_ROOT}/include)
|
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/../../../../common)
|
include_directories(${CMAKE_SOURCE_DIR}/../../../../common)
|
||||||
|
|
||||||
# Set 3rdparty path
|
# Set 3rdparty path
|
||||||
|
|
@ -22,15 +19,8 @@ include_directories(${3RDPARTY_DIR}/stb_image)
|
||||||
include_directories(${3RDPARTY_DIR}/json)
|
include_directories(${3RDPARTY_DIR}/json)
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
||||||
if (ANDROID_ABI STREQUAL "arm64-v8a")
|
|
||||||
link_directories(${NNSDK_ROOT}/android/arm64-v8a)
|
|
||||||
else()
|
|
||||||
link_directories(${NNSDK_ROOT}/android/armeabi-v7a)
|
|
||||||
endif()
|
|
||||||
# Android needs log
|
# Android needs log
|
||||||
link_libraries(log)
|
link_libraries(log)
|
||||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
||||||
link_directories(${NNSDK_ROOT}/linux/yocto/aarch64-poky-linux)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME}
|
add_executable(${PROJECT_NAME}
|
||||||
|
|
@ -41,7 +31,7 @@ add_executable(${PROJECT_NAME}
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME}
|
target_link_libraries(${PROJECT_NAME}
|
||||||
nnsdk
|
${AMLNN_LIBRARY}
|
||||||
dl
|
dl
|
||||||
m
|
m
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,118 +1,132 @@
|
||||||
## Model Description
|
## Model Description
|
||||||
|
|
||||||
This model is converted from MobileNetV2 pretrained weights
|
This model is converted from MobileNetV2 pretrained weights
|
||||||
originally released by Google under the Apache License 2.0.
|
originally released by Google under the Apache License 2.0.
|
||||||
|
|
||||||
Original model:
|
Original model:
|
||||||
- Architecture: MobileNetV2
|
- Architecture: MobileNetV2
|
||||||
- Source: TensorFlow / Keras official implementation
|
- Source: TensorFlow / Keras official implementation
|
||||||
|
|
||||||
The model has been converted and optimized into ADLA format
|
The model has been converted and optimized into ADLA format
|
||||||
for deployment on Amlogic NPU platforms.
|
for deployment on Amlogic NPU platforms.
|
||||||
|
|
||||||
## Demo Run
|
## Demo Run
|
||||||
|
|
||||||
### CPP
|
### CPP
|
||||||
|
|
||||||
#### 1. Compile
|
#### 1. Compile
|
||||||
|
|
||||||
**Prerequisites:**
|
#### AMLNN SDK Setup
|
||||||
- Android NDK (r25e recommended)
|
|
||||||
- `ANDROID_NDK_PATH` environment variable set
|
Resolve the AMLNN nnsdk dependency using one of the following methods:
|
||||||
|
|
||||||
**Build:**
|
- **Priority 1 – Environment variable (recommended)**
|
||||||
```bash
|
```bash
|
||||||
# Build for arm64-v8a
|
export AMLNN_HOME=/path/to/amlnn-toolkit
|
||||||
cd examples/mobilenet/cpp
|
```
|
||||||
./build-android.sh -a arm64-v8a
|
- **Priority 3 – Sibling directory fallback** *(automatic)*
|
||||||
```
|
Place `amlnn-toolkit` as a sibling to `amlnn-model-playground`:
|
||||||
|
```bash
|
||||||
The executable will be generated at `build/android/mobilenet_v2_demo` (Note: executable name may vary, verify in build folder).
|
git clone git@github.com:Amlogic-NN/amlnn-toolkit.git ../amlnn-toolkit
|
||||||
|
```
|
||||||
#### 2. Run
|
|
||||||
|
**Prerequisites:**
|
||||||
```bash
|
- Android NDK (r25e recommended)
|
||||||
# Push executable to device
|
- `ANDROID_NDK_PATH` environment variable set
|
||||||
adb push build/android/mobilenet_v2_demo /data/local/tmp/
|
|
||||||
adb push model/mobilenet_v2_1.0_224_quant_A311D2.adla /data/local/tmp/
|
**Build:**
|
||||||
adb push model/cat_224x224.jpg /data/local/tmp/
|
```bash
|
||||||
adb push model/labels.txt /data/local/tmp/
|
# Build for arm64-v8a
|
||||||
|
cd examples/mobilenet/cpp
|
||||||
# Run on device
|
./build-android.sh -a arm64-v8a
|
||||||
adb shell
|
```
|
||||||
cd /data/local/tmp
|
|
||||||
chmod +x mobilenet_v2_demo
|
The executable will be generated at `build/android/mobilenet_v2_demo` (Note: executable name may vary, verify in build folder).
|
||||||
export LD_LIBRARY_PATH=/vendor/lib64 or (/vendor/lib)
|
|
||||||
|
#### 2. Run
|
||||||
# Usage: ./mobilenet_v2_demo <model_path> <image_path> <labels_path>
|
|
||||||
./mobilenet_v2_demo mobilenet_v2_1.0_224_quant_A311D2.adla cat_224x224.jpg labels.txt
|
```bash
|
||||||
```
|
# Push executable to device
|
||||||
|
adb push build/android/mobilenet_v2_demo /data/local/tmp/
|
||||||
**Note:** Replace `mobilenet_v2_1.0_224_quant_A311D2.adla` with your actual model file path.
|
adb push model/mobilenet_v2_1.0_224_quant_A311D2.adla /data/local/tmp/
|
||||||
|
adb push model/cat_224x224.jpg /data/local/tmp/
|
||||||
### Python
|
adb push model/labels.txt /data/local/tmp/
|
||||||
|
|
||||||
**Prerequisites:**
|
# Run on device
|
||||||
- Python 3.10
|
adb shell
|
||||||
- Required packages: `numpy`, `Pillow`, `amlnnlite`
|
cd /data/local/tmp
|
||||||
|
chmod +x mobilenet_v2_demo
|
||||||
**Install dependencies:**
|
export LD_LIBRARY_PATH=/vendor/lib64 or (/vendor/lib)
|
||||||
```bash
|
|
||||||
pip install numpy Pillow amlnnlite-1.0.0-cp310-cp310-linux_aarch64.whl
|
# Usage: ./mobilenet_v2_demo <model_path> <image_path> <labels_path>
|
||||||
```
|
./mobilenet_v2_demo mobilenet_v2_1.0_224_quant_A311D2.adla cat_224x224.jpg labels.txt
|
||||||
|
```
|
||||||
**Run on device:**
|
|
||||||
```bash
|
**Note:** Replace `mobilenet_v2_1.0_224_quant_A311D2.adla` with your actual model file path.
|
||||||
# Basic usage
|
|
||||||
python mobilenetv2.py --model-path ./mobilenet_v2_1.0_224_quant_A311D2.adla
|
### Python
|
||||||
|
|
||||||
# Run with performance testing (100 cycles)
|
**Prerequisites:**
|
||||||
python mobilenetv2.py --model-path ./mobilenet_v2_1.0_224_quant_A311D2.adla --run-cycles 100
|
- Python 3.10
|
||||||
```
|
- Required packages: `numpy`, `Pillow`, `amlnnlite`
|
||||||
|
|
||||||
The script will automatically process all image files (`.jpg`, `.jpeg`, `.png`, `.bmp`) in the current directory and display top-5 classification results for each image.
|
**Install dependencies:**
|
||||||
|
```bash
|
||||||
## Results
|
pip install numpy Pillow amlnnlite-1.0.0-cp310-cp310-linux_aarch64.whl
|
||||||
|
```
|
||||||
The program will print the top-5 classification results with probabilities for each processed image.
|
|
||||||
|
**Run on device:**
|
||||||
**Example output:**
|
```bash
|
||||||
```
|
# Basic usage
|
||||||
# python demo result
|
python mobilenetv2.py --model-path ./mobilenet_v2_1.0_224_quant_A311D2.adla
|
||||||
============================================================
|
|
||||||
Processing image 1/3: dog_224x224.jpg
|
# Run with performance testing (100 cycles)
|
||||||
============================================================
|
python mobilenetv2.py --model-path ./mobilenet_v2_1.0_224_quant_A311D2.adla --run-cycles 100
|
||||||
|
```
|
||||||
Top-5 Classification Results:
|
|
||||||
1. Shih-Tzu (probability: 0.9239)
|
The script will automatically process all image files (`.jpg`, `.jpeg`, `.png`, `.bmp`) in the current directory and display top-5 classification results for each image.
|
||||||
2. Pekinese (probability: 0.0476)
|
|
||||||
3. Lhasa (probability: 0.0263)
|
## Results
|
||||||
4. Brabancon griffon (probability: 0.0004)
|
|
||||||
5. Dandie Dinmont (probability: 0.0003)
|
The program will print the top-5 classification results with probabilities for each processed image.
|
||||||
|
|
||||||
============================================================
|
**Example output:**
|
||||||
Processing image 2/3: cat_224x224.jpg
|
```
|
||||||
============================================================
|
# python demo result
|
||||||
|
============================================================
|
||||||
Top-5 Classification Results:
|
Processing image 1/3: dog_224x224.jpg
|
||||||
1. tiger cat (probability: 0.4774)
|
============================================================
|
||||||
2. tabby (probability: 0.4324)
|
|
||||||
3. Egyptian cat (probability: 0.0542)
|
Top-5 Classification Results:
|
||||||
4. lynx (probability: 0.0150)
|
1. Shih-Tzu (probability: 0.9239)
|
||||||
5. Persian cat (probability: 0.0025)
|
2. Pekinese (probability: 0.0476)
|
||||||
|
3. Lhasa (probability: 0.0263)
|
||||||
============================================================
|
4. Brabancon griffon (probability: 0.0004)
|
||||||
Processing image 3/3: fish_224x224.jpeg
|
5. Dandie Dinmont (probability: 0.0003)
|
||||||
============================================================
|
|
||||||
|
============================================================
|
||||||
Top-5 Classification Results:
|
Processing image 2/3: cat_224x224.jpg
|
||||||
1. goldfish (probability: 0.9998)
|
============================================================
|
||||||
2. conch (probability: 0.0001)
|
|
||||||
3. trifle (probability: 0.0000)
|
Top-5 Classification Results:
|
||||||
4. axolotl (probability: 0.0000)
|
1. tiger cat (probability: 0.4774)
|
||||||
5. American lobster (probability: 0.0000)
|
2. tabby (probability: 0.4324)
|
||||||
```
|
3. Egyptian cat (probability: 0.0542)
|
||||||
|
4. lynx (probability: 0.0150)
|
||||||
The classification results show the model's confidence scores (probabilities) for each detected class, with the highest probability indicating the most likely classification.
|
5. Persian cat (probability: 0.0025)
|
||||||
|
|
||||||
|
============================================================
|
||||||
|
Processing image 3/3: fish_224x224.jpeg
|
||||||
|
============================================================
|
||||||
|
|
||||||
|
Top-5 Classification Results:
|
||||||
|
1. goldfish (probability: 0.9998)
|
||||||
|
2. conch (probability: 0.0001)
|
||||||
|
3. trifle (probability: 0.0000)
|
||||||
|
4. axolotl (probability: 0.0000)
|
||||||
|
5. American lobster (probability: 0.0000)
|
||||||
|
```
|
||||||
|
|
||||||
|
The classification results show the model's confidence scores (probabilities) for each detected class, with the highest probability indicating the most likely classification.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,8 @@ echo "BUILD_DIR: ${BUILD_DIR}"
|
||||||
mkdir -p ${BUILD_DIR}
|
mkdir -p ${BUILD_DIR}
|
||||||
cd ${BUILD_DIR}
|
cd ${BUILD_DIR}
|
||||||
|
|
||||||
cmake ../../src \
|
cmake -Wno-dev ../../src \
|
||||||
|
-DAMLNN_HOME=${AMLNN_HOME:-} \
|
||||||
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake \
|
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake \
|
||||||
-DANDROID_ABI=${TARGET_ABI} \
|
-DANDROID_ABI=${TARGET_ABI} \
|
||||||
-DANDROID_PLATFORM=android-24 \
|
-DANDROID_PLATFORM=android-24 \
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,21 @@
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.10...3.27)
|
||||||
project(mobilenet_v2_demo)
|
project(mobilenet_v2_demo)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
# Set NNSDK path
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../../../../cmake")
|
||||||
if(NOT DEFINED NNSDK_DIR)
|
find_package(AMLNN REQUIRED)
|
||||||
set(NNSDK_DIR "${CMAKE_SOURCE_DIR}/../../../../../amlnn-toolkit/nn_runtime/nnsdk")
|
include_directories(${AMLNN_INCLUDE_DIR})
|
||||||
endif()
|
link_directories(${AMLNN_LIBRARY_DIR})
|
||||||
set(NNSDK_ROOT "${NNSDK_DIR}")
|
|
||||||
message(STATUS "NNSDK_ROOT: ${NNSDK_ROOT}")
|
|
||||||
|
|
||||||
include_directories(${NNSDK_ROOT}/include)
|
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/../../../../common)
|
include_directories(${CMAKE_SOURCE_DIR}/../../../../common)
|
||||||
|
|
||||||
# Set dependency path
|
# Set dependency path
|
||||||
set(3RDPARTY_DIR "${CMAKE_SOURCE_DIR}/../../../../dependency")
|
set(3RDPARTY_DIR "${CMAKE_SOURCE_DIR}/../../../../dependency")
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
||||||
if (ANDROID_ABI STREQUAL "arm64-v8a")
|
|
||||||
link_directories(${NNSDK_ROOT}/android/arm64-v8a)
|
|
||||||
else()
|
|
||||||
link_directories(${NNSDK_ROOT}/android/armeabi-v7a)
|
|
||||||
endif()
|
|
||||||
# Android needs log
|
# Android needs log
|
||||||
link_libraries(log)
|
link_libraries(log)
|
||||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
||||||
link_directories(${NNSDK_ROOT}/linux/yocto/aarch64-poky-linux)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Find OpenCV
|
# Find OpenCV
|
||||||
|
|
@ -40,5 +30,5 @@ add_executable(mobilenet_v2_demo
|
||||||
|
|
||||||
target_link_libraries(mobilenet_v2_demo
|
target_link_libraries(mobilenet_v2_demo
|
||||||
${OpenCV_LIBS}
|
${OpenCV_LIBS}
|
||||||
nnsdk
|
${AMLNN_LIBRARY}
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
# PaddleOCR Detection
|
||||||
|
|
||||||
|
## 4. Demo Run
|
||||||
|
|
||||||
|
### CPP
|
||||||
|
|
||||||
|
#### 1. Compile
|
||||||
|
|
||||||
|
#### AMLNN SDK Setup
|
||||||
|
|
||||||
|
Resolve the AMLNN nnsdk dependency using one of the following methods:
|
||||||
|
|
||||||
|
- **Priority 1 – Environment variable (recommended)**
|
||||||
|
```bash
|
||||||
|
export AMLNN_HOME=/path/to/amlnn-toolkit
|
||||||
|
```
|
||||||
|
- **Priority 3 – Sibling directory fallback** *(automatic)*
|
||||||
|
Place `amlnn-toolkit` as a sibling to `amlnn-model-playground`:
|
||||||
|
```bash
|
||||||
|
git clone git@github.com:Amlogic-NN/amlnn-toolkit.git ../amlnn-toolkit
|
||||||
|
```
|
||||||
|
|
||||||
|
**Prerequisites:**
|
||||||
|
- Android NDK r25c
|
||||||
|
- `ANDROID_NDK_PATH` environment variable set
|
||||||
|
|
||||||
|
**Build:**
|
||||||
|
```bash
|
||||||
|
# Build for arm64-v8a
|
||||||
|
cd examples/ppocr-det/cpp
|
||||||
|
./build-android.sh -a arm64-v8a
|
||||||
|
```
|
||||||
|
|
||||||
|
The executable will be generated in `build/android/`.
|
||||||
|
|
@ -65,7 +65,8 @@ echo "BUILD_DIR: ${BUILD_DIR}"
|
||||||
mkdir -p ${BUILD_DIR}
|
mkdir -p ${BUILD_DIR}
|
||||||
cd ${BUILD_DIR}
|
cd ${BUILD_DIR}
|
||||||
|
|
||||||
cmake ../../src \
|
cmake -Wno-dev ../../src \
|
||||||
|
-DAMLNN_HOME=${AMLNN_HOME:-} \
|
||||||
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake \
|
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake \
|
||||||
-DANDROID_ABI=${TARGET_ABI} \
|
-DANDROID_ABI=${TARGET_ABI} \
|
||||||
-DANDROID_PLATFORM=android-24 \
|
-DANDROID_PLATFORM=android-24 \
|
||||||
|
|
|
||||||
|
|
@ -1,48 +1,38 @@
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.10...3.27)
|
||||||
project(yolo_world_demo)
|
project(yolo_world_demo)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
# Set NNSDK path
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../../../../cmake")
|
||||||
if(NOT DEFINED NNSDK_DIR)
|
find_package(AMLNN REQUIRED)
|
||||||
set(NNSDK_DIR "${CMAKE_SOURCE_DIR}/../../../../../amlnn-toolkit/nn_runtime/nnsdk")
|
include_directories(${AMLNN_INCLUDE_DIR})
|
||||||
endif()
|
link_directories(${AMLNN_LIBRARY_DIR})
|
||||||
set(NNSDK_ROOT "${NNSDK_DIR}")
|
|
||||||
message(STATUS "NNSDK_ROOT: ${NNSDK_ROOT}")
|
include_directories(${CMAKE_SOURCE_DIR}/../../../../common)
|
||||||
|
|
||||||
include_directories(${NNSDK_ROOT}/include)
|
# Set 3rdparty path
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/../../../../common)
|
set(3RDPARTY_DIR "${CMAKE_SOURCE_DIR}/../../../../dependency")
|
||||||
|
|
||||||
# Set 3rdparty path
|
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
||||||
set(3RDPARTY_DIR "${CMAKE_SOURCE_DIR}/../../../../dependency")
|
# Android needs log
|
||||||
|
link_libraries(log)
|
||||||
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
endif()
|
||||||
if (ANDROID_ABI STREQUAL "arm64-v8a")
|
|
||||||
link_directories(${NNSDK_ROOT}/android/arm64-v8a)
|
# Find OpenCV
|
||||||
else()
|
message(STATUS "OpenCV_DIR: ${OpenCV_DIR}")
|
||||||
link_directories(${NNSDK_ROOT}/android/armeabi-v7a)
|
find_package(OpenCV REQUIRED)
|
||||||
endif()
|
include_directories(${OpenCV_INCLUDE_DIRS})
|
||||||
# Android needs log
|
|
||||||
link_libraries(log)
|
add_executable(paddleocr_det_demo
|
||||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
main.cpp
|
||||||
link_directories(${NNSDK_ROOT}/linux/yocto/aarch64-poky-linux)
|
postprocess.cpp
|
||||||
endif()
|
postprocess.h
|
||||||
|
clipper.cpp
|
||||||
# Find OpenCV
|
clipper.h
|
||||||
message(STATUS "OpenCV_DIR: ${OpenCV_DIR}")
|
${CMAKE_SOURCE_DIR}/../../../../common/model_loader.cpp
|
||||||
find_package(OpenCV REQUIRED)
|
)
|
||||||
include_directories(${OpenCV_INCLUDE_DIRS})
|
|
||||||
|
target_link_libraries(paddleocr_det_demo
|
||||||
add_executable(paddleocr_det_demo
|
${OpenCV_LIBS}
|
||||||
main.cpp
|
${AMLNN_LIBRARY}
|
||||||
postprocess.cpp
|
)
|
||||||
postprocess.h
|
|
||||||
clipper.cpp
|
|
||||||
clipper.h
|
|
||||||
${CMAKE_SOURCE_DIR}/../../../../common/model_loader.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(paddleocr_det_demo
|
|
||||||
${OpenCV_LIBS}
|
|
||||||
nnsdk
|
|
||||||
)
|
|
||||||
|
|
|
||||||
|
|
@ -1,165 +1,179 @@
|
||||||
# resnet
|
# resnet
|
||||||
|
|
||||||
## 1.Overview
|
## 1.Overview
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 2.Model Download
|
## 2.Model Download
|
||||||
|
|
||||||
- **Open Source model**
|
- **Open Source model**
|
||||||
|
|
||||||
- **Open Source projects:**
|
- **Open Source projects:**
|
||||||
|
|
||||||
- **Export Model Step:**
|
- **Export Model Step:**
|
||||||
|
|
||||||
- **Install ultralytics**
|
- **Install ultralytics**
|
||||||
|
|
||||||
pip install torch==2.4.1
|
pip install torch==2.4.1
|
||||||
|
|
||||||
pip install torchvision==0.19.1
|
pip install torchvision==0.19.1
|
||||||
|
|
||||||
pip install ultralytics==8.3.0
|
pip install ultralytics==8.3.0
|
||||||
|
|
||||||
- **Download weights**
|
- **Download weights**
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- **Export Model**
|
- **Export Model**
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
- **Exported Model**
|
- **Exported Model**
|
||||||
|
|
||||||
link to amlogic server( **onnx model or quantized tflite**)
|
link to amlogic server( **onnx model or quantized tflite**)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 3. Model Conversion
|
## 3. Model Conversion
|
||||||
|
|
||||||
```
|
```
|
||||||
cd model
|
cd model
|
||||||
Usage: ./adla_covnert.sh model_path adla_tookkit_path target_platform
|
Usage: ./adla_covnert.sh model_path adla_tookkit_path target_platform
|
||||||
|
|
||||||
example
|
example
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
| Parameter | Discription |
|
| Parameter | Discription |
|
||||||
| ----------------- | ------------------------------------------------------------ |
|
| ----------------- | ------------------------------------------------------------ |
|
||||||
| model_path | onnx model path |
|
| model_path | onnx model path |
|
||||||
| adla_tookkit_path | path to adla_toolkit |
|
| adla_tookkit_path | path to adla_toolkit |
|
||||||
| target_platform | Specify target platform. for A311D2 : PRODUCT_PID0XA003. for S905X5: PRODUCT_PID0XA005 |
|
| target_platform | Specify target platform. for A311D2 : PRODUCT_PID0XA003. for S905X5: PRODUCT_PID0XA005 |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 4. Demo Run
|
## 4. Demo Run
|
||||||
|
|
||||||
### CPP
|
### CPP
|
||||||
|
|
||||||
#### 1. Compile
|
#### 1. Compile
|
||||||
|
|
||||||
**Prerequisites:**
|
#### AMLNN SDK Setup
|
||||||
- Android NDK (r25e recommended)
|
|
||||||
- `ANDROID_NDK_PATH` environment variable set
|
Resolve the AMLNN nnsdk dependency using one of the following methods:
|
||||||
|
|
||||||
**Build:**
|
- **Priority 1 – Environment variable (recommended)**
|
||||||
```bash
|
```bash
|
||||||
# Build for arm64-v8a
|
export AMLNN_HOME=/path/to/amlnn-toolkit
|
||||||
cd examples/resnet/cpp
|
```
|
||||||
./build-android.sh -a arm64-v8a
|
- **Priority 3 – Sibling directory fallback** *(automatic)*
|
||||||
```
|
Place `amlnn-toolkit` as a sibling to `amlnn-model-playground`:
|
||||||
|
```bash
|
||||||
The executable will be generated at `build/android/resnet_demo` (Note: executable name may vary, verify in build folder).
|
git clone git@github.com:Amlogic-NN/amlnn-toolkit.git ../amlnn-toolkit
|
||||||
|
```
|
||||||
#### 2. Run
|
|
||||||
|
**Prerequisites:**
|
||||||
```bash
|
- Android NDK (r25e recommended)
|
||||||
# Push executable to device
|
- `ANDROID_NDK_PATH` environment variable set
|
||||||
adb push build/android/resnet_demo /data/local/tmp/
|
|
||||||
adb push model/res2net50_int8_A311D2.adla /data/local/tmp/
|
**Build:**
|
||||||
adb push imgs /data/local/tmp/
|
```bash
|
||||||
adb push labels.txt /data/local/tmp/
|
# Build for arm64-v8a
|
||||||
|
cd examples/resnet/cpp
|
||||||
# Run on device
|
./build-android.sh -a arm64-v8a
|
||||||
adb shell
|
```
|
||||||
cd /data/local/tmp
|
|
||||||
chmod +x resnet_demo
|
The executable will be generated at `build/android/resnet_demo` (Note: executable name may vary, verify in build folder).
|
||||||
export LD_LIBRARY_PATH=/vendor/lib64 or (/vendor/lib)
|
|
||||||
|
#### 2. Run
|
||||||
# Usage: ./resnet_demo <model_path> <image_dir> <labels.txt>
|
|
||||||
./resnet_demo res2net50_int8_A311D2.adla imgs/ labels.txt
|
```bash
|
||||||
```
|
# Push executable to device
|
||||||
|
adb push build/android/resnet_demo /data/local/tmp/
|
||||||
**Note:** Replace `res2net50_int8_A311D2.adla` with your actual model file path.
|
adb push model/res2net50_int8_A311D2.adla /data/local/tmp/
|
||||||
|
adb push imgs /data/local/tmp/
|
||||||
### Python
|
adb push labels.txt /data/local/tmp/
|
||||||
|
|
||||||
**Prerequisites:**
|
# Run on device
|
||||||
- Python 3.10
|
adb shell
|
||||||
- Required packages: `numpy`, `opencv-python`, `amlnnlite`
|
cd /data/local/tmp
|
||||||
|
chmod +x resnet_demo
|
||||||
**Install dependencies:**
|
export LD_LIBRARY_PATH=/vendor/lib64 or (/vendor/lib)
|
||||||
```bash
|
|
||||||
pip install numpy opencv-python amlnnlite-1.0.0-cp310-cp310-linux_aarch64.whl
|
# Usage: ./resnet_demo <model_path> <image_dir> <labels.txt>
|
||||||
```
|
./resnet_demo res2net50_int8_A311D2.adla imgs/ labels.txt
|
||||||
|
```
|
||||||
**Run on device:**
|
|
||||||
```bash
|
**Note:** Replace `res2net50_int8_A311D2.adla` with your actual model file path.
|
||||||
python resnet.py \
|
|
||||||
--model-path ./res2net50_int8_A311D2.adla \
|
### Python
|
||||||
--image-dir ./imgs \
|
|
||||||
--labels labels.txt \
|
**Prerequisites:**
|
||||||
--run-cycles 1 \
|
- Python 3.10
|
||||||
--loglevel INFO
|
- Required packages: `numpy`, `opencv-python`, `amlnnlite`
|
||||||
```
|
|
||||||
Argument Descriptions:
|
**Install dependencies:**
|
||||||
| Argument | Description |
|
```bash
|
||||||
| ----------------- | ------------------------------------------------------------ |
|
pip install numpy opencv-python amlnnlite-1.0.0-cp310-cp310-linux_aarch64.whl
|
||||||
| --board-work-path | Work path on board, default is /data/local/tmp |
|
```
|
||||||
| --model-path | path to .adla model |
|
|
||||||
| --image-dir | Directory containing test images |
|
**Run on device:**
|
||||||
| --labels | Path to synset_words.txt or labels.txt |
|
```bash
|
||||||
| --run-cycles | Number of inference cycles, default is 1 |
|
python resnet.py \
|
||||||
| --loglevel | Logging level: DEBUG / INFO / WARNING / ERROR, default is WARNING |
|
--model-path ./res2net50_int8_A311D2.adla \
|
||||||
|
--image-dir ./imgs \
|
||||||
The script will automatically process all image files (`.jpg`, `.jpeg`, `.png`, `.bmp`) in the current directory and save results to a `{model_name}_result` folder.
|
--labels labels.txt \
|
||||||
|
--run-cycles 1 \
|
||||||
## 5.Results
|
--loglevel INFO
|
||||||
**Performance Feedback**
|
```
|
||||||
|
Argument Descriptions:
|
||||||
By setting the loglevel to INFO, the program provides real-time performance metrics upon completion. The console log will display essential hardware and execution details, including:
|
| Argument | Description |
|
||||||
- Hardware Information: System and ADLA library versions.
|
| ----------------- | ------------------------------------------------------------ |
|
||||||
- Model Overview: Basic input/output configurations.
|
| --board-work-path | Work path on board, default is /data/local/tmp |
|
||||||
- NPU Metrics: Total inference time (latency) and total DRAM bandwidth consumption.
|
| --model-path | path to .adla model |
|
||||||
|
| --image-dir | Directory containing test images |
|
||||||
**Classification Output**
|
| --labels | Path to synset_words.txt or labels.txt |
|
||||||
|
| --run-cycles | Number of inference cycles, default is 1 |
|
||||||
For each image, the program prints the Top-5 classification results with their respective scores:
|
| --loglevel | Logging level: DEBUG / INFO / WARNING / ERROR, default is WARNING |
|
||||||
```bash
|
|
||||||
============================================================
|
The script will automatically process all image files (`.jpg`, `.jpeg`, `.png`, `.bmp`) in the current directory and save results to a `{model_name}_result` folder.
|
||||||
Processing image 1/1: dog.jpg
|
|
||||||
============================================================ Top-5 Results:
|
## 5.Results
|
||||||
1: Pekinese score=9.851644
|
**Performance Feedback**
|
||||||
2: West Highland white terrier score=5.055449
|
|
||||||
3: Maltese dog score=4.796195
|
By setting the loglevel to INFO, the program provides real-time performance metrics upon completion. The console log will display essential hardware and execution details, including:
|
||||||
4: basenji score=3.111045
|
- Hardware Information: System and ADLA library versions.
|
||||||
5: Scotch terrier score=2.786978 ============================================================
|
- Model Overview: Basic input/output configurations.
|
||||||
```
|
- NPU Metrics: Total inference time (latency) and total DRAM bandwidth consumption.
|
||||||
**Profiling Visualization**
|
|
||||||
|
**Classification Output**
|
||||||
After a successful run of the Python demo, a folder named after the model (e.g., `{model_name}`) will be generated in the script directory. This folder contains 5 HTML files that provide a visual and detailed breakdown of per-layer performance:
|
|
||||||
- `hard_op_chart.html` & `soft_op_chart.html`: Hardware/Software op execution details.
|
For each image, the program prints the Top-5 classification results with their respective scores:
|
||||||
- `dram_rd_chart.html` & `dram_wr_chart.html`: Bandwidth read/write distribution.
|
```bash
|
||||||
- `pie_charts_distribution.html`: Overall resource allocation.
|
============================================================
|
||||||
|
Processing image 1/1: dog.jpg
|
||||||
You can pull the result folder back to view it:
|
============================================================ Top-5 Results:
|
||||||
```bash
|
1: Pekinese score=9.851644
|
||||||
adb pull /data/local/tmp/res2net50_int8_A311D2
|
2: West Highland white terrier score=5.055449
|
||||||
```
|
3: Maltese dog score=4.796195
|
||||||
|
4: basenji score=3.111045
|
||||||
Taking hard_op_chart.html as an example (shown below), each layer's ADLA operator name includes parentheses containing the index of the corresponding quantized .tflite layer(s); by default, these indices are suppressed, and operators are labeled generically as "hardware" or "software" without numerical suffixes.
|
5: Scotch terrier score=2.786978 ============================================================
|
||||||
|
```
|
||||||
|
**Profiling Visualization**
|
||||||
|
|
||||||
|
After a successful run of the Python demo, a folder named after the model (e.g., `{model_name}`) will be generated in the script directory. This folder contains 5 HTML files that provide a visual and detailed breakdown of per-layer performance:
|
||||||
|
- `hard_op_chart.html` & `soft_op_chart.html`: Hardware/Software op execution details.
|
||||||
|
- `dram_rd_chart.html` & `dram_wr_chart.html`: Bandwidth read/write distribution.
|
||||||
|
- `pie_charts_distribution.html`: Overall resource allocation.
|
||||||
|
|
||||||
|
You can pull the result folder back to view it:
|
||||||
|
```bash
|
||||||
|
adb pull /data/local/tmp/res2net50_int8_A311D2
|
||||||
|
```
|
||||||
|
|
||||||
|
Taking hard_op_chart.html as an example (shown below), each layer's ADLA operator name includes parentheses containing the index of the corresponding quantized .tflite layer(s); by default, these indices are suppressed, and operators are labeled generically as "hardware" or "software" without numerical suffixes.
|
||||||
|
|
||||||

|

|
||||||
|
|
@ -65,7 +65,8 @@ echo "BUILD_DIR: ${BUILD_DIR}"
|
||||||
mkdir -p ${BUILD_DIR}
|
mkdir -p ${BUILD_DIR}
|
||||||
cd ${BUILD_DIR}
|
cd ${BUILD_DIR}
|
||||||
|
|
||||||
cmake ../../src \
|
cmake -Wno-dev ../../src \
|
||||||
|
-DAMLNN_HOME=${AMLNN_HOME:-} \
|
||||||
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake \
|
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake \
|
||||||
-DANDROID_ABI=${TARGET_ABI} \
|
-DANDROID_ABI=${TARGET_ABI} \
|
||||||
-DANDROID_PLATFORM=android-24 \
|
-DANDROID_PLATFORM=android-24 \
|
||||||
|
|
|
||||||
|
|
@ -1,46 +1,35 @@
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.10...3.27)
|
||||||
project(resnet_demo)
|
project(resnet_demo)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
# Set NNSDK path
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../../../../cmake")
|
||||||
if(NOT DEFINED NNSDK_DIR)
|
find_package(AMLNN REQUIRED)
|
||||||
set(NNSDK_DIR "${CMAKE_SOURCE_DIR}/../../../../../amlnn-toolkit/nn_runtime/nnsdk")
|
include_directories(${AMLNN_INCLUDE_DIR})
|
||||||
endif()
|
link_directories(${AMLNN_LIBRARY_DIR})
|
||||||
set(NNSDK_ROOT "${NNSDK_DIR}")
|
|
||||||
message(STATUS "NNSDK_ROOT: ${NNSDK_ROOT}")
|
include_directories(${CMAKE_SOURCE_DIR}/../../../../common)
|
||||||
|
|
||||||
include_directories(${NNSDK_ROOT}/include)
|
# Set dependency path
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/../../../../common)
|
set(3RDPARTY_DIR "${CMAKE_SOURCE_DIR}/../../../../dependency")
|
||||||
|
|
||||||
# Set dependency path
|
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
||||||
set(3RDPARTY_DIR "${CMAKE_SOURCE_DIR}/../../../../dependency")
|
# Android needs log
|
||||||
|
link_libraries(log)
|
||||||
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
endif()
|
||||||
if (ANDROID_ABI STREQUAL "arm64-v8a")
|
|
||||||
link_directories(${NNSDK_ROOT}/android/arm64-v8a)
|
# Find OpenCV
|
||||||
else()
|
message(STATUS "OpenCV_DIR: ${OpenCV_DIR}")
|
||||||
link_directories(${NNSDK_ROOT}/android/armeabi-v7a)
|
find_package(OpenCV REQUIRED)
|
||||||
endif()
|
include_directories(${OpenCV_INCLUDE_DIRS})
|
||||||
# Android needs log
|
|
||||||
link_libraries(log)
|
add_executable(resnet_demo
|
||||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
main.cpp
|
||||||
link_directories(${NNSDK_ROOT}/linux/yocto/aarch64-poky-linux)
|
postprocess.cpp
|
||||||
endif()
|
${CMAKE_SOURCE_DIR}/../../../../common/model_loader.cpp
|
||||||
|
)
|
||||||
# Find OpenCV
|
|
||||||
message(STATUS "OpenCV_DIR: ${OpenCV_DIR}")
|
target_link_libraries(resnet_demo
|
||||||
find_package(OpenCV REQUIRED)
|
${OpenCV_LIBS}
|
||||||
include_directories(${OpenCV_INCLUDE_DIRS})
|
${AMLNN_LIBRARY}
|
||||||
|
|
||||||
|
|
||||||
add_executable(resnet_demo
|
|
||||||
main.cpp
|
|
||||||
postprocess.cpp
|
|
||||||
${CMAKE_SOURCE_DIR}/../../../../common/model_loader.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(resnet_demo
|
|
||||||
${OpenCV_LIBS}
|
|
||||||
nnsdk
|
|
||||||
)
|
)
|
||||||
|
|
@ -1,160 +1,174 @@
|
||||||
# retinaface
|
# retinaface
|
||||||
|
|
||||||
## 1.Overview
|
## 1.Overview
|
||||||
|
|
||||||
|
|
||||||
## 2.Model Download
|
## 2.Model Download
|
||||||
|
|
||||||
- **Open Source model**
|
- **Open Source model**
|
||||||
|
|
||||||
- **Open Source projects:**
|
- **Open Source projects:**
|
||||||
|
|
||||||
- **Export Model Step:**
|
- **Export Model Step:**
|
||||||
|
|
||||||
- **Install ultralytics**
|
- **Install ultralytics**
|
||||||
|
|
||||||
pip install torch==2.4.1
|
pip install torch==2.4.1
|
||||||
|
|
||||||
pip install torchvision==0.19.1
|
pip install torchvision==0.19.1
|
||||||
|
|
||||||
pip install ultralytics==8.3.0
|
pip install ultralytics==8.3.0
|
||||||
|
|
||||||
- **Download weights**
|
- **Download weights**
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- **Export Model**
|
- **Export Model**
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- **Exported Model**
|
- **Exported Model**
|
||||||
|
|
||||||
link to amlogic server( **onnx model or quantized tflite**)
|
link to amlogic server( **onnx model or quantized tflite**)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 3. Model Conversion
|
## 3. Model Conversion
|
||||||
|
|
||||||
```
|
```
|
||||||
cd model
|
cd model
|
||||||
Usage: ./adla_covnert.sh model_path adla_tookkit_path target_platform
|
Usage: ./adla_covnert.sh model_path adla_tookkit_path target_platform
|
||||||
|
|
||||||
example
|
example
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
| Parameter | Discription |
|
| Parameter | Discription |
|
||||||
| ----------------- | ------------------------------------------------------------ |
|
| ----------------- | ------------------------------------------------------------ |
|
||||||
| model_path | onnx model path |
|
| model_path | onnx model path |
|
||||||
| adla_tookkit_path | path to adla_toolkit |
|
| adla_tookkit_path | path to adla_toolkit |
|
||||||
| target_platform | Specify target platform. for A311D2 : PRODUCT_PID0XA003. for S905X5: PRODUCT_PID0XA005 |
|
| target_platform | Specify target platform. for A311D2 : PRODUCT_PID0XA003. for S905X5: PRODUCT_PID0XA005 |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 4. Demo Run
|
## 4. Demo Run
|
||||||
|
|
||||||
### CPP
|
### CPP
|
||||||
|
|
||||||
#### 1. Compile
|
#### 1. Compile
|
||||||
|
|
||||||
**Prerequisites:**
|
#### AMLNN SDK Setup
|
||||||
- Android NDK (r25e recommended)
|
|
||||||
- `ANDROID_NDK_PATH` environment variable set
|
Resolve the AMLNN nnsdk dependency using one of the following methods:
|
||||||
|
|
||||||
**Build:**
|
- **Priority 1 – Environment variable (recommended)**
|
||||||
```bash
|
```bash
|
||||||
# Build for arm64-v8a
|
export AMLNN_HOME=/path/to/amlnn-toolkit
|
||||||
cd examples/retinaface/cpp
|
```
|
||||||
./build-android.sh -a arm64-v8a
|
- **Priority 3 – Sibling directory fallback** *(automatic)*
|
||||||
```
|
Place `amlnn-toolkit` as a sibling to `amlnn-model-playground`:
|
||||||
|
```bash
|
||||||
The executable will be generated at `build/android/retinaface_demo` (Note: executable name may vary, verify in build folder).
|
git clone git@github.com:Amlogic-NN/amlnn-toolkit.git ../amlnn-toolkit
|
||||||
|
```
|
||||||
#### 2. Run
|
|
||||||
|
**Prerequisites:**
|
||||||
```bash
|
- Android NDK (r25e recommended)
|
||||||
# Push executable to device
|
- `ANDROID_NDK_PATH` environment variable set
|
||||||
adb push build/android/retinaface_demo /data/local/tmp/
|
|
||||||
adb push model/RetinaFace_int8_A311D2.adla /data/local/tmp/
|
**Build:**
|
||||||
adb push imgs /data/local/tmp/
|
```bash
|
||||||
|
# Build for arm64-v8a
|
||||||
# Run on device
|
cd examples/retinaface/cpp
|
||||||
adb shell
|
./build-android.sh -a arm64-v8a
|
||||||
cd /data/local/tmp
|
```
|
||||||
chmod +x retinaface_demo
|
|
||||||
export LD_LIBRARY_PATH=/vendor/lib64 or (/vendor/lib)
|
The executable will be generated at `build/android/retinaface_demo` (Note: executable name may vary, verify in build folder).
|
||||||
|
|
||||||
# Usage: ./retinaface_demo <model_path> <image_dir>
|
#### 2. Run
|
||||||
./retinaface_demo RetinaFace_int8_A311D2.adla ./imgs
|
|
||||||
```
|
```bash
|
||||||
|
# Push executable to device
|
||||||
**Note:** Replace `RetinaFace_int8_A311D2.adla` with your actual model file path.
|
adb push build/android/retinaface_demo /data/local/tmp/
|
||||||
|
adb push model/RetinaFace_int8_A311D2.adla /data/local/tmp/
|
||||||
### Python
|
adb push imgs /data/local/tmp/
|
||||||
|
|
||||||
**Prerequisites:**
|
# Run on device
|
||||||
- Python 3.10
|
adb shell
|
||||||
- Required packages: `numpy`, `opencv-python`, `amlnnlite`
|
cd /data/local/tmp
|
||||||
|
chmod +x retinaface_demo
|
||||||
**Install dependencies:**
|
export LD_LIBRARY_PATH=/vendor/lib64 or (/vendor/lib)
|
||||||
```bash
|
|
||||||
pip install numpy opencv-python amlnnlite-1.0.0-cp310-cp310-linux_aarch64.whl
|
# Usage: ./retinaface_demo <model_path> <image_dir>
|
||||||
```
|
./retinaface_demo RetinaFace_int8_A311D2.adla ./imgs
|
||||||
|
```
|
||||||
**Run on device:**
|
|
||||||
```bash
|
**Note:** Replace `RetinaFace_int8_A311D2.adla` with your actual model file path.
|
||||||
python RetinaFace.py \
|
|
||||||
--model-path ./RetinaFace_int8_A311D2.adla \
|
### Python
|
||||||
--image-dir ./imgs \
|
|
||||||
--run-cycles 1 \
|
**Prerequisites:**
|
||||||
--loglevel INFO
|
- Python 3.10
|
||||||
```
|
- Required packages: `numpy`, `opencv-python`, `amlnnlite`
|
||||||
|
|
||||||
Argument Descriptions:
|
**Install dependencies:**
|
||||||
| Argument | Description |
|
```bash
|
||||||
| ----------------- | ------------------------------------------------------------ |
|
pip install numpy opencv-python amlnnlite-1.0.0-cp310-cp310-linux_aarch64.whl
|
||||||
| --board-work-path | Work path on board, default is /data/local/tmp |
|
```
|
||||||
| --model-path | path to .adla model |
|
|
||||||
| --image-dir | Directory containing test images |
|
**Run on device:**
|
||||||
| --run-cycles | Number of inference cycles, default is 1 |
|
```bash
|
||||||
| --loglevel | Logging level: DEBUG / INFO / WARNING / ERROR, default is WARNING |
|
python RetinaFace.py \
|
||||||
|
--model-path ./RetinaFace_int8_A311D2.adla \
|
||||||
The script will automatically process all image files (`.jpg`, `.jpeg`, `.png`, `.bmp`) in the current directory and save results to a `{model_name}_result` folder.
|
--image-dir ./imgs \
|
||||||
|
--run-cycles 1 \
|
||||||
## 5.Results
|
--loglevel INFO
|
||||||
|
```
|
||||||
**Performance Feedback**
|
|
||||||
|
Argument Descriptions:
|
||||||
By setting the loglevel to INFO, the program provides real-time performance metrics upon completion. The console log will display essential hardware and execution details, including:
|
| Argument | Description |
|
||||||
- Hardware Information: System and ADLA library versions.
|
| ----------------- | ------------------------------------------------------------ |
|
||||||
- Model Overview: Basic input/output configurations.
|
| --board-work-path | Work path on board, default is /data/local/tmp |
|
||||||
- NPU Metrics: Total inference time (latency) and total DRAM bandwidth consumption.
|
| --model-path | path to .adla model |
|
||||||
|
| --image-dir | Directory containing test images |
|
||||||
**Detection Output**
|
| --run-cycles | Number of inference cycles, default is 1 |
|
||||||
|
| --loglevel | Logging level: DEBUG / INFO / WARNING / ERROR, default is WARNING |
|
||||||
The program will print the detection count. The output images, featuring bounding boxes and five facial landmarks (eyes, nose, and mouth corners), will be saved to the `{model_name}_result` folder.
|
|
||||||
|
The script will automatically process all image files (`.jpg`, `.jpeg`, `.png`, `.bmp`) in the current directory and save results to a `{model_name}_result` folder.
|
||||||
|
|
||||||
You can pull the result folder back to view it:
|
## 5.Results
|
||||||
```bash
|
|
||||||
adb pull /data/local/tmp/RetinaFace_int8_A311D2_result
|
**Performance Feedback**
|
||||||
```
|
|
||||||

|
By setting the loglevel to INFO, the program provides real-time performance metrics upon completion. The console log will display essential hardware and execution details, including:
|
||||||
|
- Hardware Information: System and ADLA library versions.
|
||||||
|
- Model Overview: Basic input/output configurations.
|
||||||
**Profiling Visualization**
|
- NPU Metrics: Total inference time (latency) and total DRAM bandwidth consumption.
|
||||||
|
|
||||||
After a successful run of the Python demo, a folder named after the model (e.g., `{model_name}`) will be generated in the script directory. This folder contains 5 HTML files that provide a visual and detailed breakdown of per-layer performance:
|
**Detection Output**
|
||||||
- `hard_op_chart.html` & `soft_op_chart.html`: Hardware/Software op execution details.
|
|
||||||
- `dram_rd_chart.html` & `dram_wr_chart.html`: Bandwidth read/write distribution.
|
The program will print the detection count. The output images, featuring bounding boxes and five facial landmarks (eyes, nose, and mouth corners), will be saved to the `{model_name}_result` folder.
|
||||||
- `pie_charts_distribution.html`: Overall resource allocation.
|
|
||||||
|
|
||||||
You can pull the result folder back to view it:
|
You can pull the result folder back to view it:
|
||||||
```bash
|
```bash
|
||||||
adb pull /data/local/tmp/RetinaFace_int8_A311D2
|
adb pull /data/local/tmp/RetinaFace_int8_A311D2_result
|
||||||
```
|
```
|
||||||
|

|
||||||
Taking hard_op_chart.html as an example (shown below), each layer's ADLA operator name includes parentheses containing the index of the corresponding quantized .tflite layer(s); by default, these indices are suppressed, and operators are labeled generically as "hardware" or "software" without numerical suffixes.
|
|
||||||
|
|
||||||

|
**Profiling Visualization**
|
||||||
|
|
||||||
|
After a successful run of the Python demo, a folder named after the model (e.g., `{model_name}`) will be generated in the script directory. This folder contains 5 HTML files that provide a visual and detailed breakdown of per-layer performance:
|
||||||
|
- `hard_op_chart.html` & `soft_op_chart.html`: Hardware/Software op execution details.
|
||||||
|
- `dram_rd_chart.html` & `dram_wr_chart.html`: Bandwidth read/write distribution.
|
||||||
|
- `pie_charts_distribution.html`: Overall resource allocation.
|
||||||
|
|
||||||
|
You can pull the result folder back to view it:
|
||||||
|
```bash
|
||||||
|
adb pull /data/local/tmp/RetinaFace_int8_A311D2
|
||||||
|
```
|
||||||
|
|
||||||
|
Taking hard_op_chart.html as an example (shown below), each layer's ADLA operator name includes parentheses containing the index of the corresponding quantized .tflite layer(s); by default, these indices are suppressed, and operators are labeled generically as "hardware" or "software" without numerical suffixes.
|
||||||
|
|
||||||
|

|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,8 @@ echo "BUILD_DIR: ${BUILD_DIR}"
|
||||||
mkdir -p ${BUILD_DIR}
|
mkdir -p ${BUILD_DIR}
|
||||||
cd ${BUILD_DIR}
|
cd ${BUILD_DIR}
|
||||||
|
|
||||||
cmake ../../src \
|
cmake -Wno-dev ../../src \
|
||||||
|
-DAMLNN_HOME=${AMLNN_HOME:-} \
|
||||||
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake \
|
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake \
|
||||||
-DANDROID_ABI=${TARGET_ABI} \
|
-DANDROID_ABI=${TARGET_ABI} \
|
||||||
-DANDROID_PLATFORM=android-24 \
|
-DANDROID_PLATFORM=android-24 \
|
||||||
|
|
|
||||||
|
|
@ -1,46 +1,35 @@
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.10...3.27)
|
||||||
project(retinaface_demo)
|
project(retinaface_demo)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
# Set NNSDK path
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../../../../cmake")
|
||||||
if(NOT DEFINED NNSDK_DIR)
|
find_package(AMLNN REQUIRED)
|
||||||
set(NNSDK_DIR "${CMAKE_SOURCE_DIR}/../../../../../amlnn-toolkit/nn_runtime/nnsdk")
|
include_directories(${AMLNN_INCLUDE_DIR})
|
||||||
endif()
|
link_directories(${AMLNN_LIBRARY_DIR})
|
||||||
set(NNSDK_ROOT "${NNSDK_DIR}")
|
|
||||||
message(STATUS "NNSDK_ROOT: ${NNSDK_ROOT}")
|
include_directories(${CMAKE_SOURCE_DIR}/../../../../common)
|
||||||
|
|
||||||
include_directories(${NNSDK_ROOT}/include)
|
# Set dependency path
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/../../../../common)
|
set(3RDPARTY_DIR "${CMAKE_SOURCE_DIR}/../../../../dependency")
|
||||||
|
|
||||||
# Set dependency path
|
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
||||||
set(3RDPARTY_DIR "${CMAKE_SOURCE_DIR}/../../../../dependency")
|
# Android needs log
|
||||||
|
link_libraries(log)
|
||||||
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
endif()
|
||||||
if (ANDROID_ABI STREQUAL "arm64-v8a")
|
|
||||||
link_directories(${NNSDK_ROOT}/android/arm64-v8a)
|
# Find OpenCV
|
||||||
else()
|
message(STATUS "OpenCV_DIR: ${OpenCV_DIR}")
|
||||||
link_directories(${NNSDK_ROOT}/android/armeabi-v7a)
|
find_package(OpenCV REQUIRED)
|
||||||
endif()
|
include_directories(${OpenCV_INCLUDE_DIRS})
|
||||||
# Android needs log
|
|
||||||
link_libraries(log)
|
add_executable(retinaface_demo
|
||||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
main.cpp
|
||||||
link_directories(${NNSDK_ROOT}/linux/yocto/aarch64-poky-linux)
|
postprocess.cpp
|
||||||
endif()
|
${CMAKE_SOURCE_DIR}/../../../../common/model_loader.cpp
|
||||||
|
)
|
||||||
# Find OpenCV
|
|
||||||
message(STATUS "OpenCV_DIR: ${OpenCV_DIR}")
|
target_link_libraries(retinaface_demo
|
||||||
find_package(OpenCV REQUIRED)
|
${OpenCV_LIBS}
|
||||||
include_directories(${OpenCV_INCLUDE_DIRS})
|
${AMLNN_LIBRARY}
|
||||||
|
|
||||||
|
|
||||||
add_executable(retinaface_demo
|
|
||||||
main.cpp
|
|
||||||
postprocess.cpp
|
|
||||||
${CMAKE_SOURCE_DIR}/../../../../common/model_loader.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(retinaface_demo
|
|
||||||
${OpenCV_LIBS}
|
|
||||||
nnsdk
|
|
||||||
)
|
)
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
# Whisper
|
||||||
|
|
||||||
|
## 4. Demo Run
|
||||||
|
|
||||||
|
### CPP
|
||||||
|
|
||||||
|
#### 1. Compile
|
||||||
|
|
||||||
|
#### AMLNN SDK Setup
|
||||||
|
|
||||||
|
Resolve the AMLNN nnsdk dependency using one of the following methods:
|
||||||
|
|
||||||
|
- **Priority 1 – Environment variable (recommended)**
|
||||||
|
```bash
|
||||||
|
export AMLNN_HOME=/path/to/amlnn-toolkit
|
||||||
|
```
|
||||||
|
- **Priority 3 – Sibling directory fallback** *(automatic)*
|
||||||
|
Place `amlnn-toolkit` as a sibling to `amlnn-model-playground`:
|
||||||
|
```bash
|
||||||
|
git clone git@github.com:Amlogic-NN/amlnn-toolkit.git ../amlnn-toolkit
|
||||||
|
```
|
||||||
|
|
||||||
|
**Prerequisites:**
|
||||||
|
- Android NDK r25c
|
||||||
|
- `ANDROID_NDK_PATH` environment variable set
|
||||||
|
|
||||||
|
**Build:**
|
||||||
|
```bash
|
||||||
|
# Build for arm64-v8a
|
||||||
|
cd examples/whisper/cpp
|
||||||
|
./build-android.sh -a arm64-v8a
|
||||||
|
```
|
||||||
|
|
||||||
|
The executable will be generated in `build/android/`.
|
||||||
|
|
@ -65,7 +65,8 @@ echo "BUILD_DIR: ${BUILD_DIR}"
|
||||||
mkdir -p ${BUILD_DIR}
|
mkdir -p ${BUILD_DIR}
|
||||||
cd ${BUILD_DIR}
|
cd ${BUILD_DIR}
|
||||||
|
|
||||||
cmake ../../src \
|
cmake -Wno-dev ../../src \
|
||||||
|
-DAMLNN_HOME=${AMLNN_HOME:-} \
|
||||||
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake \
|
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake \
|
||||||
-DANDROID_ABI=${TARGET_ABI} \
|
-DANDROID_ABI=${TARGET_ABI} \
|
||||||
-DANDROID_PLATFORM=android-24 \
|
-DANDROID_PLATFORM=android-24 \
|
||||||
|
|
|
||||||
|
|
@ -1,45 +1,35 @@
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.10...3.27)
|
||||||
project(whisper_demo)
|
project(whisper_demo)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
# Set NNSDK path
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../../../../cmake")
|
||||||
if(NOT DEFINED NNSDK_DIR)
|
find_package(AMLNN REQUIRED)
|
||||||
set(NNSDK_DIR "${CMAKE_SOURCE_DIR}/../../../../../amlnn-toolkit/nn_runtime/nnsdk")
|
include_directories(${AMLNN_INCLUDE_DIR})
|
||||||
endif()
|
link_directories(${AMLNN_LIBRARY_DIR})
|
||||||
set(NNSDK_ROOT "${NNSDK_DIR}")
|
|
||||||
message(STATUS "NNSDK_ROOT: ${NNSDK_ROOT}")
|
include_directories(${CMAKE_SOURCE_DIR}/../../../../common)
|
||||||
|
|
||||||
include_directories(${NNSDK_ROOT}/include)
|
# Set 3rdparty path
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/../../../../common)
|
set(3RDPARTY_DIR "${CMAKE_SOURCE_DIR}/../../../../dependency")
|
||||||
|
|
||||||
# Set 3rdparty path
|
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
||||||
set(3RDPARTY_DIR "${CMAKE_SOURCE_DIR}/../../../../dependency")
|
# Android needs log
|
||||||
|
link_libraries(log)
|
||||||
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
endif()
|
||||||
if (ANDROID_ABI STREQUAL "arm64-v8a")
|
|
||||||
link_directories(${NNSDK_ROOT}/android/arm64-v8a)
|
add_executable(${PROJECT_NAME}
|
||||||
else()
|
main.cpp
|
||||||
link_directories(${NNSDK_ROOT}/android/armeabi-v7a)
|
common.cpp
|
||||||
endif()
|
whisper.cpp
|
||||||
# Android needs log
|
whisper_invoke.cpp
|
||||||
link_libraries(log)
|
pre_process_whisper.cpp
|
||||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
post_process_whisper.cpp
|
||||||
link_directories(${NNSDK_ROOT}/linux/yocto/aarch64-poky-linux)
|
)
|
||||||
endif()
|
|
||||||
|
target_link_libraries(${PROJECT_NAME}
|
||||||
add_executable(${PROJECT_NAME}
|
${AMLNN_LIBRARY}
|
||||||
main.cpp
|
dl
|
||||||
common.cpp
|
m
|
||||||
whisper.cpp
|
)
|
||||||
whisper_invoke.cpp
|
|
||||||
pre_process_whisper.cpp
|
|
||||||
post_process_whisper.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME}
|
|
||||||
nnsdk
|
|
||||||
dl
|
|
||||||
m
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
# YOLOE
|
||||||
|
|
||||||
|
## 4. Demo Run
|
||||||
|
|
||||||
|
### CPP
|
||||||
|
|
||||||
|
#### 1. Compile
|
||||||
|
|
||||||
|
#### AMLNN SDK Setup
|
||||||
|
|
||||||
|
Resolve the AMLNN nnsdk dependency using one of the following methods:
|
||||||
|
|
||||||
|
- **Priority 1 – Environment variable (recommended)**
|
||||||
|
```bash
|
||||||
|
export AMLNN_HOME=/path/to/amlnn-toolkit
|
||||||
|
```
|
||||||
|
- **Priority 3 – Sibling directory fallback** *(automatic)*
|
||||||
|
Place `amlnn-toolkit` as a sibling to `amlnn-model-playground`:
|
||||||
|
```bash
|
||||||
|
git clone git@github.com:Amlogic-NN/amlnn-toolkit.git ../amlnn-toolkit
|
||||||
|
```
|
||||||
|
|
||||||
|
**Prerequisites:**
|
||||||
|
- Android NDK r25c
|
||||||
|
- `ANDROID_NDK_PATH` environment variable set
|
||||||
|
|
||||||
|
**Build:**
|
||||||
|
```bash
|
||||||
|
# Build for arm64-v8a
|
||||||
|
cd examples/yoloe/cpp
|
||||||
|
./build-android.sh -a arm64-v8a
|
||||||
|
```
|
||||||
|
|
||||||
|
The executable will be generated in `build/android/`.
|
||||||
|
|
@ -65,7 +65,8 @@ echo "BUILD_DIR: ${BUILD_DIR}"
|
||||||
mkdir -p ${BUILD_DIR}
|
mkdir -p ${BUILD_DIR}
|
||||||
cd ${BUILD_DIR}
|
cd ${BUILD_DIR}
|
||||||
|
|
||||||
cmake ../../src \
|
cmake -Wno-dev ../../src \
|
||||||
|
-DAMLNN_HOME=${AMLNN_HOME:-} \
|
||||||
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake \
|
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake \
|
||||||
-DANDROID_ABI=${TARGET_ABI} \
|
-DANDROID_ABI=${TARGET_ABI} \
|
||||||
-DANDROID_PLATFORM=android-24 \
|
-DANDROID_PLATFORM=android-24 \
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,21 @@
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.10...3.27)
|
||||||
project(yoloe_demo)
|
project(yoloe_demo)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
# Set NNSDK path
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../../../../cmake")
|
||||||
if(NOT DEFINED NNSDK_DIR)
|
find_package(AMLNN REQUIRED)
|
||||||
set(NNSDK_DIR "${CMAKE_SOURCE_DIR}/../../../../../amlnn-toolkit/nn_runtime/nnsdk")
|
include_directories(${AMLNN_INCLUDE_DIR})
|
||||||
endif()
|
link_directories(${AMLNN_LIBRARY_DIR})
|
||||||
set(NNSDK_ROOT "${NNSDK_DIR}")
|
|
||||||
message(STATUS "NNSDK_ROOT: ${NNSDK_ROOT}")
|
|
||||||
|
|
||||||
include_directories(${NNSDK_ROOT}/include)
|
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/../../../../common)
|
include_directories(${CMAKE_SOURCE_DIR}/../../../../common)
|
||||||
|
|
||||||
# Set dependency path
|
# Set dependency path
|
||||||
set(3RDPARTY_DIR "${CMAKE_SOURCE_DIR}/../../../../dependency")
|
set(3RDPARTY_DIR "${CMAKE_SOURCE_DIR}/../../../../dependency")
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
||||||
if (ANDROID_ABI STREQUAL "arm64-v8a")
|
|
||||||
link_directories(${NNSDK_ROOT}/android/arm64-v8a)
|
|
||||||
else()
|
|
||||||
link_directories(${NNSDK_ROOT}/android/armeabi-v7a)
|
|
||||||
endif()
|
|
||||||
# Android needs log
|
# Android needs log
|
||||||
link_libraries(log)
|
link_libraries(log)
|
||||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
||||||
link_directories(${NNSDK_ROOT}/linux/yocto/aarch64-poky-linux)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Find OpenCV
|
# Find OpenCV
|
||||||
|
|
@ -40,5 +30,5 @@ add_executable(yoloe_demo
|
||||||
|
|
||||||
target_link_libraries(yoloe_demo
|
target_link_libraries(yoloe_demo
|
||||||
${OpenCV_LIBS}
|
${OpenCV_LIBS}
|
||||||
nnsdk
|
${AMLNN_LIBRARY}
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,170 +1,184 @@
|
||||||
# yolov11
|
# yolov11
|
||||||
|
|
||||||
## 1.Overview
|
## 1.Overview
|
||||||
|
|
||||||
YOLOv11 was released by Ultralytics on October 2, 2024. It introduces significant architectural refinements and efficiency optimizations, delivering superior accuracy-speed trade-offs compared to previous generations. With enhanced feature extraction capabilities, YOLOv11 is designed for high-performance real-time applications—including object detection, instance segmentation, and pose estimation—to handle demanding tasks in a wide range of applications.
|
YOLOv11 was released by Ultralytics on October 2, 2024. It introduces significant architectural refinements and efficiency optimizations, delivering superior accuracy-speed trade-offs compared to previous generations. With enhanced feature extraction capabilities, YOLOv11 is designed for high-performance real-time applications—including object detection, instance segmentation, and pose estimation—to handle demanding tasks in a wide range of applications.
|
||||||
|
|
||||||
## 2.Model Download
|
## 2.Model Download
|
||||||
|
|
||||||
- **Open Source model**
|
- **Open Source model**
|
||||||
|
|
||||||
- **Open Source projects:** https://github.com/ultralytics/ultralytics/tree/v8.3.0
|
- **Open Source projects:** https://github.com/ultralytics/ultralytics/tree/v8.3.0
|
||||||
|
|
||||||
- **Export Model Step:**
|
- **Export Model Step:**
|
||||||
|
|
||||||
- **Install ultralytics**
|
- **Install ultralytics**
|
||||||
|
|
||||||
pip install torch==2.4.1
|
pip install torch==2.4.1
|
||||||
|
|
||||||
pip install torchvision==0.19.1
|
pip install torchvision==0.19.1
|
||||||
|
|
||||||
pip install ultralytics==8.3.0
|
pip install ultralytics==8.3.0
|
||||||
|
|
||||||
- **Download weights**
|
- **Download weights**
|
||||||
|
|
||||||
wget https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11m.pt
|
wget https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11m.pt
|
||||||
|
|
||||||
wget https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11s.pt
|
wget https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11s.pt
|
||||||
|
|
||||||
wget https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11n.pt
|
wget https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11n.pt
|
||||||
|
|
||||||
- **Export Model**
|
- **Export Model**
|
||||||
|
|
||||||
```
|
```
|
||||||
from ultralytics import YOLO
|
from ultralytics import YOLO
|
||||||
|
|
||||||
model = YOLO("yolo11n.pt")
|
model = YOLO("yolo11n.pt")
|
||||||
model.export(format="onnx", opset=12, simplify=True, dynamic=False, imgsz=640)
|
model.export(format="onnx", opset=12, simplify=True, dynamic=False, imgsz=640)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
- **Exported Model**
|
- **Exported Model**
|
||||||
|
|
||||||
link to amlogic server( **onnx model or quantized tflite**)
|
link to amlogic server( **onnx model or quantized tflite**)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 3. Model Conversion
|
## 3. Model Conversion
|
||||||
|
|
||||||
```
|
```
|
||||||
cd model
|
cd model
|
||||||
Usage: ./adla_covnert.sh model_path adla_tookkit_path target_platform
|
Usage: ./adla_covnert.sh model_path adla_tookkit_path target_platform
|
||||||
|
|
||||||
example
|
example
|
||||||
./adla_covnert.sh yolov11m.onnx /xxxx/adla-toolkit-binary-3.2.9.3 PRODUCT_PID0XA005
|
./adla_covnert.sh yolov11m.onnx /xxxx/adla-toolkit-binary-3.2.9.3 PRODUCT_PID0XA005
|
||||||
./adla_covnert.sh yolov11s.onnx /xxxx/adla-toolkit-binary-3.2.9.3 PRODUCT_PID0XA005
|
./adla_covnert.sh yolov11s.onnx /xxxx/adla-toolkit-binary-3.2.9.3 PRODUCT_PID0XA005
|
||||||
./adla_covnert.sh yolov11n.onnx /xxxx/adla-toolkit-binary-3.2.9.3 PRODUCT_PID0XA005
|
./adla_covnert.sh yolov11n.onnx /xxxx/adla-toolkit-binary-3.2.9.3 PRODUCT_PID0XA005
|
||||||
```
|
```
|
||||||
|
|
||||||
| Parameter | Discription |
|
| Parameter | Discription |
|
||||||
| ----------------- | ------------------------------------------------------------ |
|
| ----------------- | ------------------------------------------------------------ |
|
||||||
| model_path | onnx model path |
|
| model_path | onnx model path |
|
||||||
| adla_tookkit_path | path to adla_toolkit |
|
| adla_tookkit_path | path to adla_toolkit |
|
||||||
| target_platform | Specify target platform. for A311D2 : PRODUCT_PID0XA003. for S905X5: PRODUCT_PID0XA005 |
|
| target_platform | Specify target platform. for A311D2 : PRODUCT_PID0XA003. for S905X5: PRODUCT_PID0XA005 |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 4. Demo Run
|
## 4. Demo Run
|
||||||
|
|
||||||
### CPP
|
### CPP
|
||||||
|
|
||||||
#### 1. Compile
|
#### 1. Compile
|
||||||
|
|
||||||
**Prerequisites:**
|
#### AMLNN SDK Setup
|
||||||
- Android NDK (r25e recommended)
|
|
||||||
- `ANDROID_NDK_PATH` environment variable set
|
Resolve the AMLNN nnsdk dependency using one of the following methods:
|
||||||
|
|
||||||
**Build:**
|
- **Priority 1 – Environment variable (recommended)**
|
||||||
```bash
|
```bash
|
||||||
# Build for arm64-v8a
|
export AMLNN_HOME=/path/to/amlnn-toolkit
|
||||||
cd examples/yolov11/cpp
|
```
|
||||||
./build-android.sh -a arm64-v8a
|
- **Priority 3 – Sibling directory fallback** *(automatic)*
|
||||||
```
|
Place `amlnn-toolkit` as a sibling to `amlnn-model-playground`:
|
||||||
|
```bash
|
||||||
The executable will be generated at `build/android/yolo11_demo` (Note: executable name may vary, verify in build folder).
|
git clone git@github.com:Amlogic-NN/amlnn-toolkit.git ../amlnn-toolkit
|
||||||
|
```
|
||||||
#### 2. Run
|
|
||||||
|
**Prerequisites:**
|
||||||
```bash
|
- Android NDK (r25e recommended)
|
||||||
# Push executable to device
|
- `ANDROID_NDK_PATH` environment variable set
|
||||||
adb push build/android/yolo11_demo /data/local/tmp/
|
|
||||||
adb push model/yolov11n_int8_A311D2.adla /data/local/tmp/
|
**Build:**
|
||||||
adb push imgs /data/local/tmp/
|
```bash
|
||||||
|
# Build for arm64-v8a
|
||||||
# Run on device
|
cd examples/yolov11/cpp
|
||||||
adb shell
|
./build-android.sh -a arm64-v8a
|
||||||
cd /data/local/tmp
|
```
|
||||||
chmod +x yolo11_demo
|
|
||||||
export LD_LIBRARY_PATH=/vendor/lib64 or (/vendor/lib)
|
The executable will be generated at `build/android/yolo11_demo` (Note: executable name may vary, verify in build folder).
|
||||||
|
|
||||||
# Usage: ./yolo11_demo <model_path> <image_dir>
|
#### 2. Run
|
||||||
./yolo11_demo yolov11n_int8_A311D2.adla ./imgs
|
|
||||||
```
|
```bash
|
||||||
|
# Push executable to device
|
||||||
**Note:** Replace `yolov11n_int8_A311D2.adla` with your actual model file path.
|
adb push build/android/yolo11_demo /data/local/tmp/
|
||||||
|
adb push model/yolov11n_int8_A311D2.adla /data/local/tmp/
|
||||||
### Python
|
adb push imgs /data/local/tmp/
|
||||||
|
|
||||||
**Prerequisites:**
|
# Run on device
|
||||||
- Python 3.10
|
adb shell
|
||||||
- Required packages: `numpy`, `opencv-python`, `amlnnlite`
|
cd /data/local/tmp
|
||||||
|
chmod +x yolo11_demo
|
||||||
**Install dependencies:**
|
export LD_LIBRARY_PATH=/vendor/lib64 or (/vendor/lib)
|
||||||
```bash
|
|
||||||
pip install numpy opencv-python amlnnlite-1.0.0-cp310-cp310-linux_aarch64.whl
|
# Usage: ./yolo11_demo <model_path> <image_dir>
|
||||||
```
|
./yolo11_demo yolov11n_int8_A311D2.adla ./imgs
|
||||||
|
```
|
||||||
**Run on device:**
|
|
||||||
```bash
|
**Note:** Replace `yolov11n_int8_A311D2.adla` with your actual model file path.
|
||||||
python yolov11.py \
|
|
||||||
--model-path ./yolov11n_int8_A311D2.adla \
|
### Python
|
||||||
--image-dir ./imgs \
|
|
||||||
--run-cycles 1 \
|
**Prerequisites:**
|
||||||
--loglevel INFO
|
- Python 3.10
|
||||||
```
|
- Required packages: `numpy`, `opencv-python`, `amlnnlite`
|
||||||
|
|
||||||
Argument Descriptions:
|
**Install dependencies:**
|
||||||
| Argument | Description |
|
```bash
|
||||||
| ----------------- | ------------------------------------------------------------ |
|
pip install numpy opencv-python amlnnlite-1.0.0-cp310-cp310-linux_aarch64.whl
|
||||||
| --board-work-path | Work path on board, default is /data/local/tmp |
|
```
|
||||||
| --model-path | path to .adla model |
|
|
||||||
| --image-dir | Directory containing test images |
|
**Run on device:**
|
||||||
| --run-cycles | Number of inference cycles, default is 1 |
|
```bash
|
||||||
| --loglevel | Logging level: DEBUG / INFO / WARNING / ERROR, default is WARNING |
|
python yolov11.py \
|
||||||
|
--model-path ./yolov11n_int8_A311D2.adla \
|
||||||
The script will automatically process all image files (`.jpg`, `.jpeg`, `.png`, `.bmp`) in the current directory and save results to a `{model_name}_result` folder.
|
--image-dir ./imgs \
|
||||||
|
--run-cycles 1 \
|
||||||
## 5.Results
|
--loglevel INFO
|
||||||
|
```
|
||||||
**Performance Feedback**
|
|
||||||
|
Argument Descriptions:
|
||||||
By setting the loglevel to INFO, the program provides real-time performance metrics upon completion. The console log will display essential hardware and execution details, including:
|
| Argument | Description |
|
||||||
- Hardware Information: System and ADLA library versions.
|
| ----------------- | ------------------------------------------------------------ |
|
||||||
- Model Overview: Basic input/output configurations.
|
| --board-work-path | Work path on board, default is /data/local/tmp |
|
||||||
- NPU Metrics: Total inference time (latency) and total DRAM bandwidth consumption.
|
| --model-path | path to .adla model |
|
||||||
|
| --image-dir | Directory containing test images |
|
||||||
**Detection Output**
|
| --run-cycles | Number of inference cycles, default is 1 |
|
||||||
|
| --loglevel | Logging level: DEBUG / INFO / WARNING / ERROR, default is WARNING |
|
||||||
The program will print the detection count. The result image with bounding boxes will be saved to the specified output path (`{model_name}_result`).
|
|
||||||
|
The script will automatically process all image files (`.jpg`, `.jpeg`, `.png`, `.bmp`) in the current directory and save results to a `{model_name}_result` folder.
|
||||||
You can pull the result folder back to view it:
|
|
||||||
```bash
|
## 5.Results
|
||||||
adb pull /data/local/tmp/yolov11n_int8_A311D2_result
|
|
||||||
```
|
**Performance Feedback**
|
||||||

|
|
||||||
|
By setting the loglevel to INFO, the program provides real-time performance metrics upon completion. The console log will display essential hardware and execution details, including:
|
||||||
**Profiling Visualization**
|
- Hardware Information: System and ADLA library versions.
|
||||||
|
- Model Overview: Basic input/output configurations.
|
||||||
After a successful run of the Python demo, a folder named after the model (e.g., `{model_name}`) will be generated in the script directory. This folder contains 5 HTML files that provide a visual and detailed breakdown of per-layer performance:
|
- NPU Metrics: Total inference time (latency) and total DRAM bandwidth consumption.
|
||||||
- `hard_op_chart.html` & `soft_op_chart.html`: Hardware/Software op execution details.
|
|
||||||
- `dram_rd_chart.html` & `dram_wr_chart.html`: Bandwidth read/write distribution.
|
**Detection Output**
|
||||||
- `pie_charts_distribution.html`: Overall resource allocation.
|
|
||||||
|
The program will print the detection count. The result image with bounding boxes will be saved to the specified output path (`{model_name}_result`).
|
||||||
You can pull the result folder back to view it:
|
|
||||||
```bash
|
You can pull the result folder back to view it:
|
||||||
adb pull /data/local/tmp/yolov11n_int8_A311D2
|
```bash
|
||||||
```
|
adb pull /data/local/tmp/yolov11n_int8_A311D2_result
|
||||||
|
```
|
||||||
Taking hard_op_chart.html as an example (shown below), each layer's ADLA operator name includes parentheses containing the index of the corresponding quantized .tflite layer(s); by default, these indices are suppressed, and operators are labeled generically as "hardware" or "software" without numerical suffixes.
|

|
||||||
|
|
||||||
|
**Profiling Visualization**
|
||||||
|
|
||||||
|
After a successful run of the Python demo, a folder named after the model (e.g., `{model_name}`) will be generated in the script directory. This folder contains 5 HTML files that provide a visual and detailed breakdown of per-layer performance:
|
||||||
|
- `hard_op_chart.html` & `soft_op_chart.html`: Hardware/Software op execution details.
|
||||||
|
- `dram_rd_chart.html` & `dram_wr_chart.html`: Bandwidth read/write distribution.
|
||||||
|
- `pie_charts_distribution.html`: Overall resource allocation.
|
||||||
|
|
||||||
|
You can pull the result folder back to view it:
|
||||||
|
```bash
|
||||||
|
adb pull /data/local/tmp/yolov11n_int8_A311D2
|
||||||
|
```
|
||||||
|
|
||||||
|
Taking hard_op_chart.html as an example (shown below), each layer's ADLA operator name includes parentheses containing the index of the corresponding quantized .tflite layer(s); by default, these indices are suppressed, and operators are labeled generically as "hardware" or "software" without numerical suffixes.
|
||||||
|
|
||||||

|

|
||||||
|
|
@ -65,7 +65,8 @@ echo "BUILD_DIR: ${BUILD_DIR}"
|
||||||
mkdir -p ${BUILD_DIR}
|
mkdir -p ${BUILD_DIR}
|
||||||
cd ${BUILD_DIR}
|
cd ${BUILD_DIR}
|
||||||
|
|
||||||
cmake ../../src \
|
cmake -Wno-dev ../../src \
|
||||||
|
-DAMLNN_HOME=${AMLNN_HOME:-} \
|
||||||
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake \
|
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake \
|
||||||
-DANDROID_ABI=${TARGET_ABI} \
|
-DANDROID_ABI=${TARGET_ABI} \
|
||||||
-DANDROID_PLATFORM=android-24 \
|
-DANDROID_PLATFORM=android-24 \
|
||||||
|
|
|
||||||
|
|
@ -1,46 +1,35 @@
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.10...3.27)
|
||||||
project(yolo11_demo)
|
project(yolo11_demo)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
# Set NNSDK path
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../../../../cmake")
|
||||||
if(NOT DEFINED NNSDK_DIR)
|
find_package(AMLNN REQUIRED)
|
||||||
set(NNSDK_DIR "${CMAKE_SOURCE_DIR}/../../../../../amlnn-toolkit/nn_runtime/nnsdk")
|
include_directories(${AMLNN_INCLUDE_DIR})
|
||||||
endif()
|
link_directories(${AMLNN_LIBRARY_DIR})
|
||||||
set(NNSDK_ROOT "${NNSDK_DIR}")
|
|
||||||
message(STATUS "NNSDK_ROOT: ${NNSDK_ROOT}")
|
include_directories(${CMAKE_SOURCE_DIR}/../../../../common)
|
||||||
|
|
||||||
include_directories(${NNSDK_ROOT}/include)
|
# Set dependency path
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/../../../../common)
|
set(3RDPARTY_DIR "${CMAKE_SOURCE_DIR}/../../../../dependency")
|
||||||
|
|
||||||
# Set dependency path
|
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
||||||
set(3RDPARTY_DIR "${CMAKE_SOURCE_DIR}/../../../../dependency")
|
# Android needs log
|
||||||
|
link_libraries(log)
|
||||||
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
endif()
|
||||||
if (ANDROID_ABI STREQUAL "arm64-v8a")
|
|
||||||
link_directories(${NNSDK_ROOT}/android/arm64-v8a)
|
# Find OpenCV
|
||||||
else()
|
message(STATUS "OpenCV_DIR: ${OpenCV_DIR}")
|
||||||
link_directories(${NNSDK_ROOT}/android/armeabi-v7a)
|
find_package(OpenCV REQUIRED)
|
||||||
endif()
|
include_directories(${OpenCV_INCLUDE_DIRS})
|
||||||
# Android needs log
|
|
||||||
link_libraries(log)
|
add_executable(yolo11_demo
|
||||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
main.cpp
|
||||||
link_directories(${NNSDK_ROOT}/linux/yocto/aarch64-poky-linux)
|
postprocess.cpp
|
||||||
endif()
|
${CMAKE_SOURCE_DIR}/../../../../common/model_loader.cpp
|
||||||
|
)
|
||||||
# Find OpenCV
|
|
||||||
message(STATUS "OpenCV_DIR: ${OpenCV_DIR}")
|
target_link_libraries(yolo11_demo
|
||||||
find_package(OpenCV REQUIRED)
|
${OpenCV_LIBS}
|
||||||
include_directories(${OpenCV_INCLUDE_DIRS})
|
${AMLNN_LIBRARY}
|
||||||
|
|
||||||
|
|
||||||
add_executable(yolo11_demo
|
|
||||||
main.cpp
|
|
||||||
postprocess.cpp
|
|
||||||
${CMAKE_SOURCE_DIR}/../../../../common/model_loader.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(yolo11_demo
|
|
||||||
${OpenCV_LIBS}
|
|
||||||
nnsdk
|
|
||||||
)
|
)
|
||||||
|
|
@ -1,133 +1,147 @@
|
||||||
# yolov8
|
# yolov8
|
||||||
|
|
||||||
## 1.Overview
|
## 1.Overview
|
||||||
|
|
||||||
YOLOv8 was released by Ultralytics on January 10, 2023, offering cutting-edge performance in terms of accuracy and speed. Building upon the advancements of previous YOLO versions, YOLOv8 introduced new features and optimizations that make it an ideal choice for various [object detection](https://www.ultralytics.com/blog/a-guide-to-deep-dive-into-object-detection-in-2025) tasks in a wide range of applications.
|
YOLOv8 was released by Ultralytics on January 10, 2023, offering cutting-edge performance in terms of accuracy and speed. Building upon the advancements of previous YOLO versions, YOLOv8 introduced new features and optimizations that make it an ideal choice for various [object detection](https://www.ultralytics.com/blog/a-guide-to-deep-dive-into-object-detection-in-2025) tasks in a wide range of applications.
|
||||||
|
|
||||||
## 2.Model Download
|
## 2.Model Download
|
||||||
|
|
||||||
- **Open Source model**
|
- **Open Source model**
|
||||||
|
|
||||||
- **Open Source projects:** https://github.com/ultralytics/ultralytics/tree/v8.2.0
|
- **Open Source projects:** https://github.com/ultralytics/ultralytics/tree/v8.2.0
|
||||||
|
|
||||||
- **Export Model Step:**
|
- **Export Model Step:**
|
||||||
|
|
||||||
- **Install ultralytics**
|
- **Install ultralytics**
|
||||||
|
|
||||||
pip install torch==2.4.1
|
pip install torch==2.4.1
|
||||||
|
|
||||||
pip install torchvision==0.19.1
|
pip install torchvision==0.19.1
|
||||||
|
|
||||||
pip install ultralytics==8.2.0
|
pip install ultralytics==8.2.0
|
||||||
|
|
||||||
- **Download weights**
|
- **Download weights**
|
||||||
|
|
||||||
wget https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8m.pt
|
wget https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8m.pt
|
||||||
|
|
||||||
wget https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8s.pt
|
wget https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8s.pt
|
||||||
|
|
||||||
wget https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n.pt
|
wget https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n.pt
|
||||||
|
|
||||||
- **Export Model**
|
- **Export Model**
|
||||||
|
|
||||||
```
|
```
|
||||||
from ultralytics import YOLO
|
from ultralytics import YOLO
|
||||||
|
|
||||||
model = YOLO("yolov8m.pt")
|
model = YOLO("yolov8m.pt")
|
||||||
model.export(format="onnx", opset=12, simplify=True, dynamic=False, imgsz=640)
|
model.export(format="onnx", opset=12, simplify=True, dynamic=False, imgsz=640)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
- **Exported Model**
|
- **Exported Model**
|
||||||
|
|
||||||
link to amlogic server( **onnx model or quantized tflite**)
|
link to amlogic server( **onnx model or quantized tflite**)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 3. Model Conversion
|
## 3. Model Conversion
|
||||||
|
|
||||||
```
|
```
|
||||||
cd model
|
cd model
|
||||||
Usage: ./adla_covnert.sh model_path adla_tookkit_path target_platform
|
Usage: ./adla_covnert.sh model_path adla_tookkit_path target_platform
|
||||||
|
|
||||||
example
|
example
|
||||||
./adla_covnert.sh yolov8m.onnx /xxxx/adla-toolkit-binary-3.2.9.3 PRODUCT_PID0XA005
|
./adla_covnert.sh yolov8m.onnx /xxxx/adla-toolkit-binary-3.2.9.3 PRODUCT_PID0XA005
|
||||||
./adla_covnert.sh yolov8s.onnx /xxxx/adla-toolkit-binary-3.2.9.3 PRODUCT_PID0XA005
|
./adla_covnert.sh yolov8s.onnx /xxxx/adla-toolkit-binary-3.2.9.3 PRODUCT_PID0XA005
|
||||||
./adla_covnert.sh yolov8n.onnx /xxxx/adla-toolkit-binary-3.2.9.3 PRODUCT_PID0XA005
|
./adla_covnert.sh yolov8n.onnx /xxxx/adla-toolkit-binary-3.2.9.3 PRODUCT_PID0XA005
|
||||||
```
|
```
|
||||||
|
|
||||||
| Parameter | Discription |
|
| Parameter | Discription |
|
||||||
| ----------------- | ------------------------------------------------------------ |
|
| ----------------- | ------------------------------------------------------------ |
|
||||||
| model_path | onnx model path |
|
| model_path | onnx model path |
|
||||||
| adla_tookkit_path | path to adla_toolkit |
|
| adla_tookkit_path | path to adla_toolkit |
|
||||||
| target_platform | Specify target platform. for A311D2 : PRODUCT_PID0XA003。for S905X5: PRODUCT_PID0XA005 |
|
| target_platform | Specify target platform. for A311D2 : PRODUCT_PID0XA003。for S905X5: PRODUCT_PID0XA005 |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 4. Demo Run
|
## 4. Demo Run
|
||||||
|
|
||||||
### CPP
|
### CPP
|
||||||
|
|
||||||
#### 1. Compile
|
#### 1. Compile
|
||||||
|
|
||||||
**Prerequisites:**
|
#### AMLNN SDK Setup
|
||||||
- Android NDK (r25e recommended)
|
|
||||||
- `ANDROID_NDK_PATH` environment variable set
|
Resolve the AMLNN nnsdk dependency using one of the following methods:
|
||||||
|
|
||||||
**Build:**
|
- **Priority 1 – Environment variable (recommended)**
|
||||||
```bash
|
```bash
|
||||||
# Build for arm64-v8a
|
export AMLNN_HOME=/path/to/amlnn-toolkit
|
||||||
cd examples/yolov8/cpp
|
```
|
||||||
./build-android.sh -a arm64-v8a
|
- **Priority 3 – Sibling directory fallback** *(automatic)*
|
||||||
```
|
Place `amlnn-toolkit` as a sibling to `amlnn-model-playground`:
|
||||||
|
```bash
|
||||||
The executable will be generated at `build/android/yolov8_demo` (Note: executable name may vary, verify in build folder).
|
git clone git@github.com:Amlogic-NN/amlnn-toolkit.git ../amlnn-toolkit
|
||||||
|
```
|
||||||
#### 2. Run
|
|
||||||
|
**Prerequisites:**
|
||||||
```bash
|
- Android NDK (r25e recommended)
|
||||||
# Push executable to device
|
- `ANDROID_NDK_PATH` environment variable set
|
||||||
adb push build/android/yolov8_demo /data/local/tmp/
|
|
||||||
adb push model/yolov8s_int8_A311D2.adla /data/local/tmp/
|
**Build:**
|
||||||
adb push test_image.jpg /data/local/tmp/
|
```bash
|
||||||
|
# Build for arm64-v8a
|
||||||
# Run on device
|
cd examples/yolov8/cpp
|
||||||
adb shell
|
./build-android.sh -a arm64-v8a
|
||||||
cd /data/local/tmp
|
```
|
||||||
chmod +x yolov8_demo
|
|
||||||
export LD_LIBRARY_PATH=/vendor/lib64 or (/vendor/lib)
|
The executable will be generated at `build/android/yolov8_demo` (Note: executable name may vary, verify in build folder).
|
||||||
|
|
||||||
# Usage: ./yolo_world_demo <model_path> <image_path>
|
#### 2. Run
|
||||||
./yolov8_demo yolov8s_int8_A311D2.adla test_image.jpg"
|
|
||||||
```
|
```bash
|
||||||
|
# Push executable to device
|
||||||
**Note:** Replace `yolov8s_int8_A311D2.adla` with your actual model file path.
|
adb push build/android/yolov8_demo /data/local/tmp/
|
||||||
|
adb push model/yolov8s_int8_A311D2.adla /data/local/tmp/
|
||||||
### Python
|
adb push test_image.jpg /data/local/tmp/
|
||||||
|
|
||||||
**Prerequisites:**
|
# Run on device
|
||||||
- Python 3.10
|
adb shell
|
||||||
- Required packages: `numpy`, `opencv-python`, `amlnnlite`
|
cd /data/local/tmp
|
||||||
|
chmod +x yolov8_demo
|
||||||
**Install dependencies:**
|
export LD_LIBRARY_PATH=/vendor/lib64 or (/vendor/lib)
|
||||||
```bash
|
|
||||||
pip install numpy opencv-python amlnnlite-1.0.0-cp310-cp310-linux_aarch64.whl
|
# Usage: ./yolo_world_demo <model_path> <image_path>
|
||||||
```
|
./yolov8_demo yolov8s_int8_A311D2.adla test_image.jpg"
|
||||||
|
```
|
||||||
**Run on device:**
|
|
||||||
```bash
|
**Note:** Replace `yolov8s_int8_A311D2.adla` with your actual model file path.
|
||||||
python yolov8.py --model-path ./yolov8s_int8_A311D2.adla
|
|
||||||
```
|
### Python
|
||||||
|
|
||||||
The script will automatically process all image files (`.jpg`, `.jpeg`, `.png`, `.bmp`) in the current directory and save results to a `{model_name}_result` folder.
|
**Prerequisites:**
|
||||||
|
- Python 3.10
|
||||||
## 5.Results
|
- Required packages: `numpy`, `opencv-python`, `amlnnlite`
|
||||||
The program will print the detection count and inference time. The result image with bounding boxes will be saved to the specified output path (`result.jpg` by default).
|
|
||||||
|
**Install dependencies:**
|
||||||
|
```bash
|
||||||
You can pull the result image back to view it:
|
pip install numpy opencv-python amlnnlite-1.0.0-cp310-cp310-linux_aarch64.whl
|
||||||
```bash
|
```
|
||||||
adb pull result.jpg.
|
|
||||||
```
|
**Run on device:**
|
||||||

|
```bash
|
||||||
|
python yolov8.py --model-path ./yolov8s_int8_A311D2.adla
|
||||||
|
```
|
||||||
|
|
||||||
|
The script will automatically process all image files (`.jpg`, `.jpeg`, `.png`, `.bmp`) in the current directory and save results to a `{model_name}_result` folder.
|
||||||
|
|
||||||
|
## 5.Results
|
||||||
|
The program will print the detection count and inference time. The result image with bounding boxes will be saved to the specified output path (`result.jpg` by default).
|
||||||
|
|
||||||
|
|
||||||
|
You can pull the result image back to view it:
|
||||||
|
```bash
|
||||||
|
adb pull result.jpg.
|
||||||
|
```
|
||||||
|

|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,13 +65,13 @@ echo "BUILD_DIR: ${BUILD_DIR}"
|
||||||
mkdir -p ${BUILD_DIR}
|
mkdir -p ${BUILD_DIR}
|
||||||
cd ${BUILD_DIR}
|
cd ${BUILD_DIR}
|
||||||
|
|
||||||
cmake ../../src \
|
cmake -Wno-dev ../../src \
|
||||||
|
-DAMLNN_HOME=${AMLNN_HOME:-} \
|
||||||
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake \
|
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake \
|
||||||
-DANDROID_ABI=${TARGET_ABI} \
|
-DANDROID_ABI=${TARGET_ABI} \
|
||||||
-DANDROID_PLATFORM=android-24 \
|
-DANDROID_PLATFORM=android-24 \
|
||||||
-DCMAKE_BUILD_TYPE=Release \
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
-DOpenCV_DIR=${ROOT_PWD}/../../../dependency/opencv/opencv-android-sdk-build/sdk/native/jni/abi-${TARGET_ABI} \
|
-DOpenCV_DIR=${ROOT_PWD}/../../../dependency/opencv/opencv-android-sdk-build/sdk/native/jni/abi-${TARGET_ABI} \
|
||||||
-DNNSDK_DIR=${ROOT_PWD}/../../../../amlnn-toolkit/nn_runtime/nnsdk
|
|
||||||
|
|
||||||
make -j4
|
make -j4
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,46 +1,36 @@
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.10...3.27)
|
||||||
project(yolo_world_demo)
|
project(yolo_world_demo)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
# Set NNSDK path
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../../../../cmake")
|
||||||
if(NOT DEFINED NNSDK_DIR)
|
find_package(AMLNN REQUIRED)
|
||||||
set(NNSDK_DIR "${CMAKE_SOURCE_DIR}/../../../../../amlnn-toolkit/nn_runtime/nnsdk")
|
include_directories(${AMLNN_INCLUDE_DIR})
|
||||||
endif()
|
link_directories(${AMLNN_LIBRARY_DIR})
|
||||||
set(NNSDK_ROOT "${NNSDK_DIR}")
|
|
||||||
message(STATUS "NNSDK_ROOT: ${NNSDK_ROOT}")
|
include_directories(${CMAKE_SOURCE_DIR}/../../../../common)
|
||||||
|
|
||||||
include_directories(${NNSDK_ROOT}/include)
|
# Set 3rdparty path
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/../../../../common)
|
set(3RDPARTY_DIR "${CMAKE_SOURCE_DIR}/../../../../dependency")
|
||||||
|
|
||||||
# Set 3rdparty path
|
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
||||||
set(3RDPARTY_DIR "${CMAKE_SOURCE_DIR}/../../../../dependency")
|
# Android needs log
|
||||||
|
link_libraries(log)
|
||||||
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
endif()
|
||||||
if (ANDROID_ABI STREQUAL "arm64-v8a")
|
|
||||||
link_directories(${NNSDK_ROOT}/android/arm64-v8a)
|
# Find OpenCV
|
||||||
else()
|
message(STATUS "OpenCV_DIR: ${OpenCV_DIR}")
|
||||||
link_directories(${NNSDK_ROOT}/android/armeabi-v7a)
|
find_package(OpenCV REQUIRED)
|
||||||
endif()
|
include_directories(${OpenCV_INCLUDE_DIRS})
|
||||||
# Android needs log
|
|
||||||
link_libraries(log)
|
add_executable(yolov8_demo
|
||||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
main.cpp
|
||||||
link_directories(${NNSDK_ROOT}/linux/yocto/aarch64-poky-linux)
|
postprocess.cpp
|
||||||
endif()
|
postprocess.h
|
||||||
|
${CMAKE_SOURCE_DIR}/../../../../common/model_loader.cpp
|
||||||
# Find OpenCV
|
)
|
||||||
message(STATUS "OpenCV_DIR: ${OpenCV_DIR}")
|
|
||||||
find_package(OpenCV REQUIRED)
|
target_link_libraries(yolov8_demo
|
||||||
include_directories(${OpenCV_INCLUDE_DIRS})
|
${OpenCV_LIBS}
|
||||||
|
${AMLNN_LIBRARY}
|
||||||
add_executable(yolov8_demo
|
)
|
||||||
main.cpp
|
|
||||||
postprocess.cpp
|
|
||||||
postprocess.h
|
|
||||||
${CMAKE_SOURCE_DIR}/../../../../common/model_loader.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(yolov8_demo
|
|
||||||
${OpenCV_LIBS}
|
|
||||||
nnsdk
|
|
||||||
)
|
|
||||||
|
|
|
||||||
|
|
@ -1,72 +1,86 @@
|
||||||
## Demo Run
|
## Demo Run
|
||||||
|
|
||||||
### CPP
|
### CPP
|
||||||
|
|
||||||
#### 1. Compile
|
#### 1. Compile
|
||||||
|
|
||||||
**Prerequisites:**
|
#### AMLNN SDK Setup
|
||||||
- Android NDK (r25e recommended)
|
|
||||||
- `ANDROID_NDK_PATH` environment variable set
|
Resolve the AMLNN nnsdk dependency using one of the following methods:
|
||||||
|
|
||||||
**Build:**
|
- **Priority 1 – Environment variable (recommended)**
|
||||||
```bash
|
```bash
|
||||||
# Build for arm64-v8a
|
export AMLNN_HOME=/path/to/amlnn-toolkit
|
||||||
cd examples/yoloworld/cpp
|
```
|
||||||
./build-android.sh -a arm64-v8a
|
- **Priority 3 – Sibling directory fallback** *(automatic)*
|
||||||
```
|
Place `amlnn-toolkit` as a sibling to `amlnn-model-playground`:
|
||||||
|
```bash
|
||||||
The executable will be generated at `build/android/yolo_world_demo` (Note: executable name may vary, verify in build folder).
|
git clone git@github.com:Amlogic-NN/amlnn-toolkit.git ../amlnn-toolkit
|
||||||
|
```
|
||||||
#### 2. Run
|
|
||||||
|
**Prerequisites:**
|
||||||
```bash
|
- Android NDK (r25e recommended)
|
||||||
# Push executable to device
|
- `ANDROID_NDK_PATH` environment variable set
|
||||||
adb push build/android/yolo_world_demo /data/local/tmp/
|
|
||||||
adb push model/yoloworld_int8_A311D2.adla /data/local/tmp/
|
**Build:**
|
||||||
adb push test_image.jpg /data/local/tmp/
|
```bash
|
||||||
|
# Build for arm64-v8a
|
||||||
# Run on device
|
cd examples/yoloworld/cpp
|
||||||
adb shell
|
./build-android.sh -a arm64-v8a
|
||||||
cd /data/local/tmp
|
```
|
||||||
chmod +x yolo_world_demo
|
|
||||||
export LD_LIBRARY_PATH=/vendor/lib64 or (/vendor/lib)
|
The executable will be generated at `build/android/yolo_world_demo` (Note: executable name may vary, verify in build folder).
|
||||||
|
|
||||||
# Usage: ./yolo_world_demo <model_path> <image_path>
|
#### 2. Run
|
||||||
./yolo_world_demo yoloworld_int8_A311D2.adla test_image.jpg
|
|
||||||
```
|
```bash
|
||||||
|
# Push executable to device
|
||||||
**Note:** Replace `yoloworld_int8_A311D2.adla` with your actual model file path.
|
adb push build/android/yolo_world_demo /data/local/tmp/
|
||||||
|
adb push model/yoloworld_int8_A311D2.adla /data/local/tmp/
|
||||||
### Python
|
adb push test_image.jpg /data/local/tmp/
|
||||||
|
|
||||||
**Prerequisites:**
|
# Run on device
|
||||||
- Python 3.10
|
adb shell
|
||||||
- Required packages: `numpy`, `opencv-python`, `amlnnlite`
|
cd /data/local/tmp
|
||||||
|
chmod +x yolo_world_demo
|
||||||
**Install dependencies:**
|
export LD_LIBRARY_PATH=/vendor/lib64 or (/vendor/lib)
|
||||||
```bash
|
|
||||||
pip install numpy opencv-python amlnnlite-1.0.0-cp310-cp310-linux_aarch64.whl
|
# Usage: ./yolo_world_demo <model_path> <image_path>
|
||||||
```
|
./yolo_world_demo yoloworld_int8_A311D2.adla test_image.jpg
|
||||||
|
```
|
||||||
**Run on device:**
|
|
||||||
```bash
|
**Note:** Replace `yoloworld_int8_A311D2.adla` with your actual model file path.
|
||||||
# Basic usage (process current directory)
|
|
||||||
python yoloworld.py --model-path ./yoloworld_int8_A311D2.adla
|
### Python
|
||||||
|
|
||||||
# Specify image directory
|
**Prerequisites:**
|
||||||
python yoloworld.py --model-path ./yoloworld_int8_A311D2.adla --image-dir ./
|
- Python 3.10
|
||||||
```
|
- Required packages: `numpy`, `opencv-python`, `amlnnlite`
|
||||||
|
|
||||||
The script will automatically process all image files (`.jpg`, `.jpeg`, `.png`, `.bmp`) in the specified directory and save results to a `{model_name}_result` folder.
|
**Install dependencies:**
|
||||||
|
```bash
|
||||||
## Results
|
pip install numpy opencv-python amlnnlite-1.0.0-cp310-cp310-linux_aarch64.whl
|
||||||
|
```
|
||||||
The program will print the detection count and detected objects for each processed image. The result image with bounding boxes will be saved to the specified output directory.
|
|
||||||
|
**Run on device:**
|
||||||
You can pull the result image back to view it:
|
```bash
|
||||||
```bash
|
# Basic usage (process current directory)
|
||||||
adb pull result.jpg.
|
python yoloworld.py --model-path ./yoloworld_int8_A311D2.adla
|
||||||
```
|
|
||||||

|
# Specify image directory
|
||||||
|
python yoloworld.py --model-path ./yoloworld_int8_A311D2.adla --image-dir ./
|
||||||
The program detects objects from predefined classes (handbag, backpack, wallet, watch, necklace, bracelet, earrings, finger ring, sunglass, hat, shoes, belt, makeup palette, lipstick tube, car, truck, bicycle, motorcycle, phone, laptop, camera, wine bottle, stuffed toy) and draws bounding boxes with class labels on the result images.
|
```
|
||||||
|
|
||||||
|
The script will automatically process all image files (`.jpg`, `.jpeg`, `.png`, `.bmp`) in the specified directory and save results to a `{model_name}_result` folder.
|
||||||
|
|
||||||
|
## Results
|
||||||
|
|
||||||
|
The program will print the detection count and detected objects for each processed image. The result image with bounding boxes will be saved to the specified output directory.
|
||||||
|
|
||||||
|
You can pull the result image back to view it:
|
||||||
|
```bash
|
||||||
|
adb pull result.jpg.
|
||||||
|
```
|
||||||
|

|
||||||
|
|
||||||
|
The program detects objects from predefined classes (handbag, backpack, wallet, watch, necklace, bracelet, earrings, finger ring, sunglass, hat, shoes, belt, makeup palette, lipstick tube, car, truck, bicycle, motorcycle, phone, laptop, camera, wine bottle, stuffed toy) and draws bounding boxes with class labels on the result images.
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,8 @@ echo "BUILD_DIR: ${BUILD_DIR}"
|
||||||
mkdir -p ${BUILD_DIR}
|
mkdir -p ${BUILD_DIR}
|
||||||
cd ${BUILD_DIR}
|
cd ${BUILD_DIR}
|
||||||
|
|
||||||
cmake ../../src \
|
cmake -Wno-dev ../../src \
|
||||||
|
-DAMLNN_HOME=${AMLNN_HOME:-} \
|
||||||
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake \
|
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake \
|
||||||
-DANDROID_ABI=${TARGET_ABI} \
|
-DANDROID_ABI=${TARGET_ABI} \
|
||||||
-DANDROID_PLATFORM=android-24 \
|
-DANDROID_PLATFORM=android-24 \
|
||||||
|
|
|
||||||
|
|
@ -1,45 +1,35 @@
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.10...3.27)
|
||||||
project(yolo_world_demo)
|
project(yolo_world_demo)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
# Set NNSDK path
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../../../../cmake")
|
||||||
if(NOT DEFINED NNSDK_DIR)
|
find_package(AMLNN REQUIRED)
|
||||||
set(NNSDK_DIR "${CMAKE_SOURCE_DIR}/../../../../../amlnn-toolkit/nn_runtime/nnsdk")
|
include_directories(${AMLNN_INCLUDE_DIR})
|
||||||
endif()
|
link_directories(${AMLNN_LIBRARY_DIR})
|
||||||
set(NNSDK_ROOT "${NNSDK_DIR}")
|
|
||||||
message(STATUS "NNSDK_ROOT: ${NNSDK_ROOT}")
|
include_directories(${CMAKE_SOURCE_DIR}/../../../../common)
|
||||||
|
|
||||||
include_directories(${NNSDK_ROOT}/include)
|
# Set 3rdparty path
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/../../../../common)
|
set(3RDPARTY_DIR "${CMAKE_SOURCE_DIR}/../../../../dependency")
|
||||||
|
|
||||||
# Set 3rdparty path
|
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
||||||
set(3RDPARTY_DIR "${CMAKE_SOURCE_DIR}/../../../../dependency")
|
# Android needs log
|
||||||
|
link_libraries(log)
|
||||||
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
endif()
|
||||||
if (ANDROID_ABI STREQUAL "arm64-v8a")
|
|
||||||
link_directories(${NNSDK_ROOT}/android/arm64-v8a)
|
# Find OpenCV
|
||||||
else()
|
find_package(OpenCV REQUIRED)
|
||||||
link_directories(${NNSDK_ROOT}/android/armeabi-v7a)
|
include_directories(${OpenCV_INCLUDE_DIRS})
|
||||||
endif()
|
|
||||||
# Android needs log
|
add_executable(yolo_world_demo
|
||||||
link_libraries(log)
|
main.cpp
|
||||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
postprocess.cpp
|
||||||
link_directories(${NNSDK_ROOT}/linux/yocto/aarch64-poky-linux)
|
postprocess.h
|
||||||
endif()
|
${CMAKE_SOURCE_DIR}/../../../../common/model_loader.cpp
|
||||||
|
)
|
||||||
# Find OpenCV
|
|
||||||
find_package(OpenCV REQUIRED)
|
target_link_libraries(yolo_world_demo
|
||||||
include_directories(${OpenCV_INCLUDE_DIRS})
|
${OpenCV_LIBS}
|
||||||
|
${AMLNN_LIBRARY}
|
||||||
add_executable(yolo_world_demo
|
)
|
||||||
main.cpp
|
|
||||||
postprocess.cpp
|
|
||||||
postprocess.h
|
|
||||||
${CMAKE_SOURCE_DIR}/../../../../common/model_loader.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(yolo_world_demo
|
|
||||||
${OpenCV_LIBS}
|
|
||||||
nnsdk
|
|
||||||
)
|
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,8 @@ echo "BUILD_DIR: ${BUILD_DIR}"
|
||||||
mkdir -p ${BUILD_DIR}
|
mkdir -p ${BUILD_DIR}
|
||||||
cd ${BUILD_DIR}
|
cd ${BUILD_DIR}
|
||||||
|
|
||||||
cmake ../../src \
|
cmake -Wno-dev ../../src \
|
||||||
|
-DAMLNN_HOME=${AMLNN_HOME:-} \
|
||||||
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake \
|
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake \
|
||||||
-DANDROID_ABI=${TARGET_ABI} \
|
-DANDROID_ABI=${TARGET_ABI} \
|
||||||
-DANDROID_PLATFORM=android-24 \
|
-DANDROID_PLATFORM=android-24 \
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,21 @@
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.10...3.27)
|
||||||
project(yolo11_demo)
|
project(yolo11_demo)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
# Set NNSDK path
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../../../../cmake")
|
||||||
if(NOT DEFINED NNSDK_DIR)
|
find_package(AMLNN REQUIRED)
|
||||||
set(NNSDK_DIR "${CMAKE_SOURCE_DIR}/../../../../../amlnn-toolkit/nn_runtime/nnsdk")
|
include_directories(${AMLNN_INCLUDE_DIR})
|
||||||
endif()
|
link_directories(${AMLNN_LIBRARY_DIR})
|
||||||
set(NNSDK_ROOT "${NNSDK_DIR}")
|
|
||||||
message(STATUS "NNSDK_ROOT: ${NNSDK_ROOT}")
|
|
||||||
|
|
||||||
include_directories(${NNSDK_ROOT}/include)
|
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/../../../../common)
|
include_directories(${CMAKE_SOURCE_DIR}/../../../../common)
|
||||||
|
|
||||||
# Set dependency path
|
# Set dependency path
|
||||||
set(3RDPARTY_DIR "${CMAKE_SOURCE_DIR}/../../../../dependency")
|
set(3RDPARTY_DIR "${CMAKE_SOURCE_DIR}/../../../../dependency")
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
||||||
if (ANDROID_ABI STREQUAL "arm64-v8a")
|
|
||||||
link_directories(${NNSDK_ROOT}/android/arm64-v8a)
|
|
||||||
else()
|
|
||||||
link_directories(${NNSDK_ROOT}/android/armeabi-v7a)
|
|
||||||
endif()
|
|
||||||
# Android needs log
|
# Android needs log
|
||||||
link_libraries(log)
|
link_libraries(log)
|
||||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
||||||
link_directories(${NNSDK_ROOT}/linux/yocto/aarch64-poky-linux)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Find OpenCV
|
# Find OpenCV
|
||||||
|
|
@ -33,7 +23,6 @@ message(STATUS "OpenCV_DIR: ${OpenCV_DIR}")
|
||||||
find_package(OpenCV REQUIRED)
|
find_package(OpenCV REQUIRED)
|
||||||
include_directories(${OpenCV_INCLUDE_DIRS})
|
include_directories(${OpenCV_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
|
||||||
add_executable(yolox_demo
|
add_executable(yolox_demo
|
||||||
main.cpp
|
main.cpp
|
||||||
postprocess.cpp
|
postprocess.cpp
|
||||||
|
|
@ -42,5 +31,5 @@ add_executable(yolox_demo
|
||||||
|
|
||||||
target_link_libraries(yolox_demo
|
target_link_libraries(yolox_demo
|
||||||
${OpenCV_LIBS}
|
${OpenCV_LIBS}
|
||||||
nnsdk
|
${AMLNN_LIBRARY}
|
||||||
)
|
)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue