"""Decode raw HTP output saved by the three documented device runners.""" import argparse import json from pathlib import Path import numpy as np from infer import decode, load_heads def main() -> None: parser = argparse.ArgumentParser() parser.add_argument("--runtime", choices=["tflite-qnn", "onnx-qnn", "native-qnn"], required=True) parser.add_argument("--capture-dir", type=Path, required=True) parser.add_argument("--image-id", type=int, required=True, help="Numeric stem of the input image's .bin file") parser.add_argument("--native-index", type=int, default=0, help="Zero-based line index of the QNN native input list") parser.add_argument("--image-size", type=Path, required=True) parser.add_argument("--anchors", type=Path, required=True) args = parser.parse_args() size = json.loads(args.image_size.read_text(encoding="utf-8")) anchors = np.fromfile(args.anchors, np.float32).reshape(19206, 4) boxes, scores, current_anchors = load_heads( args.runtime, args.capture_dir, args.image_id, args.native_index, anchors) print(json.dumps(decode(boxes, scores, current_anchors, (size["width"], size["height"])), indent=2)) if __name__ == "__main__": main()