YOLOv4 with DirectML

Leverage the power of DirectML for efficient real-time object detection.

Overview

This sample demonstrates how to use the YOLOv4 (You Only Look Once version 4) object detection model with DirectML on Windows. YOLOv4 is a state-of-the-art real-time object detection system known for its accuracy and speed.

Sample Details

Technology: DirectML, ONNX Runtime, C++

Platform: Windows

Focus: Object Detection, Neural Networks, Hardware Acceleration

Source Code: View on GitHub

Key Features

Getting Started

To get started with this sample, you'll need to clone the DirectML-Samples repository and build the project. Ensure you have the necessary development tools installed, including Visual Studio with C++ development workload and the Windows SDK.

Prerequisites

Build Instructions

1. Clone the DirectML-Samples repository from GitHub:

git clone https://github.com/microsoft/DirectML-Samples.git

2. Navigate to the sample's directory: cd DirectML-Samples/samples/Yolov4ObjectDetection

3. Open the solution file (.sln) in Visual Studio.

4. Build the project in Visual Studio (usually by pressing F7 or selecting "Build Solution" from the Build menu).

5. Ensure the necessary ONNX model files are downloaded or present in the expected directory (refer to the repository's README for details).

Running the Sample

Once the project is built successfully, you can run the executable. The application typically allows you to:

You can also run it from the command line with specific arguments, for example:

.\Yolov4ObjectDetection.exe --model path/to/your/yolov4.onnx --input path/to/your/image.jpg

Model Details

The YOLOv4 model used in this sample is typically trained on a large dataset like MS COCO and can detect a wide variety of common objects, such as persons, cars, chairs, and more. The model's architecture is designed for high throughput and accuracy, making it ideal for real-time applications.

DirectML provides a low-level API for hardware-accelerated machine learning inference on Windows devices. By using DirectML, this sample can leverage the computational power of GPUs for significantly faster inference compared to CPU-only execution.

Further Resources