TensorStack.HuggingFace
0.15.0
Prefix Reserved
dotnet add package TensorStack.HuggingFace --version 0.15.0
NuGet\Install-Package TensorStack.HuggingFace -Version 0.15.0
<PackageReference Include="TensorStack.HuggingFace" Version="0.15.0" />
<PackageVersion Include="TensorStack.HuggingFace" Version="0.15.0" />
<PackageReference Include="TensorStack.HuggingFace" />
paket add TensorStack.HuggingFace --version 0.15.0
#r "nuget: TensorStack.HuggingFace, 0.15.0"
#:package TensorStack.HuggingFace@0.15.0
#addin nuget:?package=TensorStack.HuggingFace&version=0.15.0
#tool nuget:?package=TensorStack.HuggingFace&version=0.15.0
TensorStack.HuggingFace
Basic .NET Wrapper API for HuggingFace Diffusers & Transformers
Nuget Package
Image Example
Edit an image using Qwen-Image-Edit
using (var backend = new HuggingFaceBackend(VendorType.Nvidia))
{
await backend.InitializeAsync();
// Pipeline Config
var pipelineConfig = new PipelineConfig
{
Pipeline = "QwenImagePipeline",
Template = "QwenImage_Edit",
ProcessType = ProcessType.ImageEdit,
DataType = DataType.Bfloat16,
MemoryMode = MemoryModeType.OffloadCPU,
CheckpointConfig = new CheckpointConfig
{
Transformer = "models/Qwen-Image-Edit-2511/transformer",
TextEncoder = "models/Qwen2.5-VL-7B/text_encoder",
Vae = "models/Qwen-Image/vae"
}
};
using (var pipeline = new HuggingFacePipeline(pipelineConfig, PipelineProgress.ConsoleCallback))
{
// Load Model
await pipeline.LoadAsync();
// Generate
var results = await pipeline.GenerateImageAsync(new GenerateImageOptions
{
Prompt = "Yarn art style",
Steps = 30,
Width = 1024,
Height = 1024,
GuidanceScale = 4f,
SchedulerOptions = new FlowMatchEulerOptions(),
InputImages = [new ImageInput("Image.png")]
});
// Save Image
await results[0].SaveAsync("Result.png");
}
}
Pipelines
Pipeline names a Python pipeline module in Native/Pipelines (e.g. FluxPipeline, WanPipeline, LTX20Pipeline, AceStepPipeline, AutoTextPipeline), and Template names a folder in Native/Pipelines/Templates holding the model's config files. CheckpointConfig gives the path of each model component.
| Method | Returns | Process Types |
|---|---|---|
GenerateImageAsync |
ImageTensor[] |
TextToImage, ImageToImage, ImageEdit, ImageInpaint, ImageControlNet |
GenerateVideoAsync |
Tensor<float>[] |
TextToVideo, ImageToVideo, VideoToVideo |
GenerateAudioAsync |
AudioTensor[] |
TextToAudio |
GenerateTextAsync |
TextInput[] |
TextToText, ImageToText |
ReloadAsync changes the process type, LoRA adapters or ControlNet without reloading the model.
HuggingFace Backends
The HuggingFaceBackend class to manage HuggingFace backend environments. You can initialize a backend using built-in vendor configurations or provide a custom configuration to control its version, installation directory, and requirements.
Basic Documentation
// Create a backend using built-in vendor defaults.
var backend = new HuggingFaceBackend(VendorType.Nvidia);
// Initialize the environment.
// Attempts to load an existing environment, update it if loading
// fails, or create a new environment if necessary.
bool initialized = await backend.InitializeAsync();
// Load the environment directly.
bool loaded = await backend.LoadAsync();
// Perform a specific setup operation.
bool updated = await backend.SetupAsync(BackendStatus.Update);
// Delete the backend environment.
bool deleted = await backend.DeleteAsync();
// Check whether the backend environment exists.
bool exists = backend.Exists();
// ============================================================
// Backend Setup Operations
// ============================================================
// Create - Create a new environment.
// Load - Load operation status.
// Update - Update an existing environment.
// Rebuild - Rebuild the environment.
// Reinstall - Reinstall the environment.
bool success = await backend.SetupAsync(BackendStatus.Create);
// ============================================================
// Custom Configuration
// ============================================================
// Name - Backend name
// Version - Python version (Supported: 3.12, 3.13, 3.14)
// Directory - Backend directory
// Requirements - List of python package requirements.
// Define a custom backend configuration.
var customConfiguration = new BackendConfig
{
Name = "cuda",
Version = "3.12",
Directory = "HuggingFace",
Requirements =
[
"your custom python requirements",
// Include Default Requirements
.. HuggingFaceBackend.DefaultRequirements
]
};
// Create a backend using the custom configuration.
var customBackend = new HuggingFaceBackend(customConfiguration);
// ============================================================
// Built-in Configuration Customization
// ============================================================
// Retrieve a built-in vendor configuration.
BackendConfig configuration = HuggingFaceBackend.GetConfig(VendorType.Nvidia);
// Create a modified copy of the configuration.
// BackendConfig is a record, so the original remains unchanged.
var modifiedConfiguration = configuration with
{
Name = "cuda-test",
Version = "3.14",
Directory = "My Location"
};
// Create a backend using the modified configuration.
var modifiedBackend = new HuggingFaceBackend(modifiedConfiguration);
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-windows10.0.17763 is compatible. |
-
net10.0-windows10.0.17763
- Microsoft.Extensions.Logging (>= 11.0.0)
- TensorStack.Common (>= 0.15.0)
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 | 77 | 11/18/2026 |
| 0.14.14 | 86 | 11/17/2026 |
| 0.14.13 | 94 | 11/16/2026 |
| 0.14.12 | 92 | 11/15/2026 |
| 0.14.11 | 90 | 11/15/2026 |
| 0.14.10 | 93 | 11/14/2026 |
| 0.14.9 | 93 | 11/13/2026 |
| 0.14.8 | 90 | 11/10/2026 |
| 0.14.7 | 95 | 11/8/2026 |
| 0.14.6 | 101 | 11/5/2026 |
| 0.14.5 | 117 | 11/1/2026 |
| 0.14.4 | 168 | 10/29/2026 |
| 0.14.3 | 105 | 10/28/2026 |
| 0.14.2 | 138 | 10/20/2026 |
| 0.14.1 | 121 | 10/16/2026 |
| 0.13.13 | 104 | 10/11/2026 |
| 0.13.12 | 104 | 10/10/2026 |
| 0.13.10 | 128 | 10/6/2026 |
| 0.13.9 | 97 | 10/5/2026 |
| 0.13.8 | 111 | 10/4/2026 |