Build DX-M1 Inference Apps With an AI Coding Agent
Build Python or C++ inference apps for the DEEPX DX-M1 NPU by describing them to an AI coding agent. Setup, prompts, validation steps, and fixes.
With agent-driven development for DX-APP, you describe the inference app you want in plain English and an AI coding agent builds it for the DEEPX DX-M1 NPU. The agent writes the Python or C++ code, registers your .dxnn model, validates the result, and leaves you with scripts to run it.
This guide covers the practical path: setup, your first prompt, the questions the agent asks, what lands on disk, and how to check the app works. It's the companion to our DX-COM guide: DX-COM turns your model into a .dxnn file, and DX-APP turns that file into a running application.
The short version
- Open the
dx_appproject in your AI coding tool. - Tell the agent what to build, for example: "Build a yolo26n person detection app using Python."
- Confirm three choices: language and variant, AI task, and model.
- Wait while the agent generates and validates the code.
- Run
bash setup.sh && bash run.shfrom the session folder.
Key terms
- DX-APP is DEEPX's toolkit for building standalone inference applications on the DX-M1.
- DXNN is DEEPX's compiled model format (
.dxnn). The DX-M1 NPU runs these files. - Factory is the class that defines how an app prepares inputs and interprets outputs for one model. Every generated app has one.
- Sync and async describe how the app feeds frames to the NPU: one at a time, or in a pipeline.
- Postprocessing turns raw model output into results you can use, such as labeled boxes.
Which agent does what
You usually talk to one agent, dx-app-builder. It reads your request and hands the work to a specialist.
| Agent | What it does |
|---|---|
dx-app-builder | Router. Classifies your request and dispatches it |
dx-python-builder | Builds Python apps in four variants (see Step 3) |
dx-cpp-builder | Builds C++ apps using the InferenceEngine API |
dx-benchmark-builder | Benchmarks and profiles performance |
dx-model-manager | Downloads, registers, and manages .dxnn models |
dx-validator | Checks generated code and framework integrity. Runs automatically after generation |
In Claude Code and Cursor, you type the request and routing happens for you. In GitHub Copilot and OpenCode, you can name an agent with @.
Before you start
| Requirement | Details |
|---|---|
| Device | A Sixfab AI HAT+ or Sixfab Edge AI Expansion Board on a Raspberry Pi 5, or an ALPON X5 AI |
| OS | Raspberry Pi OS Trixie (64-bit). Bookworm also works |
| Runtime and driver | Installed with the Sixfab quickstart for your device (see below). Only validation levels 4 and 5 need the NPU (see Step 5) |
| Project folder | The dx_app repository, cloned in Step 1 |
| Python environment | Dependencies installed by install.sh. If you use a virtual environment, activate it and make sure PYTHONPATH includes the project root |
| A model | A .dxnn file, or let the agent download and register one |
| AI coding agent | Claude Code, GitHub Copilot (VS Code), Cursor, OpenCode, or Codex CLI |
Have no .dxnn file yet? You have three routes. Ask the agent to download one ("Download yolo26n model for DX-M1"), grab a pre-compiled model from the Sixfab Model Zoo, or compile your own with the DX-COM guide.
Install the runtime first
DX-APP needs the DEEPX runtime and kernel driver on your device. Sixfab packages both, so follow the quickstart for your product and come back here when it's done:
| Your device | Quickstart |
|---|---|
| Sixfab AI HAT+ | AI HAT+ quickstart |
| Sixfab Edge AI Expansion Board | Edge AI Expansion Board quickstart |
| ALPON X5 AI | ALPON X5 AI quickstart |
Then check that your NPU is visible:
dxrt-cli -sExpected result: a device report that shows your NPU, the driver and firmware versions, and the PCIe link. If the NPU doesn't show up, see Troubleshooting.
Choose your tool
Each tool loads the project's configuration automatically when you open the folder.
| Tool | Type | How you talk to the agent |
|---|---|---|
| Claude Code | CLI | Type your request as normal conversation |
| Cursor | IDE | Type your request as normal conversation |
| GitHub Copilot | VS Code | @dx-app-builder "your request", or a specialist agent |
| OpenCode | CLI | @dx-app-builder "your request", or a slash skill such as /dx-agent-app-build-python |
| Codex CLI | CLI | Type your request as normal conversation |
Step 1: Get the project and open it
Clone the repository on your device, install its dependencies, and build the sample applications:
git clone https://github.com/DEEPX-AI/dx_app
cd dx_app
./install.sh
./build.shinstall.sh installs the dependencies. build.sh builds the DX-APP applications. Both can take a while on the first run. To see the available options, run ./install.sh --help and ./build.sh --help.
Then start your tool from inside the dx_app folder. Each tool finds its configuration file there.
# Claude Code
claude
# OpenCode
opencode
# Codex CLI
codex
# GitHub Copilot: open the folder in VS Code
code .
# Cursor: open the folder in Cursor
cursor .If you use a Python virtual environment, activate it in your terminal before you start. The validation scripts need it.
Step 2: Tell the agent what to build
State the task, the model, and the language. These prompts cover the common cases:
| You want | Prompt |
|---|---|
| A Python detection app | Build a yolo26n person detection app using Python |
| A C++ app | Build a C++ inference app for yolo26n using InferenceEngine |
| A faster, pipelined app | Build an async high-performance detection app with yolo26n |
| Pose estimation | Build a pose estimation app with yolo26n-pose |
| Instance segmentation | Build an instance segmentation app with yolo26n-seg |
| Image classification | Build an image classification app with EfficientNet-B0 |
| A model download | Download yolo26n model for DX-M1 |
| A check of existing code | Validate the detection app I created |
In OpenCode, slash skills such as /dx-agent-app-build-python do the same job. In Copilot, start with @dx-app-builder, or with a specialist like @dx-python-builder.
These are examples. Swap in your own model name and task.
Step 3: Confirm the three choices
Before it writes any code, the agent asks three questions. They're mandatory, and the agent asks them even when your prompt already answers them. Treat them as a confirmation step.
1. Which language and variant?
| Choice | What you get |
|---|---|
| Python: sync | One frame at a time. The simplest app to read and debug |
| Python: async | A pipelined app that feeds frames continuously |
| Python: sync with C++ postprocessing | Sync app that runs postprocessing in C++ through pybind |
| Python: async with C++ postprocessing | Async app with C++ postprocessing |
| C++ | A native app built on the InferenceEngine API |
New to this? Start with Python sync. It's the easiest one to read and the easiest to debug.
2. Which AI task?
Detection, classification, segmentation, or pose estimation. Pick the one that matches your model.
3. Which model?
Name a specific model (for example yolo26n) or ask the agent to recommend one. If the .dxnn file isn't registered yet, dx-model-manager downloads it and records it in model_registry.json.
Step 4: Review what the agent created
Each run gets its own session folder, so runs never overwrite each other:
dx-agent-dev/<session_id>/
├── README.md
├── session.json
├── setup.sh (mandatory)
├── run.sh (mandatory)
├── session.log (mandatory)
└── src/python_example/{task}/{model}/
├── __init__.py
├── config.json
├── {model}_factory.py
├── {model}_sync.py
├── {model}_async.py
├── {model}_sync_cpp_postprocess.py
└── {model}_async_cpp_postprocess.pyThe session ID looks like YYYYMMDD-HHMMSS_<agent>_<model>_<task>, where <agent> is claude, copilot, cursor, or opencode. The agent writes into the project's own src/ folder only when you explicitly ask for production placement.
What each file does
| File | Purpose |
|---|---|
config.json | Model path, task type, input dimensions, and label map |
{model}_factory.py | Defines how the app prepares inputs, processes outputs, and draws results |
{model}_sync.py | Entry point for the synchronous app |
{model}_async.py | Entry point for the pipelined async app |
{model}_sync_cpp_postprocess.py | Sync entry point with C++ postprocessing |
{model}_async_cpp_postprocess.py | Async entry point with C++ postprocessing |
setup.sh / run.sh | Set up the environment and launch the app |
session.log | Record of what the agent did |
Depending on the variant you chose, you may see only some of the entry-point files.
Step 5: Validate the app
The dx-validator agent runs automatically after generation. You can also run the same checks yourself. Validation works as a pyramid of five levels, and each level must pass before the next one counts:
| Level | What it checks | Needs NPU? |
|---|---|---|
| Absolute imports, naming, structure, factory methods | No |
| config.json schema, model path, task types | No |
| --help runs and modules import | No |
| End-to-end inference on a sample image | Yes |
| FPS meets the target thresholds | Yes |
Run the checks from the project root:
# Levels 1-2: static and config checks
python .deepx/scripts/validate_app.py src/python_example/{task}/{model}/
# Levels 1-3: adds smoke tests
python .deepx/scripts/validate_app.py src/python_example/{task}/{model}/ --smoke-test
# Framework integrity
python .deepx/scripts/validate_framework.pyReplace {task} and {model} with your own folder names, for example detection and yolo26n.
Expected result: each level reports pass or fail with the reason. Levels 1 to 3 run on any machine with the environment set up. Levels 4 and 5 need the DX-M1.
Step 6: Run the app
From the session folder:
bash setup.sh && bash run.shExpected result: the app loads your model, runs inference on a sample input, and shows or prints the results. For a detection app, that means labeled boxes.
Note:
setup.shchanges your environment. Read it first if you want to know what it does.
Editing the generated code
You'll probably want to change what the agent wrote. Two rules keep the app working:
- Use absolute imports. Relative imports such as
from .factory import ...break the app. LLMs default to them, so check generated code for them. - Keep all five factory methods. Every factory implements
create_preprocessor,create_postprocessor,create_label_map,create_input_config, andcreate_visualizer. If one is missing, validation fails.
Don't edit the platform files (.github/, .cursor/, .opencode/, CLAUDE.md, AGENTS.md). DEEPX generates them from the .deepx/ folder. To change them, edit the source in .deepx/ and re-run DEEPX's dx-agent-gen generator. A pre-commit hook runs it automatically when you commit.
Troubleshooting
| What you see | Likely cause | Fix |
|---|---|---|
| Relative imports in generated code | The AI model's default habit | Switch to absolute imports |
| Factory class is missing methods | Incomplete factory | Implement all five factory methods listed above |
| Model not found at runtime | The .dxnn path isn't registered | Ask dx-model-manager to download and register it in model_registry.json |
| NPU not available, or a device error | The accelerator isn't detected | Run dxrt-cli -s and check that the kernel module is loaded |
validate_app.py fails right away | Python path or virtual environment isn't set | Activate the virtual environment and set PYTHONPATH to the project root |
Still stuck? Ask the agent to debug. It has a debugging skill (/dx-swe-debugging) that finds the cause before it proposes a fix.
Optional skills
You can call these by name in tools that support slash commands, or describe the same intent in plain language.
| Skill | Use it to |
|---|---|
/dx-agent-app-build-python | Build a Python app |
/dx-agent-app-build-cpp | Build a C++ app |
/dx-agent-app-build-async | Build an async app |
/dx-agent-app-model-management | Download and register models |
/dx-agent-app-validate | Validate an app |
/dx-swe-brainstorm | Plan before building |
/dx-swe-tdd | Validate each step as you go |
/dx-swe-verify | Require evidence before the agent calls the job done |
Next steps
- Watch your NPU. Use
dxtopordxrt-clito see per-core load while your app runs. The system monitoring guide explains both. - Find more models. Browse the Sixfab Model Zoo and the supported models catalog.
- Compile your own model. Use the DX-COM guide and the DX-COM configuration reference.
- Study more examples. Sixfab maintains the sixfab-dx-examples repository.
FAQ
What is agent-driven development for DX-APP?
It's a way to build inference apps for the DEEPX DX-M1 NPU by talking to an AI coding agent. You describe the app, and specialist agents generate the code, register the model, validate the result, and write the setup and run scripts.
How is this different from the DX-COM guide?
DX-COM compiles a model into a .dxnn file. DX-APP builds the application that loads that file and runs inference. Most projects use both: compile first, then build the app.
Which Sixfab products does it work with?
The Sixfab AI HAT+ and Edge AI Expansion Board on a Raspberry Pi 5, and the ALPON X5 AI. Use Raspberry Pi OS Trixie (Bookworm also works), and install the runtime with the quickstart for your device first.
Should I choose Python or C++?
Start with Python sync. It's the easiest to read and debug. Move to the async variants when you want pipelined processing, and to C++ when you need a native app.
Do I need an NPU to validate the app?
Not for levels 1 to 3 (static checks, config checks, and smoke tests). Levels 4 and 5, which run real inference and measure FPS, need a DX-M1.
What do the [DX-AGENT-DEV: START] and [DX-AGENT-DEV: DONE ...] lines mean?
[DX-AGENT-DEV: START] and [DX-AGENT-DEV: DONE ...] lines mean?They're fixed markers the agent prints at the start and end of each task, mainly for automated testing. The DONE line includes your output folder, for example [DX-AGENT-DEV: DONE (output-dir: dx-agent-dev/<session_id>)]. The agent only prints DONE after it has produced code, scripts, configs, and validation results, not after planning alone.
Why does the agent ask questions I already answered in my prompt?
The three questions (variant, task, model) are mandatory. The agent confirms them every time, even when your prompt already contains the answers.
Updated about 1 hour ago
