diff --git a/OnnxStack.Console/Examples/StableCascadeExample.cs b/OnnxStack.Console/Examples/StableCascadeExample.cs index da5c91e..b22a81c 100644 --- a/OnnxStack.Console/Examples/StableCascadeExample.cs +++ b/OnnxStack.Console/Examples/StableCascadeExample.cs @@ -1,5 +1,6 @@ using OnnxStack.Core.Image; using OnnxStack.StableDiffusion.Config; +using OnnxStack.StableDiffusion.Enums; using OnnxStack.StableDiffusion.Pipelines; using SixLabors.ImageSharp; using System.Diagnostics; @@ -15,6 +16,7 @@ public StableCascadeExample(StableDiffusionConfig configuration) { _configuration = configuration; _outputDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Examples", nameof(StableCascadeExample)); + Directory.CreateDirectory(_outputDirectory); } public int Index => 20; @@ -28,46 +30,25 @@ public StableCascadeExample(StableDiffusionConfig configuration) /// public async Task RunAsync() { - Directory.CreateDirectory(_outputDirectory); - - - var prompt = "photo of a cat"; + // Prompt var promptOptions = new PromptOptions { - Prompt = prompt + 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:\\Repositories\\stable-cascade-onnx", memoryMode: StableDiffusion.Enums.MemoryModeType.Minimum); - - // Preload Models (optional) - await pipeline.LoadAsync(); - - - // Loop through schedulers - var schedulerOptions = pipeline.DefaultSchedulerOptions with - { - SchedulerType = StableDiffusion.Enums.SchedulerType.DDPM, - GuidanceScale =4f, - InferenceSteps = 20, - Width = 1024, - Height = 1024 - }; - - var timestamp = Stopwatch.GetTimestamp(); - + var pipeline = StableCascadePipeline.CreatePipeline("D:\\Models\\stable-cascade-onnx", memoryMode: MemoryModeType.Minimum); // Run pipeline - var result = await pipeline.RunAsync(promptOptions, schedulerOptions, progressCallback: OutputHelpers.ProgressCallback); - - var image = new OnnxImage(result); + var result = await pipeline.GenerateImageAsync(promptOptions, progressCallback: OutputHelpers.ProgressCallback); // Save Image File - await image.SaveAsync(Path.Combine(_outputDirectory, $"output.png")); + await result.SaveAsync(Path.Combine(_outputDirectory, $"output.png")); + // Unload await pipeline.UnloadAsync(); - - } } } diff --git a/OnnxStack.StableDiffusion/Pipelines/StableCascadePipeline.cs b/OnnxStack.StableDiffusion/Pipelines/StableCascadePipeline.cs index 004b90f..c6376e0 100644 --- a/OnnxStack.StableDiffusion/Pipelines/StableCascadePipeline.cs +++ b/OnnxStack.StableDiffusion/Pipelines/StableCascadePipeline.cs @@ -54,6 +54,8 @@ public StableCascadePipeline(PipelineOptions pipelineOptions, TokenizerModel tok Height = 1024, InferenceSteps = 20, GuidanceScale = 4f, + GuidanceScale2 = 0f, + InferenceSteps2 = 10, SchedulerType = SchedulerType.DDPMWuerstchen }; } diff --git a/README.md b/README.md index 96de3e9..f3110f6 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ __________________________ * StableDiffusion 1.5 * StableDiffusion Inpaint * StableDiffusion ControlNet +* Stable-Cascade * SDXL * SDXL Inpaint * SDXL-Turbo