DirectML Object Detection Samples

Leverage the power of DirectML for high-performance object detection on Windows.

Overview

This section provides practical code samples demonstrating how to implement efficient object detection using DirectML on Windows. DirectML is a low-level API that accelerates machine learning inference on DirectX 12-capable hardware, making it ideal for real-time computer vision applications.

These samples cover common object detection models and techniques, allowing you to integrate powerful AI capabilities into your Windows applications.

Featured Samples

SSD Object Detection

Implement Single Shot MultiBox Detector (SSD) for real-time object detection. This sample shows how to load a pre-trained SSD model and perform inference on images.

Learn More

YOLOv3/v4 Integration

Explore the integration of popular YOLO (You Only Look Once) models. This sample guides you through setting up and running YOLOv3 or YOLOv4 for accurate object localization.

Learn More

Custom Model Pipeline

Learn how to build a custom object detection pipeline using DirectML operators. This sample is useful for adapting your own trained models or experimenting with novel architectures.

Learn More

SSD Object Detection Sample

The SSD sample showcases the end-to-end process of object detection with a pre-trained Single Shot MultiBox Detector model using DirectML.

Key Features:

Example Code Snippet (C++):

#include <dxcore.h>
#include <winrt/base.h>

// ... Initialize DirectML device and operator set ...

winrt::com_ptr<IDMLOperator> ssdOperator;
// ... Configure operator inputs and outputs ...

// Create persistent resource for operator inputs/outputs
winrt::com_ptr<IDMLBuffer> inputBuffer;
winrt::com_ptr<IDMLBuffer> outputBuffer;
// ... Allocate and initialize buffers ...

// Create a DirectML binding table
winrt::com_ptr<IDMLBindingTable> bindingTable;
// ... Bind buffers to operator ...

// Create an operator graph
winrt::com_ptr<IDMLOperatorGraph> graph;
// ... Add operator to graph ...

// Compile the graph
winrt::com_ptr<IDMLCompiledOperator> compiledGraph;
// ... Compile graph ...

// Record execution commands
winrt::com_ptr<ID3D12GraphicsCommandList> commandList;
// ... Create command list ...

// Execute compiled graph
compiledGraph->Compile(commandList.get(), bindingTable.get());
// ... Submit command list ...
View Full SSD Sample

YOLOv3/v4 Integration Sample

This sample demonstrates how to leverage DirectML with popular YOLO (You Only Look Once) models, known for their speed and accuracy in object detection.

Key Features:

View Full YOLO Sample

Custom Model Pipeline Sample

For developers with their own trained models or unique architectures, this sample provides a blueprint for constructing a custom object detection pipeline with DirectML.

Key Features:

View Full Custom Sample