Skip to main content
Use the LiteRT runtime to run quantized LiteRT models on the NPU of Qualcomm® Dragonwing™ devices.

Prerequisites

Before running the application, complete the following steps to connect to the target device, download the required artifacts, and set up the Python environment.
  1. Enable Wi-Fi and SSH on the device. The device requires an internet connection to download the artifacts needed to run sample applications. If SSH and Wi-Fi are already configured, skip this step. Follow Setup an SSH connection to enable Wi-Fi and SSH on the device.
  2. On the target device, download the download_artifacts.sh script, set executable permissions, and run it to download the model and label files to the device.
  3. Install the LiteRT runtime and other dependencies by setting up the Python environment on the target device.
    Activate the python environment:
    Install the LiteRT runtime, Pillow, and OpenCV packages:

Run an object detection application

The following Python application performs object detection in real time on a video file using a quantized YOLOX LiteRT model. It displays annotated frames to a file or Wayland display, and is optimized for edge AI scenarios using hardware acceleration through the QNN LiteRT delegate.
  1. Create and go to the ${HOME}/Downloads/qimsdk_samples/apps/ directory.
  2. Download the object_detection.py file.
    For code explanation, see Object detection with OpenCV and LiteRT below.
  3. Run the application:
    Download the output video to the host machine to review the results:
    When prompted for a password, enter oelinux123.

Object detection with OpenCV and LiteRT

To create an application similar to the object detection application described in the previous section, create an object_detection.py file as follows:
  1. In the ${HOME}/Downloads/qimdk_samples/apps/ folder, create an object_detection.py file.
  2. Add the following code to your object_detection.py file.
    The postprocessing in the following code is compatible with object detection models from AI Hub. For custom models, update the postprocessing logic to match the model’s output format and requirements.
    a. Import the required packages:
    b. Handle output arguments:
    c. Initialize and configure model parameters:
    d. Load the model and set up the LiteRT delegate:
    e. Set up video capture and preprocessing:
    f. Create a GStreamer pipeline to stream frames to the Wayland display:
    g. Initialize the main loop to read the video, run inference on each frame, and draw bounding boxes on the output:
    h. Release the pipeline and notify the user on completion: