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

Commit fd795df

Browse files
committed
fixed batch example
1 parent 221e970 commit fd795df

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

OnnxStack.Console/Examples/StableDiffusionBatch.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
namespace OnnxStack.Console.Runner
1010
{
11+
using StableDiffusion;
12+
1113
public sealed class StableDiffusionBatch : IExampleRunner
1214
{
1315
private readonly string _outputDirectory;
@@ -56,6 +58,8 @@ public async Task RunAsync()
5658

5759
foreach (var model in _configuration.ModelSets)
5860
{
61+
_setSchedulerTypeForPipeline();
62+
5963
OutputHelpers.WriteConsole($"Loading Model `{model.Name}`...", ConsoleColor.Green);
6064
await _stableDiffusionService.LoadModelAsync(model);
6165

@@ -76,6 +80,13 @@ public async Task RunAsync()
7680

7781
OutputHelpers.WriteConsole($"Unloading Model `{model.Name}`...", ConsoleColor.Green);
7882
await _stableDiffusionService.UnloadModelAsync(model);
83+
continue;
84+
85+
void _setSchedulerTypeForPipeline()
86+
{
87+
SchedulerType[] scheduleTypes = model.PipelineType.GetSchedulerTypes();
88+
schedulerOptions.SchedulerType = scheduleTypes.Length == 1 ? scheduleTypes[0] : scheduleTypes[Random.Shared.Next(scheduleTypes.Length)];
89+
}
7990
}
8091
}
8192
}

0 commit comments

Comments
 (0)