Skip to main content

Export a custom YOLOv8 model using the QAIRT SDK

Prerequisites

Install the Qualcomm AI Runtime SDK on a host computer with Python >= 3.10 and PyTorch >=1.8. For more details, follow Install Qualcomm AI Runtime SDK. Run the following commands on the host computer.
  1. Activate your virtual environment.
  2. Install the Ultralytics package and export the ONNX model.

Procedure

  1. Convert the ONNX model to DLC.
  2. Generate quantized DLC.
    1. Prepare the calibration data set.
    2. Gather 5-10 images that used during training and save these images in the input directory.
    3. Use the preprocess.py script to convert .jpg images into the RAW files required for quantization.
      In this example, the model uses an input dimension of 320x320.
      1. Download the script as follows:
      2. Run the script with the following options:
        • <INPUT PATH>: Folder containing the original images
        • <OUTPUT PATH>: Folder where the RAW files will be generated
    4. Create an input.txt file containing the paths to all generated RAW files. The quantization process needs this file.
  3. Quantize the model, using snpe-dlc-quantize to convert the model to quantized DLC.

Run the demo

  1. Download the labels file. See Download model and label files.
  2. On the host computer, set the user environment variable:
  3. Push the test video file /etc/media on the device.
  4. Push the quantized YoloV8 model to the device.
  5. Retrieve the output tensor of the model, for example, output0. Model output tensor name in Netron graph viewer
  6. Sign in to the device using SSH:
  7. In the new shell, run the following commands: