OnnxStack.StableDiffusion
0.1.0
Prefix Reserved
See the version list below for details.
dotnet add package OnnxStack.StableDiffusion --version 0.1.0
NuGet\Install-Package OnnxStack.StableDiffusion -Version 0.1.0
<PackageReference Include="OnnxStack.StableDiffusion" Version="0.1.0" />
paket add OnnxStack.StableDiffusion --version 0.1.0
#r "nuget: OnnxStack.StableDiffusion, 0.1.0"
// Install OnnxStack.StableDiffusion as a Cake Addin #addin nuget:?package=OnnxStack.StableDiffusion&version=0.1.0 // Install OnnxStack.StableDiffusion as a Cake Tool #tool nuget:?package=OnnxStack.StableDiffusion&version=0.1.0
OnnxStack.StableDiffusion - Onnx Stable Diffusion Services for .NET Applications
OnnxStack.StableDiffusion
is a library that provides higher-level Stable Diffusion services for use in .NET applications. It offers extensive support for features such as dependency injection, .NET configuration implementations, ASP.NET Core integration, and IHostedService support.
Getting Started
.NET Core Registration
You can easily integrate OnnxStack.StableDiffusion
into your application services layer. This registration process sets up the necessary services and loads the appsettings.json
configuration.
Example: Registering OnnxStack.StableDiffusion
builder.Services.AddOnnxStackStableDiffusion();
.NET Console Application Example
Required Nuget Packages
Microsoft.Extensions.Hosting
Microsoft.Extensions.Logging
Microsoft.ML.OnnxRuntime.DirectML
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using OnnxStack.StableDiffusion.Common;
using OnnxStack.StableDiffusion.Config;
internal class Program
{
static async Task Main(string[] _)
{
var builder = Host.CreateApplicationBuilder();
builder.Logging.ClearProviders();
builder.Services.AddLogging((loggingBuilder) => loggingBuilder.SetMinimumLevel(LogLevel.Error));
// Add OnnxStack Stable Diffusion
builder.Services.AddOnnxStackStableDiffusion();
// Add AppService
builder.Services.AddHostedService<AppService>();
// Start
await builder.Build().RunAsync();
}
}
internal class AppService : IHostedService
{
private readonly string _outputDirectory;
private readonly IStableDiffusionService _stableDiffusionService;
public AppService(IStableDiffusionService stableDiffusionService)
{
_stableDiffusionService = stableDiffusionService;
_outputDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Images");
}
public async Task StartAsync(CancellationToken cancellationToken)
{
Directory.CreateDirectory(_outputDirectory);
while (true)
{
System.Console.WriteLine("Please type a prompt and press ENTER");
var prompt = System.Console.ReadLine();
System.Console.WriteLine("Please type a negative prompt and press ENTER (optional)");
var negativePrompt = System.Console.ReadLine();
var options = new StableDiffusionOptions
{
Prompt = prompt,
NegativePrompt = negativePrompt,
Seed = Random.Shared.Next(),
SchedulerType = SchedulerType.LMSScheduler
};
System.Console.WriteLine("Generating Image...");
var outputFilename = Path.Combine(_outputDirectory, $"{options.Seed}_{options.SchedulerType}.png");
var result = await _stableDiffusionService.TextToImageFile(options, outputFilename);
if (result is not null)
{
System.Console.WriteLine($"Image Created, FilePath: {outputFilename}");
}
}
}
public Task StopAsync(CancellationToken cancellationToken)
{
return Task.CompletedTask;
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net7.0
- MathNet.Numerics (>= 5.0.0)
- NumSharp (>= 0.30.0)
- OnnxStack.Core (>= 0.1.0)
- SixLabors.ImageSharp (>= 1.0.3)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on OnnxStack.StableDiffusion:
Package | Downloads |
---|---|
Frank.SemanticKernel.Connectors.OnnxStack.StableDiffusion
Package Description |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on OnnxStack.StableDiffusion:
Repository | Stars |
---|---|
TensorStack-AI/OnnxStack
C# Stable Diffusion using ONNX Runtime
|
Version | Downloads | Last updated | |
---|---|---|---|
0.39.0 | 406 | 6/12/2024 | |
0.31.0 | 236 | 4/25/2024 | |
0.27.0 | 177 | 3/31/2024 | |
0.25.0 | 156 | 3/14/2024 | |
0.23.1 | 140 | 3/1/2024 | |
0.23.0 | 124 | 2/29/2024 | |
0.22.0 | 140 | 2/23/2024 | |
0.21.0 | 133 | 2/15/2024 | |
0.19.0 | 140 | 2/1/2024 | |
0.17.0 | 178 | 1/19/2024 | |
0.16.0 | 143 | 1/11/2024 | |
0.15.0 | 209 | 1/5/2024 | |
0.14.0 | 178 | 12/27/2023 | |
0.13.0 | 119 | 12/22/2023 | |
0.12.0 | 149 | 12/15/2023 | |
0.10.0 | 184 | 11/30/2023 | |
0.9.0 | 159 | 11/23/2023 | |
0.8.0 | 221 | 11/16/2023 | |
0.7.0 | 161 | 11/9/2023 | |
0.6.0 | 137 | 11/2/2023 | |
0.5.0 | 167 | 10/27/2023 | |
0.4.0 | 166 | 10/19/2023 | |
0.3.1 | 161 | 10/9/2023 | |
0.3.0 | 152 | 10/9/2023 | |
0.2.0 | 163 | 10/3/2023 | |
0.1.0 | 165 | 9/25/2023 |