TensorStack.OnnxRuntime.Vision 0.15.0

Prefix Reserved
dotnet add package TensorStack.OnnxRuntime.Vision --version 0.15.0
                    
NuGet\Install-Package TensorStack.OnnxRuntime.Vision -Version 0.15.0
                    
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="TensorStack.OnnxRuntime.Vision" Version="0.15.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TensorStack.OnnxRuntime.Vision" Version="0.15.0" />
                    
Directory.Packages.props
<PackageReference Include="TensorStack.OnnxRuntime.Vision" />
                    
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 TensorStack.OnnxRuntime.Vision --version 0.15.0
                    
#r "nuget: TensorStack.OnnxRuntime.Vision, 0.15.0"
                    
#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 TensorStack.OnnxRuntime.Vision@0.15.0
                    
#: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=TensorStack.OnnxRuntime.Vision&version=0.15.0
                    
Install as a Cake Addin
#tool nuget:?package=TensorStack.OnnxRuntime.Vision&version=0.15.0
                    
Install as a Cake Tool

TensorStack.OnnxRuntime.Vision

ONNX image and video pipelines for upscaling, frame interpolation, feature extraction (depth, edges etc), background removal and pose detection.

Nuget Package

OnnxRuntime Vision Badge

Every pipeline takes an image, a buffered video (VideoSequence) or a video stream (IAsyncEnumerable<VideoFrame>), so long videos can be processed frame by frame with minimal memory use.

Loading and saving media uses TensorStack.Media.


Quick Start

Upscale an image and a video using RealESR-General-4x

// 1. Create the Upscale Pipeline
using (var pipeline = UpscalePipeline.Create(new UpscalerConfig
{
    ScaleFactor = 4,
    Normalization = Normalization.ZeroToOne,
    ExecutionProvider = Provider.GetProvider(),
    Path = @"M:\Models\RealESR-General-4x\model.onnx"
}))
{
    // 2. Upscale an Image
    var inputImage = new ImageInput("Input.png");
    var upscaledImage = await pipeline.RunAsync(new UpscaleImageOptions
    {
        Image = inputImage
    });
    await upscaledImage.SaveAsync("Output.png");

    // 3. Upscale a Video (Streaming mode)
    var inputStream = await VideoInputStream.CreateAsync("Input.mp4");
    var upscaledVideo = pipeline.RunAsync(new UpscaleStreamOptions
    {
        Stream = inputStream.GetAsync()
    });
    await upscaledVideo.SaveAsync("Output.mp4");

    // 4. Add audio from the source video (optional)
    await AudioManager.AddAudioAsync("Output.mp4", "Input.mp4");
}

Upscale

UpscalerConfig

  • Path - Path to the ONNX model
  • ExecutionProvider - Hardware provider, see TensorStack.OnnxRuntime
  • ScaleFactor - Upscale factor (e.g. 2x, 4x)
  • Normalization / OutputNormalization - Input and output value range (ZeroToOne or OneToOne)
  • Channels - Model channels (default 3)
  • SampleSize - Fixed model input size, 0 for dynamic

Upscale Image

var output = await pipeline.RunAsync(new UpscaleImageOptions
{
    Image = new ImageInput("Input.png")
});
await output.SaveAsync("Output.png");

Upscale Video (Buffered)

Buffers all frames in memory. Suitable for short videos, AI-generated content, low-resolution videos or GIFs.

var outputVideo = await pipeline.RunAsync(new UpscaleVideoOptions
{
    Video = new VideoInput("Input.gif")
});
await outputVideo.SaveAsync("Output.mp4");

Upscale Video (Stream)

Processes frames one by one for minimal memory usage. Ideal for high-resolution or long videos.

var inputStream = await VideoInputStream.CreateAsync("Input.mp4");
var outputStream = pipeline.RunAsync(new UpscaleStreamOptions
{
    Stream = inputStream.GetAsync()
});
await outputStream.SaveAsync("Output.mp4");

Tiling

Tiling processes images and frames in smaller sections instead of all at once, reducing memory use on large images and high-resolution video.

  • IsTileEnabled - Enable tiling
  • MaxTileSize - The maximum size of each tile in pixels, smaller tiles use less memory but may take longer
  • TileOverlap - The number of overlapping pixels between tiles, more overlap prevents visible seams
var output = await pipeline.RunAsync(new UpscaleImageOptions
{
    Image = inputImage,
    IsTileEnabled = true,
    MaxTileSize = 512,
    TileOverlap = 16
});

Upscale Models

Some known and tested models:


Interpolation

Increases the frame rate of a video by generating frames in between.

using (var pipeline = InterpolationPipeline.Create(Provider.GetProvider()))
{
    var inputVideo = new VideoInput("Input.mp4");
    var outputVideo = await pipeline.RunAsync(new InterpolationVideoOptions
    {
        Multiplier = 3,
        Video = inputVideo
    });
    await outputVideo.SaveAsync("Output.mp4");
}

InterpolationPipeline.Create(provider) loads Interpolation.onnx from the working directory, use InterpolationPipeline.Create(ModelConfig) for another path.


Extraction

ExtractorPipeline runs image-to-image feature models such as depth, edge or line art detection, commonly used as ControlNet inputs.

using (var pipeline = ExtractorPipeline.Create(new ExtractorConfig
{
    Normalization = Normalization.ZeroToOne,
    OutputNormalization = Normalization.OneToOne,
    OutputChannels = 1,
    ExecutionProvider = Provider.GetProvider(),
    Path = @"M:\Models\Depth\model.onnx"
}))
{
    var output = await pipeline.RunAsync(new ExtractorImageOptions
    {
        Image = new ImageInput("Input.png")
    });
    await output.SaveAsync("Depth.png");
}

ExtractorVideoOptions and ExtractorStreamOptions process video the same way as upscaling. Other options: IsInverted, MergeInput and tiling.


Background Removal

BackgroundPipeline uses a segmentation model to remove or isolate the background of an image.

using (var pipeline = BackgroundPipeline.Create(new ExtractorConfig
{
    ExecutionProvider = Provider.GetProvider(),
    Path = @"M:\Models\Background\model.onnx"
}))
{
    var output = await pipeline.RunAsync(new BackgroundImageOptions
    {
        Mode = BackgroundMode.RemoveBackground,
        Image = new ImageInput("Input.png")
    });
    await output.SaveAsync("Output.png");
}

Pose Detection

PosePipeline detects body poses and renders them as a pose skeleton image.

using (var pipeline = PosePipeline.Create(new ExtractorConfig
{
    ExecutionProvider = Provider.GetProvider(),
    Path = @"M:\Models\Pose\model.onnx"
}))
{
    var output = await pipeline.RunAsync(new PoseImageOptions
    {
        Image = new ImageInput("Input.png"),
        BodyConfidence = 0.4f,
        JointConfidence = 0.1f
    });
    await output.SaveAsync("Pose.png");
}

PoseVideoOptions and PoseStreamOptions process video.


Combining Pipelines

Pipelines can be chained using IAsyncEnumerable streams, so a workflow such as upscaling and frame interpolation runs in a single pass without storing intermediate results in memory.

In this example the video is upscaled by 4x and its frame rate is increased by 3x:

var provider = Provider.GetProvider();
var upscaleConfig = new UpscalerConfig
{
    ScaleFactor = 4,
    ExecutionProvider = provider,
    Normalization = Normalization.ZeroToOne,
    Path = @"M:\Models\RealESR-General-4x\model.onnx"
};

using (var upscalePipeline = UpscalePipeline.Create(upscaleConfig))
using (var interpolationPipeline = InterpolationPipeline.Create(provider))
{
    // Read Stream [512 x 512 @ 8fps]
    var videoInput = await VideoInputStream.CreateAsync("Input.mp4");
    var videoStream = videoInput.GetAsync();

    // Upscale Stream
    videoStream = upscalePipeline.RunAsync(new UpscaleStreamOptions
    {
        Stream = videoStream
    });

    // Interpolate Stream
    videoStream = interpolationPipeline.RunAsync(new InterpolationStreamOptions
    {
        Multiplier = 3,
        Stream = videoStream,
        FrameRate = videoInput.FrameRate,
        FrameCount = videoInput.FrameCount
    });

    // Save Stream [2048 x 2048 @ 24fps]
    await videoStream.SaveAsync("Output.mp4");
}
Product Compatible and additional computed target framework versions.
.NET net10.0-windows10.0.17763 is compatible. 
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
0.15.0 70 11/18/2026
0.14.14 73 11/17/2026
0.14.13 83 11/16/2026
0.14.12 81 11/15/2026
0.14.11 80 11/15/2026
0.14.10 99 11/14/2026
0.14.9 92 11/13/2026
0.14.8 95 11/10/2026
0.14.7 95 11/8/2026
0.14.6 92 11/5/2026
0.14.5 121 11/1/2026
0.14.4 179 10/29/2026
0.14.3 106 10/28/2026
0.14.2 136 10/20/2026
0.14.1 119 10/16/2026
0.13.13 113 10/11/2026
0.13.12 104 10/10/2026
0.13.10 119 10/6/2026
0.13.9 102 10/5/2026
0.13.8 112 10/4/2026
Loading failed