microsoft / OnnxRuntime-UnrealEngine

Apply a Style Transfer Neural Network in real time with Unreal Engine 5 leveraging ONNX Runtime.
MIT License
230 stars 41 forks source link
image

This code sample is to show you how to use the new Neural Network Inference (NNI) Plugin in Unreal Engine 5 which implements ONNX Runtime to allow you to add Machine Learning (ML) Models in your projects. ONNX Runtime is a library to optimize and accelerate machine learning inferencing.

image

We are using open source models from the ONNX model zoo to apply a style transform to the scene during game play. Check out the before and after pictures below to see how one of the models is able to stylize the scene.

Before:

image

After:

image

Statement of Purpose

This repository aims to grow the understanding of using ML models through the NNI Plugin in Unreal Engine 5 by providing an example of implementation and references to support the Microsoft Build conference in 2022. It is not intended to be a released product. Therefore, this repository is not for discussing ONNX Runtime, the NNI plugin or requesting new features.

Prerequisites

How to run this project

Options 1: Run with Epic Games Launcher

image image

Option 2: Open and run in Visual Studio.

How to select a different model

There are 5 differnet models included from the ONNX Model Zoo. You can find them under the Content > Models folder in the UE Content Browser. To add your own models, drag and drop them into the Models folder in the Content Browser.

image

To select one of the other preloaded models or one that you added yourself.

image image

Resources

Grab open source models to add to your project:

Connect with ONNX Runtime (ORT) on Social!