找回密码
 立即注册
查看: 200|回复: 0

ONNXRuntime for UnrealEngine

[复制链接]
发表于 2023-1-17 14:11 | 显示全部楼层 |阅读模式
在虚幻中使用微软的ONNXRuntime高效(CUDA)的运行RobustVideoMatting(字节跳动的AI扣像模型) GitHub - PeterL1n/RobustVideoMatting: Robust Video Matting in PyTorch, TensorFlow, TensorFlow.js, ONNX, CoreML! https://github.com/microsoft/onnxruntime
未完待续
未经许可禁止转载  
下面的内容是之前开发中记录的零碎,待整理
相关插件

虚幻5自带插件NNI ![[NNI.png]]     ONNXRuntime模块(插件的核心):基于微软ONNXRuntime源代码在虚幻中创建的模块         这种方式需要对原始ONNXRuntime源代码做修改,还要自行处理库的依赖         为什么要这么做呢?
商城中的第三方插件NNEngine ![[NNEngine.png]]     OnnxRuntimeNNEngine模块(插件的核心):基于微软ONNXRuntime预编译的库         ONNXRuntime库的升级非常方便
硬件加速

DirectML 只能用于Dirext12

CreateTensorValueFromExistingD3DResource Texture <===> Tensor 有现成的参考,比较方便
https://github.com/PicaroonX/OnnxRuntimeDirectMLEPSample
CUDA 只能用于Nvidia显卡

1、创建CUDA版本的Input & Output Tensors
ONNXRuntime CUDA Tensors
===========================================
Input Tensor
2、通过ComputerShader将Picture(DX Texture)转换成符合AI模型需要的Input Tensor(DX Resource)
This shader converts a DX texture (BGRA/BGRX/RGBA/GRAY) into NCHW FLOAT Tensor with channel order RGB/BGR/GRAY
https://github.com/microsoft/onnxruntime/blob/main/winml/lib/Api.Image/shaders/SurfaceToTensorFloat.hlsl
3、通过cuMemcpy将DX Resource版的Tensor Data复制到CUDA Input Tensor中
=========================================== Run(Model)
===========================================
处理结果,执行与Input Tensor相反的过程 TensorRT
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-4-30 12:27 , Processed in 0.235117 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表