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 the following workloads:
- Desktop development with C++ (required for C++ samples)
- .NET desktop development (required for C# samples)
- Windows App SDK 2.1.3 or later
- CMake 3.21 or later (required for CMake samples)
- NuGet CLI (
nuget.exe on PATH, required for CMake samples)
- Python 3.10-3.13 for Python samples on x64 and ARM64 devices
| Sample |
Description |
Key Features |
| WinMLEpCatalog |
CMake-based EP catalog sample using the WinML C API |
CMake build system, automatic NuGet restore, EP discovery and registration |
| Sample |
Description |
Key Features |
| cpp-abi |
Direct ABI implementation using raw COM interfaces |
Automatic ABI header generation, no projections |
| Sample |
Description |
Key Features |
| CSharpConsoleDesktop |
Basic C# console application |
Shared helper usage, command-line interface |
| 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) |