Files
samirodr 5360a482fc update
2026-06-08 14:59:44 -04:00
..
2026-06-08 14:59:44 -04:00
2026-06-08 14:59:44 -04:00

Qualcomm AI Hub Example

This example takes the ONNX model produced by the SageMaker training example and runs the Qualcomm AI Hub upload workflow:

  1. Quantize
  2. Compile
  3. Validate
  4. Profile
  5. Download the compiled artifact

Prerequisites

Run the training example first and wait for it to complete:

examples/training/run_training.sh --wait

The config.yaml file must include AI Hub settings:

aihub:
  device:
    name: Samsung Galaxy S25 (Family)
  target_runtime: tflite
  input_specs:
    input: [[1, 3, 160, 160], float32]
  output_dir: build/qai-hub

Finally, the user needs to authenticate with Qualcomm AI Hub using:

qai-hub configure --api_token

Prepare Inputs

AI Hub does not consume the raw JPG training images directly. It needs NumPy tensors that match the ONNX model input shape and preprocessing.

To generate calibration and validation inputs:

python examples/ai-hub/prepare_inputs.py

This writes:

examples/training/data/aihub_calibration/*.npy
examples/training/data/inputs.npz

The script applies the same image preprocessing used by the training example:

  • resize to 160x160
  • convert to channel-first 1x3x160x160
  • normalize with ImageNet mean and standard deviation

Upload Model to Qualcomm Workbench

The model can be uploaded to Qualcomm Workbench using:

qc-cli ai-hub upload examples/training/data/aihub_calibration examples/training/data/inputs.npz

The first argument is the calibration path for the model and the second argument is the input file, both of which were created by the prepare_inputs.py script. For more details, add --help after the upload command.

The upload command runs the following commands in order:

  1. qc-cli ai-hub quantize
  2. qc-cli ai-hub compile
  3. qc-cli ai-hub validate
  4. qc-cli ai-hub profile

Finally the user can download the model from AI Workbench using the command

qc-cli ai-hub download