@@ -73,20 +73,33 @@ internal class AppService : IHostedService
7373 System .Console .WriteLine (" Please type a negative prompt and press ENTER (optional)" );
7474 var negativePrompt = System .Console .ReadLine ();
7575
76- var options = new StableDiffusionOptions
76+ System .Console .WriteLine (" Please enter image filepath for Img2Img and press ENTER (optional)" );
77+ var inputImageFile = System .Console .ReadLine ();
78+
79+ var promptOptions = new PromptOptions
7780 {
7881 Prompt = prompt ,
7982 NegativePrompt = negativePrompt ,
83+ SchedulerType = SchedulerType .LMSScheduler ,
84+ InputImage = inputImageFile
85+ };
86+
87+ var schedulerOptions = new SchedulerOptions
88+ {
8089 Seed = Random .Shared .Next (),
81- SchedulerType = SchedulerType .LMSScheduler
90+ GuidanceScale = 7 . 5 f ,
91+ InferenceSteps = 30 ,
92+ Height = 512 ,
93+ Width = 512 ,
94+ Strength = 0 . 6 f // Img2Img
8295 };
8396
8497 System .Console .WriteLine (" Generating Image..." );
85- var outputFilename = Path .Combine (_outputDirectory , $" {options .Seed }_{options .SchedulerType }.png" );
86- var result = await _stableDiffusionService .TextToImageFile (options , outputFilename );
98+ var outputFilename = Path .Combine (_outputDirectory , $" {schedulerOptions .Seed }_{promptOptions .SchedulerType }.png" );
99+ var result = await _stableDiffusionService .TextToImageFile (promptOptions , schedulerOptions , outputFilename );
87100 if (result is not null )
88101 {
89- System .Console .WriteLine ($" Image Created, FilePath: {outputFilename }" );
102+ System .Console .WriteLine ($" Image Created, FilePath: {outputFilename }" );
90103 }
91104 }
92105 }
0 commit comments