TensorStack
v0.14.8 .NET Apache-2.0

Generative AI for .NET developers.

TensorStack is a modular SDK for building AI-powered applications on Windows: local inference, text, image, video and audio generation, media processing and hardware acceleration, through one consistent C# API.

dotnet add package TensorStack.Common
QuickStart.cs
// 1. Create an upscale pipeline
var pipeline = UpscalePipeline.Create(new UpscalerConfig
{
    ScaleFactor = 4,
    Normalization = Normalization.ZeroToOne,
    ExecutionProvider = Provider.GetProvider(),
    Path = @"Models\RealESR-General-4x.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 frame by frame
var inputStream = await VideoInputStream.CreateAsync("Input.mp4");
var upscaledVideo = pipeline.RunAsync(
    new UpscaleStreamOptions { Stream = inputStream.GetAsync() });
await upscaledVideo.SaveAsync("Output.mp4");

// 4. Copy the source audio track (optional)
await AudioManager.AddAudioAsync("Output.mp4", "Input.mp4");
Features

Everything an AI app needs, in C#.

Reusable components for inference, generation, media and UI — the same ones used to build Amuse.

Native .NET SDK

Typed, async pipelines with clean options records, distributed as NuGet packages.

Local inference

Run models on the user's own hardware, with no cloud service in the loop.

Text generation & LLMs

Llama and Phi-3 pipelines with greedy and beam search decoding.

Image & video generation

Diffusion through stable-diffusion.cpp and Hugging Face Diffusers.

Upscaling & extraction

Upscaling, frame interpolation, background removal, pose and feature extraction.

Image, video & audio

Load, save and stream media as tensors, with FFmpeg-backed video and audio.

Hardware acceleration

DirectML, CUDA and Vulkan, chosen to match the GPU vendor.

Python interoperability

Drive Diffusers and Transformers from C# via CSnakes, with managed environments.

Extensible providers

A provider architecture that lets you add backends and execution providers.

Packages

Install only what you use.

The SDK is split into focused NuGet packages that build on TensorStack.Common.

PackageWhat it doesVersion
TensorStack.CommonCore image, video and audio tensors, base pipeline logic and ONNX session helpers.0.14.8
TensorStack.MediaLoad, save and stream images, video and audio from disk.0.14.8
TensorStack.OnnxRuntimeONNX model and session management, with DirectML execution.0.14.8
TensorStack.OnnxRuntime.VisionUpscaling, frame interpolation, background removal, pose and feature extraction.0.14.8
TensorStack.OnnxRuntime.LLMLlama, Phi-3, Whisper speech recognition and Supertonic text-to-speech.0.14.8
TensorStack.StableDiffusionCpp.NET wrapper for stable-diffusion.cpp — GGUF image and video generation, plus upscaling.0.14.8
TensorStack.HuggingFaceC# interface to Python Diffusers and Transformers pipelines, with managed backends.0.14.8
TensorStack.WPFWPF controls and theming for building TensorStack desktop apps.0.14.8
Backends

Three engines. Matched to the GPU.

Backends set themselves up for the user's hardware, so your app doesn't have to.

ONNX Runtime

Optimized ONNX models for upscaling, vision, speech and LLMs, accelerated by DirectML on DirectX 12 GPUs or run on the CPU.

DirectMLCPU

stable-diffusion.cpp

Fetches the official stable-diffusion.cpp build for the GPU: CUDA on NVIDIA, and Vulkan on AMD, Intel and other GPUs.

CUDAVulkan

Hugging Face

Creates and maintains Python environments with the right PyTorch build, then runs Diffusers and Transformers pipelines from C#.

CUDACPU
Examples

A few lines per modality.

Every pipeline follows the same shape: create it, pass an options record, await the result.

  • Image & video — GGUF diffusion models through stable-diffusion.cpp
  • Diffusers — any supported Hugging Face pipeline, driven from C#
  • Speech — Whisper transcription and Supertonic voices
  • Language — Llama and Phi-3 with greedy or beam search
// Text-to-image with Krea2 Turbo (GGUF)
using var backend = new StableDiffusionBackend(VendorType.Nvidia);
await backend.InitializeAsync();

using var pipeline = new StableDiffusionPipeline(backend);
var device = pipeline.Devices
    .FirstOrDefault(x => x.Type == DeviceType.GPU);

await pipeline.LoadAsync(new StableDiffusionOptions
{
    Backend = device.Backend,
    LlmPath = "Qwen3VL-4B-Instruct-Q8_0.gguf",
    VaePath = "diffusion_pytorch_model.safetensors",
    DiffusionModelPath = "Krea-2-Turbo-Q8_0.gguf"
});

var options = pipeline.DefaultImageOptions with
{
    Prompt = "cute cat", Width = 1024, Height = 1024, Seed = 420
};
var image = await pipeline.GenerateImageAsync(options);
await image.SaveAsync("OutputImage.png");
Built on

Standing on excellent open source.

TensorStack builds on these projects. Thank you to everyone who maintains them.

Build the next Amuse.

Everything that powers Amuse is available to your own apps — open source, on NuGet.