VOOZH about

URL: https://www.nuget.org/packages/UAI_ONNX/

⇱ NuGet Gallery | UAI_ONNX 1.0.8.10




UAI_ONNX 1.0.8.10

dotnet add package UAI_ONNX --version 1.0.8.10
 
 
NuGet\Install-Package UAI_ONNX -Version 1.0.8.10
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="UAI_ONNX" Version="1.0.8.10" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="UAI_ONNX" Version="1.0.8.10" />
 
Directory.Packages.props
<PackageReference Include="UAI_ONNX" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add UAI_ONNX --version 1.0.8.10
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: UAI_ONNX, 1.0.8.10"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package UAI_ONNX@1.0.8.10
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=UAI_ONNX&version=1.0.8.10
 
Install as a Cake Addin
#tool nuget:?package=UAI_ONNX&version=1.0.8.10
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

UAI ONNX

ONNX Runner built for C# projects that target .Net8.0 or later. This library is built on top of the ONNX Runtime C# API and provides a simple way to load and run ONNX models in C#. Microsoft.ML.OnnxRuntime.GPU is not installed since that should be handled by the next application that uses this library.

Installation

You can restore the Nuget dependencies by running the following command in the project directory:

dotnet restore

You will need to copy the contents of UAI\thirdParty\openCV to the output directory of your app. This is because the OpenCV dlls are not included in the Nuget package.

Usage

OnnxImageProcessor

The OnnxImageProcessor class is a base class that can be extended to create custom image processing models. The class provides methods to load an ONNX model, preprocess input images, run inference, and post-process the output tensors. The class is designed to be used with image processing models that take an image as input and return an output.

using Microsoft.ML.OnnxRuntime;
using System.Drawing;
using UAI.Common.AI;
namespace UAI.AI.Models.FaceParsing
{
public class FaceParsing : OnnxImageProcessor
{
 public override string[] labels { get { return labels_; } set { labels_ = value; } }

 public string[] labels_ = new string[] { "Background", "Skin", "Nose", "Glasses", "Left Eye", "Right Eye", "Left Brow", "Right Brow", "Left Ear", "Right Ear",
 "Mouth", "Upper Lip", "Lower Lip","Hair" , "Hat", "Earring", "Necklace", "Clothing" };

 public FaceParsing(string modelPath) : base(modelPath)
 {
 

 }

 public override void Start()
	{
		base.Start();

 SetInputName("input","pixel_values");
 SetInputDimensions("pixel_values", new List<int>() { 1, 3, 512, 512 });
 SetOutputName("output","logits");
 SetOutputDimensions("logits", new List<int>() { 1, 18, 512, 512 });
	}

 
	public override async Task RunFrameOnnxInference()
 {

 await base.RunFrameOnnxInference();

 // Setup Ouptuts based on inputImage
 config.onnxMetaData.Inputs[0].dimensions = new List<int>() { 1, 3, inputImageSize.x, inputImageSize.y };
 config.onnxMetaData.Outputs[0].dimensions = new List<int>() { 1, 18, inputImageSize.x, inputImageSize.y };
 var outputPath = FaceParserRuntime.args.outputPath;

 // PreProcess Data
 var inputData = CreateOnnxInput(MatToTensor(Texture2DToMat(inputTexture, inputImageSize)));

 // Process Image
 IDisposableReadOnlyCollection<DisposableNamedOnnxValue> results = _session.Run(inputData, CreateOnnxOutput());
 
 // Process the Output Data
 var rest = GetResultTensors(results);
 List<Bitmap> bitmaps = ConvertTensorsToBitmaps(inputImageSize, rest);


 // Save the Masks and JSON if the options are set
 ProcessSaveMasks(bitmaps, outputPath, FaceParserRuntime.args.saveMasks);
 ProcessJSONOutput(bitmaps, outputPath +"/" + Path.GetFileNameWithoutExtension(FaceParserRuntime.args.inputPath) + "_masks.json", FaceParserRuntime.args.saveJson);

 // Send Inference Finished Signal gets sent when all the this.frames are finished.
 }

 
 public override async Task SendInferenceFinished()
 {
 Console.WriteLine("Inference Finished");
 base.SendInferenceFinished();
 }

 // Called every frame. 'delta' is the elapsed time since the previous frame.
 public override void Update(float delta)
	{
	}
}
}


Product Versions Compatible and additional computed target framework versions.
.NET net8.0 net8.0 is compatible.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.8.10 221 11/14/2024
1.0.8.9 186 11/14/2024
1.0.8.8 187 11/14/2024
1.0.8.7 176 11/14/2024
1.0.8.5 195 11/13/2024
1.0.8.4 189 11/10/2024
1.0.8.3 191 11/10/2024
1.0.8.2 193 11/10/2024
1.0.8.1 201 11/4/2024
1.0.8 199 11/4/2024
1.0.7.5 192 11/3/2024