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

Commit 73d7d00

Browse files
committed
Update Console and WebUI
1 parent 8fd0c79 commit 73d7d00

File tree

4 files changed

+19
-40
lines changed

4 files changed

+19
-40
lines changed

OnnxStack.Console/Examples/StableDebug.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using OnnxStack.StableDiffusion.Common;
22
using OnnxStack.StableDiffusion.Config;
33
using OnnxStack.StableDiffusion.Enums;
4+
using OnnxStack.StableDiffusion.Services;
45
using SixLabors.ImageSharp;
56
using System.Diagnostics;
67

@@ -32,6 +33,8 @@ public async Task RunAsync()
3233
var negativePrompt = "painting, drawing, sketches, monochrome, grayscale, illustration, anime, cartoon, graphic, text, crayon, graphite, abstract, easynegative, low quality, normal quality, worst quality, lowres, close up, cropped, out of frame, jpeg artifacts, duplicate, morbid, mutilated, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, glitch, deformed, mutated, cross-eyed, ugly, dehydrated, bad anatomy, bad proportions, gross proportions, cloned face, disfigured, malformed limbs, missing arms, missing legs fused fingers, too many fingers,extra fingers, extra limbs,, extra arms, extra legs,disfigured,";
3334
while (true)
3435
{
36+
var model = _stableDiffusionService.Models.First();
37+
3538
var promptOptions = new PromptOptions
3639
{
3740
Prompt = prompt,
@@ -52,23 +55,16 @@ public async Task RunAsync()
5255
{
5356
promptOptions.SchedulerType = schedulerType;
5457
OutputHelpers.WriteConsole("Generating Image...", ConsoleColor.Green);
55-
await GenerateImage(promptOptions, schedulerOptions);
58+
await GenerateImage(model, promptOptions, schedulerOptions);
5659
}
5760
}
5861
}
5962

6063

61-
private async Task<bool> GenerateImage(PromptOptions prompt, SchedulerOptions options)
64+
private async Task<bool> GenerateImage(ModelOptions model, PromptOptions prompt, SchedulerOptions options)
6265
{
6366
var timestamp = Stopwatch.GetTimestamp();
6467
var outputFilename = Path.Combine(_outputDirectory, $"{options.Seed}_{prompt.SchedulerType}.png");
65-
66-
//TODO:
67-
var model = new ModelOptions
68-
{
69-
70-
};
71-
7268
var result = await _stableDiffusionService.GenerateAsImageAsync(model, prompt, options);
7369
if (result is not null)
7470
{

OnnxStack.Console/Examples/StableDiffusionExample.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public async Task RunAsync()
3030

3131
while (true)
3232
{
33+
var model = _stableDiffusionService.Models.First();
34+
3335
OutputHelpers.WriteConsole("Please type a prompt and press ENTER", ConsoleColor.Yellow);
3436
var prompt = OutputHelpers.ReadConsole(ConsoleColor.Cyan);
3537

@@ -52,20 +54,14 @@ public async Task RunAsync()
5254
promptOptions.SchedulerType = schedulerType;
5355

5456
OutputHelpers.WriteConsole("Generating Image...", ConsoleColor.Green);
55-
await GenerateImage(promptOptions, schedulerOptions);
57+
await GenerateImage(model, promptOptions, schedulerOptions);
5658
}
5759
}
5860
}
5961

60-
private async Task<bool> GenerateImage(PromptOptions prompt, SchedulerOptions options)
62+
private async Task<bool> GenerateImage(ModelOptions model, PromptOptions prompt, SchedulerOptions options)
6163
{
6264
var outputFilename = Path.Combine(_outputDirectory, $"{options.Seed}_{prompt.SchedulerType}.png");
63-
//TODO:
64-
var model = new ModelOptions
65-
{
66-
67-
};
68-
6965
var result = await _stableDiffusionService.GenerateAsImageAsync(model, prompt, options);
7066
if (result == null)
7167
return false;

OnnxStack.Console/Examples/StableDiffusionGenerator.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public async Task RunAsync()
3131
{
3232
Directory.CreateDirectory(_outputDirectory);
3333

34+
var model = _stableDiffusionService.Models.First();
35+
3436
var seed = Random.Shared.Next();
3537
foreach (var generationPrompt in _generationPrompts)
3638
{
@@ -48,21 +50,15 @@ public async Task RunAsync()
4850
promptOptions.SchedulerType = schedulerType;
4951

5052
OutputHelpers.WriteConsole("Generating Image...", ConsoleColor.Green);
51-
await GenerateImage(promptOptions, schedulerOptions, generationPrompt.Key);
53+
await GenerateImage(model, promptOptions, schedulerOptions, generationPrompt.Key);
5254
}
5355
}
5456
OutputHelpers.WriteConsole("Complete :)", ConsoleColor.DarkMagenta);
5557
OutputHelpers.ReadConsole(ConsoleColor.Gray);
5658
}
5759

58-
private async Task<bool> GenerateImage(PromptOptions prompt, SchedulerOptions options, string key)
60+
private async Task<bool> GenerateImage(ModelOptions model, PromptOptions prompt, SchedulerOptions options, string key)
5961
{
60-
//TODO:
61-
var model = new ModelOptions
62-
{
63-
64-
};
65-
6662
var outputFilename = Path.Combine(_outputDirectory, $"{options.Seed}_{prompt.SchedulerType}_{key}.png");
6763
var result = await _stableDiffusionService.GenerateAsImageAsync(model, prompt, options);
6864
if (result == null)

OnnxStack.WebUI/Hubs/StableDiffusionHub.cs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,8 @@ private async Task<StableDiffusionResult> GenerateTextToImageResult(PromptOption
143143
if (bluprintFile is null)
144144
return new StableDiffusionResult("Failed to save blueprint");
145145

146-
//TODO:
147-
var model = new ModelOptions
148-
{
149-
150-
};
146+
//TODO: Model Selector
147+
var model = _stableDiffusionService.Models.First();
151148

152149
//3. Run stable diffusion
153150
if (!await RunStableDiffusion(model, promptOptions, schedulerOptions, outputImageFile, cancellationToken))
@@ -192,11 +189,8 @@ private async Task<StableDiffusionResult> GenerateImageToImageResult(PromptOptio
192189
if (bluprintFile is null)
193190
return new StableDiffusionResult("Failed to save blueprint");
194191

195-
//TODO:
196-
var model = new ModelOptions
197-
{
198-
199-
};
192+
//TODO: Model Selector
193+
var model = _stableDiffusionService.Models.First();
200194

201195
//4. Run stable diffusion
202196
if (!await RunStableDiffusion(model, promptOptions, schedulerOptions, outputImageFile, cancellationToken))
@@ -248,11 +242,8 @@ private async Task<StableDiffusionResult> GenerateImageInpaintResult(PromptOptio
248242
if (bluprintFile is null)
249243
return new StableDiffusionResult("Failed to save blueprint");
250244

251-
//TODO:
252-
var model = new ModelOptions
253-
{
254-
255-
};
245+
//TODO: Model Selector
246+
var model = _stableDiffusionService.Models.First();
256247

257248
// 5. Run stable diffusion
258249
if (!await RunStableDiffusion(model, promptOptions, schedulerOptions, outputImageFile, cancellationToken))

0 commit comments

Comments
 (0)