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
// 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");
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.
Install only what you use.
The SDK is split into focused NuGet packages that build on TensorStack.Common.
| Package | What it does | Version |
|---|---|---|
| TensorStack.Common | Core image, video and audio tensors, base pipeline logic and ONNX session helpers. | 0.14.8 |
| TensorStack.Media | Load, save and stream images, video and audio from disk. | 0.14.8 |
| TensorStack.OnnxRuntime | ONNX model and session management, with DirectML execution. | 0.14.8 |
| TensorStack.OnnxRuntime.Vision | Upscaling, frame interpolation, background removal, pose and feature extraction. | 0.14.8 |
| TensorStack.OnnxRuntime.LLM | Llama, 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.HuggingFace | C# interface to Python Diffusers and Transformers pipelines, with managed backends. | 0.14.8 |
| TensorStack.WPF | WPF controls and theming for building TensorStack desktop apps. | 0.14.8 |
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.
stable-diffusion.cpp
Fetches the official stable-diffusion.cpp build for the GPU: CUDA on NVIDIA, and Vulkan on AMD, Intel and other GPUs.
Hugging Face
Creates and maintains Python environments with the right PyTorch build, then runs Diffusers and Transformers pipelines from C#.
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");
// Text-to-video with MiniMax-H3 (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_32b_minimax_h3-Q4_K_M.gguf",
VaePath = "minimax_h3_video_vae_fp16.safetensors",
AudioVaePath = "minimax_h3_audio_vae_fp32.safetensors",
DiffusionModelPath = "minimax_h3_fl2va_pruned-Q8_0.gguf"
});
var options = pipeline.DefaultVideoOptions with
{
Prompt = "cute cat", Width = 864, Height = 480,
Fps = 24, VideoFrames = 56, Seed = 420
};
var video = await pipeline.GenerateVideoAsync(options);
await video.SaveAsync("OutputVideo.mp4");
// Image editing with Qwen-Image-Edit via Diffusers
using var backend = new HuggingFaceBackend(VendorType.Nvidia);
await backend.InitializeAsync(); // creates the Python environment
var config = new PipelineConfig
{
Path = "Qwen/Qwen-Image-Edit",
Pipeline = "QwenImagePipeline",
ProcessType = ProcessType.ImageEdit,
DataType = DataType.Bfloat16,
MemoryMode = MemoryModeType.OffloadCPU
};
using var pipeline = new PythonPipeline(
config, PipelineProgress.ConsoleCallback);
await pipeline.LoadAsync();
var response = await pipeline.GenerateAsync(new PipelineOptions
{
Prompt = "Yarn art style",
Steps = 30,
GuidanceScale = 4f,
Scheduler = SchedulerType.FlowMatchEulerDiscrete,
ImageInput = new ImageInput("Image.png")
});
await response.AsImageTensor().SaveAsync("Result.png");
// Text-to-speech with Supertonic
var provider = Provider.GetProvider(GraphOptimizationLevel.ORT_ENABLE_ALL);
var pipeline = SupertonicPipeline.Create(@"Models\Supertonic-onnx", provider);
var speech = await pipeline.RunAsync(new SupertonicOptions
{
TextInput = "On a quiet morning in the old town, " +
"a clockmaker named Ellis unlocked his tiny shop",
VoiceStyle = "Female1"
});
AudioManager.SaveAudio("Output.wav", speech);
// Speech-to-text with Whisper
var whisper = WhisperPipeline.Create(
Provider.GetProvider(0), @"Models\Whisper-Base", WhisperType.Base);
var transcript = await whisper.RunAsync(new GenerateOptions
{
Task = TaskType.Transcribe,
Language = LanguageType.EN,
AudioInput = await AudioInput.CreateAsync("Output.wav")
});
Console.WriteLine(transcript.Result);
// Text generation with Llama 3.2 1B
var provider = Provider.GetProvider();
var pipeline = LlamaPipeline.Create(
provider, @"Models\Llama-3.2-1B", PhiType.Mini);
// Greedy decoding
var answer = await pipeline.RunAsync(new GenerateOptions
{
Prompt = "What is an apple?"
});
Console.WriteLine(answer.Result);
// Beam search
var beams = await pipeline.RunAsync(new SearchOptions
{
Prompt = "What is an apple?",
Beams = 3, TopK = 50, TopP = 0.9f, Temperature = 1f,
NoRepeatNgramSize = 3
});
foreach (var beam in beams)
Console.WriteLine(beam.Result);
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.