@@ -9,11 +9,13 @@ namespace OnnxStack.Console.Runner
99 public sealed class StableDiffusionGenerator : IExampleRunner
1010 {
1111 private readonly string _outputDirectory ;
12+ private readonly StableDiffusionConfig _configuration ;
1213 private readonly IStableDiffusionService _stableDiffusionService ;
1314 private readonly ReadOnlyDictionary < string , string > _generationPrompts ;
1415
15- public StableDiffusionGenerator ( IStableDiffusionService stableDiffusionService )
16+ public StableDiffusionGenerator ( StableDiffusionConfig configuration , IStableDiffusionService stableDiffusionService )
1617 {
18+ _configuration = configuration ;
1719 _stableDiffusionService = stableDiffusionService ;
1820 _generationPrompts = GeneratePrompts ( ) ;
1921 _outputDirectory = Path . Combine ( Directory . GetCurrentDirectory ( ) , "Examples" , nameof ( StableDiffusionGenerator ) ) ;
@@ -31,7 +33,7 @@ public async Task RunAsync()
3133 Directory . CreateDirectory ( _outputDirectory ) ;
3234
3335 var seed = Random . Shared . Next ( ) ;
34- foreach ( var model in _stableDiffusionService . Models )
36+ foreach ( var model in _configuration . ModelSets )
3537 {
3638 OutputHelpers . WriteConsole ( $ "Loading Model `{ model . Name } `...", ConsoleColor . Green ) ;
3739 await _stableDiffusionService . LoadModelAsync ( model ) ;
@@ -62,7 +64,7 @@ public async Task RunAsync()
6264 OutputHelpers . ReadConsole ( ConsoleColor . Gray ) ;
6365 }
6466
65- private async Task < bool > GenerateImage ( ModelOptions model , PromptOptions prompt , SchedulerOptions options , string key )
67+ private async Task < bool > GenerateImage ( StableDiffusionModelSet model , PromptOptions prompt , SchedulerOptions options , string key )
6668 {
6769 var outputFilename = Path . Combine ( _outputDirectory , $ "{ options . Seed } _{ options . SchedulerType } _{ key } .png") ;
6870 var result = await _stableDiffusionService . GenerateAsImageAsync ( model , prompt , options ) ;
0 commit comments