-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #134 from saddam213/StableCascade
StableCascade Pipeline
- Loading branch information
Showing
25 changed files
with
1,392 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using OnnxStack.Core.Image; | ||
using OnnxStack.StableDiffusion.Config; | ||
using OnnxStack.StableDiffusion.Enums; | ||
using OnnxStack.StableDiffusion.Pipelines; | ||
using SixLabors.ImageSharp; | ||
using System.Diagnostics; | ||
|
||
namespace OnnxStack.Console.Runner | ||
{ | ||
public sealed class StableCascadeExample : IExampleRunner | ||
{ | ||
private readonly string _outputDirectory; | ||
private readonly StableDiffusionConfig _configuration; | ||
|
||
public StableCascadeExample(StableDiffusionConfig configuration) | ||
{ | ||
_configuration = configuration; | ||
_outputDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Examples", nameof(StableCascadeExample)); | ||
Directory.CreateDirectory(_outputDirectory); | ||
} | ||
|
||
public int Index => 20; | ||
|
||
public string Name => "Stable Cascade Demo"; | ||
|
||
public string Description => "Creates images from the text prompt provided"; | ||
|
||
/// <summary> | ||
/// Stable Diffusion Demo | ||
/// </summary> | ||
public async Task RunAsync() | ||
{ | ||
// Prompt | ||
var promptOptions = new PromptOptions | ||
{ | ||
Prompt = "an image of a cat, donning a spacesuit and helmet", | ||
DiffuserType = DiffuserType.TextToImage, | ||
//InputImage = await OnnxImage.FromFileAsync("Input.png"), | ||
}; | ||
|
||
// Create Pipeline | ||
var pipeline = StableCascadePipeline.CreatePipeline("D:\\Models\\stable-cascade-onnx", memoryMode: MemoryModeType.Minimum); | ||
|
||
// Run pipeline | ||
var result = await pipeline.GenerateImageAsync(promptOptions, progressCallback: OutputHelpers.ProgressCallback); | ||
|
||
// Save Image File | ||
await result.SaveAsync(Path.Combine(_outputDirectory, $"output.png")); | ||
|
||
// Unload | ||
await pipeline.UnloadAsync(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.