amlnn-model-playground/examples/yolov8/README.md

3.9 KiB
Raw Blame History

yolov8

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 tasks in a wide range of applications.

2.Model Download

3. Model Conversion

cd model
Usage:   ./adla_convert.sh model_path adla_toolkit_path target_platform

example
 ./adla_convert.sh yolov8m.onnx  /xxxx/adla-toolkit-binary-3.2.9.3 PRODUCT_PID0XA005
 ./adla_convert.sh yolov8s.onnx  /xxxx/adla-toolkit-binary-3.2.9.3 PRODUCT_PID0XA005
 ./adla_convert.sh yolov8n.onnx  /xxxx/adla-toolkit-binary-3.2.9.3 PRODUCT_PID0XA005
Parameter Description
model_path onnx model path
adla_toolkit_path path to adla_toolkit
target_platform Specify target platform. For A311D2: PRODUCT_PID0XA003. For S905X5: PRODUCT_PID0XA005

4. Demo Run

CPP

1. Compile

Prerequisites:

  • Android NDK (r25e recommended)
  • ANDROID_NDK_PATH environment variable set

Build:

# Build for arm64-v8a
cd examples/yolov8/cpp
./build-android.sh -a arm64-v8a

The executable will be generated at build/android/yolov8_demo (Note: executable name may vary, verify in build folder).

2. Run

# Push executable to device
adb push build/android/yolov8_demo /data/local/tmp/
adb push model/yolov8s_int8_A311D2.adla /data/local/tmp/
adb push test_image.jpg /data/local/tmp/

# Run on device
adb shell
cd /data/local/tmp
chmod +x yolov8_demo
export LD_LIBRARY_PATH=/vendor/lib64 or (/vendor/lib)

# Usage: ./yolo_world_demo <model_path> <image_path>
./yolov8_demo yolov8s_int8_A311D2.adla test_image.jpg"

Note: Replace yolov8s_int8_A311D2.adla with your actual model file path.

Python

Prerequisites:

  • Python 3.10
  • Required packages: numpy, opencv-python, amlnnlite

Install dependencies:

pip install numpy opencv-python amlnnlite-1.0.0-cp310-cp310-linux_aarch64.whl

Run on device:

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:

adb pull result.jpg.

alt text