$ show AXERA-TECH/ax-samples
This repository is a collection of C++ sample programs for deploying deep learning models on AXERA AI SoCs (NPU chips). It provides ready-to-run inference examples for a wide range of computer vision tasks including object detection (YOLOv5/6/7/8/9/10/11/26, YOLOX, YOLO-World, PPYOLOE+, RT-DETR, SCRFD), instance segmentation, oriented object detection (OBB), pose estimation, depth estimation, semantic segmentation, stereo matching, and more. Each example is a standalone command-line executable that loads a pre-compiled .axmodel, runs inference via the AX_ENGINE API, post-processes the outputs, and saves a result image. The code is organized per target chip (ax650, ax637, ax620e, ax615) with near-identical copies of examples across platforms, differing only in system initialization and minor chip-specific logic. The architecture is not a library or framework but a set of reference implementations demonstrating the integration of AXERA's NPU SDK. The primary data flow is: load image → preprocess (letterbox resize, color conversion) → push to engine → run synchronous inference → decode model outputs (e.g., anchor-based proposals, DFL, NMS) → draw bounding boxes/keypoints/masks → save output. External dependencies include the AX_ENGINE runtime, OpenCV for image processing, and standard C++ libraries. The build system uses CMake with per-chip toolchain files and GitHub Actions CI for cross-compilation verification. While the code is functional and covers a broad model zoo, it exhibits significant duplication across chip directories and hardcoded configuration (thresholds, image sizes, class names). The monolithic detection.hpp (~3500 lines) bundles many model-specific post-processing functions, increasing maintenance burden. There are no automated tests, and manual memory management is prevalent. Despite these quality issues, the repository serves its purpose as a practical reference for developers integrating AXERA hardware, and it stays current with recent model releases (YOLOv13, YOLO26, Depth Anything V2).
The LLM identified 2 files worth highlighting for reuse:
Provides a clean abstraction for AX_ENGINE IO lifecycle management: prepare_io allocates input/output tensors based on model info, push_input copies preprocessed data to the engine input buffer, free_io releases resources, and print_io_info logs tensor details. This component is self-contained, used across all examples, and could be extracted into any AX_ENGINE-based project with minimal modification. It demonstrates a consistent pattern for handling engine IO that reduces boilerplate in each example.
Contains reusable image preprocessing functions (get_input_data_letterbox, get_input_data_no_letterbox, get_input_data_centercrop) that handle resizing, padding, color conversion (BGR to RGB), and normalization. These functions are model-agnostic and used by all examples to prepare input images for the NPU engine. The implementation is clean, parameterized, and could be reused in other computer vision pipelines that require standard preprocessing transforms.