Skip to main content
The gst-ai-classification sample application demonstrates hardware-accelerated image classification on a video stream. The pipeline receives input from a camera, file source, Real-Time Streaming Protocol (RTSP) stream or USB camera, performs preprocessing, runs inference on the AI hardware, and displays the results on screen. gst-ai-classification pipeline diagram The gst-ai-classification application is part of the Qualcomm Intelligent Multimedia (QIM) SDK and is available on the device after flashing. You must push the model and label files to the device before running the application.

Download model and label files

  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 host computer, set the user environment variable:
    export USER=root
    
  3. Sign in to the target device using SSH:
    ssh $USER@<IP_ADDRESS_OF_TARGET_DEVICE>
    
  4. On the target device, download and run the download_artifacts.sh script to download the model and label files:
    cd /tmp
    curl -fsSL https://raw.githubusercontent.com/qualcomm/sample-apps-for-qualcomm-linux/refs/heads/main/qualcomm-linux/scripts/download_artifacts.sh | bash
    
  5. (Optional) Download the YOLOv8 model, which is not included in the default download. Use one of the following methods:
    1. Create a Qualcomm AI Hub account.
    2. Go to Settings in the upper right corner and copy your API key.
    3. Run the following commands on the host computer:
      curl -L -O https://raw.githubusercontent.com/qualcomm/sample-apps-for-qualcomm-linux/refs/heads/main/qualcomm-linux/scripts/export_model.sh
      chmod +x export_model.sh
      
      Replace <API_KEY> with your API key:
      ./export_model.sh --api-key=<API_KEY>
      
      The models are downloaded to the export_assets directory.
    4. Copy the model to the /etc/models/ directory on the device:
      scp <working-directory>/export_assets/yolov8_det-tflite-w8a8/yolov8_det.tflite $USER@<IP_ADDRESS_OF_TARGET_DEVICE>:/etc/models/
      

Run the sample application

  1. On the host computer, set the user environment variable:
    export USER=root
    
  2. Sign in to the device using SSH:
    ssh $USER@<IP_ADDRESS_OF_TARGET_DEVICE>
    
  3. Run the sample application:
    gst-ai-classification --config-file=/etc/configs/config_classification.json
    
    For more information about the configuration fields or available options, use the help command:
    gst-ai-classification -h
    
The application overlays classified object labels and confidence scores on the video stream and displays the results on the configured output. To stop the application, press Ctrl+C.

Configure the application

This section uses the following default file locations:
  • /etc/models/ — model files
  • /etc/labels/ — label files
  • /etc/media/ — video files
  • /etc/configs/ — configuration files
Edit the /etc/configs/config_classification.json file to specify your model, input source, and output preferences. Configuration template:
{
  "file-path": "<path-to-input-video>",
  "ml-framework": "<snpe or tflite or qnn or onnx>",
  "model": "<path-to-model-file>",
  "labels": "<path-to-label-file>",
  "threshold": "<postprocessing threshold, integer value from 1 to 100>",
  "runtime": "<dsp, gpu, or cpu>",
  "output-type": "<waylandsink, filesink, or rtspsink>"
}
Example configuration — LiteRT model on a video file using the DSP runtime:
{
  "file-path": "/etc/media/video.mp4",
  "ml-framework": "tflite",
  "model": "/etc/models/inception_v3_quantized.tflite",
  "labels": "/etc/labels/classification.json",
  "threshold": 40,
  "runtime": "dsp"
}
JSON configuration field descriptions
FieldDescription
ml-framework
  • snpe: Qualcomm Neural Processing SDK
  • tflite: LiteRT
  • qnn: Qualcomm AI Engine Direct
  • onnx: ONNX Runtime
runtime
  • cpu
  • gpu
  • dsp
output-ip-addressOutput server IP address
portOutput server port
video-formatUSB camera format: nv12, yuy2, or mjpeg, with width, height, and framerate parameters
output-fileName of the output file. Default: output_classification.mp4
output-type
  • waylandsink: display on Wayland
  • filesink: save to file
  • rtspsink: stream to RTSP server
file-pathPath to the input video file
rtsp-ip-portRTSP input stream in the format rtsp://<ip>:<port>/<stream>
cameraCamera index: primary (0) or secondary (1)

Notes

  • To stop the application, press Ctrl+C.
  • To enable GStreamer debug logging, set the GST_DEBUG environment variable. For example, to log all warnings:
    export GST_DEBUG=2
    
    For more troubleshooting options, see Troubleshooting.