Qualcomm AI Hub Example
This example takes the ONNX model produced by the SageMaker training example and runs the Qualcomm AI Hub upload workflow:
- Quantize
- Compile
- Validate
- Profile
- 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:
qc-cli ai-hub quantizeqc-cli ai-hub compileqc-cli ai-hub validateqc-cli ai-hub profile
Finally the user can download the model from AI Workbench using the command
qc-cli ai-hub download