update ai-hub to first optimize model for Workbench

Remove old examples
This commit is contained in:
2026-06-09 14:55:26 -04:00
parent 6c9f30d290
commit f26e8256f0
12 changed files with 260 additions and 700 deletions

View File

@@ -181,7 +181,7 @@ Add AI Hub settings to `config.yaml`. The input name and image size must match t
aihub:
device:
name: Dragonwing IQ-9075 EVK
target_runtime: tflite
target_runtime: onnx
input_specs:
images: [[1, 3, 640, 640], float32]
job_name: meter-detection
@@ -189,7 +189,7 @@ aihub:
output_dir: build/qai-hub/meter-detection
```
Use the same image size configured in `sagemaker.training.hyperparameters.imgsz`. For example, a smoke-test model trained with `imgsz: 320` requires `images: [[1, 3, 320, 320], float32]`.
The ONNX graph is the source of truth. The export normally uses the same value as `sagemaker.training.hyperparameters.imgsz`, but changing `config.yaml` after training does not resize an existing model. For example, a model exported with `imgsz: 320` requires `images: [[1, 3, 320, 320], float32]`.
## 7. Prepare AI Hub Inputs
@@ -208,8 +208,6 @@ examples/meter-detection/data/inputs.npz
The script applies the preprocessing expected by the exported YOLO model: aspect-ratio-preserving letterboxing, RGB channel order, channel-first layout, and pixel values normalized to `[0, 1]`.
Set `--image-size` to the training `imgsz` value when it is not `640`.
## 8. Upload To Qualcomm AI Hub
Use the SageMaker job name printed by `qc-cli train start`:
@@ -221,7 +219,12 @@ qc-cli ai-hub upload \
--from-job qc-cli-YYYYMMDD-HHMMSS
```
The command downloads the job's `model.tar.gz`, finds `model.onnx`, uploads it to AI Hub, and runs quantization, compilation, validation, and profiling. The uploaded source model uses the configured `aihub.model_name`.
The command downloads the job's `model.tar.gz`, finds `model.onnx`, and runs the following AI Hub workflow:
1. Compile the external ONNX to a Workbench-optimized ONNX model.
2. Quantize the optimized ONNX model.
3. Compile the quantized model when the configured deployment runtime is not `onnx`.
4. Validate and profile the final model.
The training example sanitizes the Ultralytics ONNX export before saving `model.onnx`. This removes graph input or output names, such as `output0`, that are duplicated in the ONNX `value_info` metadata and rejected by AI Hub.
@@ -238,24 +241,6 @@ qc-cli ai-hub upload \
--onnx-path build/qai-hub/meter-detection/model.aihub.onnx
```
If the meter-detection job is still the last training job in `.qc-cli.json`, `--from-job` can be omitted. Keeping it explicit prevents accidentally uploading an artifact from a different training run.
To resume after a completed step, use one of:
```bash
qc-cli ai-hub upload \
examples/meter-detection/data/aihub_calibration \
examples/meter-detection/data/inputs.npz \
--from-step compile
```
```bash
qc-cli ai-hub upload \
examples/meter-detection/data/aihub_calibration \
examples/meter-detection/data/inputs.npz \
--from-step validate
```
Download the compiled artifact after the workflow completes:
```bash