Skip to content
This repository was archived by the owner on Nov 27, 2024. It is now read-only.

chore: Examples add schedulerOptions.Width and Height ; Fix Batchinde… #106

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion OnnxStack.Console/Examples/StableDiffusionBatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,17 @@ public async Task RunAsync()
OutputHelpers.WriteConsole($"Loading Model `{model.Name}`...", ConsoleColor.Green);
await _stableDiffusionService.LoadModelAsync(model);

schedulerOptions.Width = model.SampleSize;
schedulerOptions.Height = model.SampleSize;

var batchIndex = 0;
var callback = (DiffusionProgress progress) =>
{
batchIndex = progress.BatchValue;
OutputHelpers.WriteConsole($"Image: {progress.BatchValue}/{progress.BatchMax} - Step: {progress.StepValue}/{progress.StepMax}", ConsoleColor.Cyan);
};

await foreach (var result in _stableDiffusionService.GenerateBatchAsync(new ModelOptions(model), promptOptions, schedulerOptions, batchOptions, default))
await foreach (var result in _stableDiffusionService.GenerateBatchAsync(new ModelOptions(model), promptOptions, schedulerOptions, batchOptions, callback))
{
var outputFilename = Path.Combine(_outputDirectory, $"{batchIndex}_{result.SchedulerOptions.Seed}.png");
var image = result.ImageResult.ToImage();
Expand Down
3 changes: 3 additions & 0 deletions OnnxStack.Console/Examples/StableDiffusionExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public async Task RunAsync()
OutputHelpers.WriteConsole($"Loading Model `{model.Name}`...", ConsoleColor.Green);
await _stableDiffusionService.LoadModelAsync(model);

schedulerOptions.Width = model.SampleSize;
schedulerOptions.Height = model.SampleSize;

foreach (var schedulerType in model.PipelineType.GetSchedulerTypes())
{
schedulerOptions.SchedulerType = schedulerType;
Expand Down