This repository contains comprehensive samples demonstrating how to use Windows ML and ONNX Runtime for machine learning inference on Windows. These samples emphasize Windows ML integration with various Windows technologies via the Windows App SDK. Samples for the ONNX Runtime can be found in this repository.
Windows ML enables high-performance, reliable inferencing of machine learning models on Windows devices. These samples demonstrate key concepts including:
- Execution Provider Selection - Automatic discovery and acquisition of execution providers for hardware-accelerated inference
- Model Compilation - Optimize models for specific hardware during first run
- Windows App SDK Deployment Types - Use models in a variety of different Windows App SDK deployment modes (e.g., self-contained, framework-based deployment)
- Windows 11 PC running version 24H2 (build 26100) or greater
- Visual Studio 2022 with C++ and .NET workloads
- Windows App SDK 1.8.1 or later
- Python 3.10-3.13 for Python samples on x64 and ARM64 devices
| Sample |
Description |
Key Features |
| cpp-abi |
Direct ABI implementation using raw COM interfaces |
Automatic ABI header generation, no projections |
| Sample |
UI Framework |
Description |
| cs-wpf |
WPF |
Image classification example |
| cs-winforms |
Windows Forms |
Image classification example |
| cs-winui |
WinUI 3 |
Image classification example |
| Sample |
Description |
Key Features |
| SqueezeNetPython |
Python image classification |
WinML Python bindings, batch image processing |
Most samples follow this pattern:
- Initialize Environment - Create ONNX Runtime environment
- Register Execution Providers - Discover and register available hardware accelerators
- Load Model - Load ONNX model, optionally compile for target hardware
- Preprocess Input - Convert images to model input format
- Run Inference - Execute model and get predictions
- Process Results - Apply softmax and display top predictions
Samples use these pre-trained models:
- SqueezeNet - Lightweight image classification (included)
- ResNet-50 - High-accuracy image classification (requires AI Toolkit conversion)
These samples detect and utilize the CPU, GPU, and NPU.
| Resource |
Description |
| capture-logs |
Scripts and profiles for capturing Windows ML diagnostic logs (docs) |