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

Commit 6387cce

Browse files
committed
Add PipelineType to blueprint, fix incorrect LCM default value
1 parent 7eccd73 commit 6387cce

File tree

6 files changed

+22
-10
lines changed

6 files changed

+22
-10
lines changed

OnnxStack.StableDiffusion/Config/SchedulerOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,6 @@ public class SchedulerOptions
8080
public AlphaTransformType AlphaTransformType { get; set; } = AlphaTransformType.Cosine;
8181
public float MaximumBeta { get; set; } = 0.999f;
8282

83-
public int OriginalInferenceSteps { get; set; } = 30;
83+
public int OriginalInferenceSteps { get; set; } = 50;
8484
}
8585
}

OnnxStack.UI/Models/ImageResult.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class ImageResult
1616
public ModelOptionsModel Model { get; set; }
1717

1818
public DateTime Timestamp { get; } = DateTime.UtcNow;
19+
public DiffuserPipelineType PipelineType { get; set; }
1920
public DiffuserType DiffuserType { get; init; }
2021
public string Prompt { get; init; }
2122
public string NegativePrompt { get; init; }

OnnxStack.UI/Views/ImageInpaint.xaml.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public Task NavigateAsync(ImageResult imageResult)
163163
HasInputResult = true;
164164
HasInputMaskResult = false;
165165
InputImageMask = null;
166-
if (imageResult.Model.ModelOptions.Diffusers.Contains(DiffuserType.ImageInpaint)
166+
if (imageResult.Model.ModelOptions.Diffusers.Contains(DiffuserType.ImageInpaint)
167167
|| imageResult.Model.ModelOptions.Diffusers.Contains(DiffuserType.ImageInpaintLegacy))
168168
{
169169
SelectedModel = imageResult.Model;
@@ -198,8 +198,8 @@ private async Task Generate()
198198
Prompt = PromptOptions.Prompt,
199199
NegativePrompt = PromptOptions.NegativePrompt,
200200
SchedulerType = PromptOptions.SchedulerType,
201-
DiffuserType = SelectedModel.ModelOptions.Diffusers.Contains(DiffuserType.ImageInpaint)
202-
? DiffuserType.ImageInpaint
201+
DiffuserType = SelectedModel.ModelOptions.Diffusers.Contains(DiffuserType.ImageInpaint)
202+
? DiffuserType.ImageInpaint
203203
: DiffuserType.ImageInpaintLegacy,
204204
InputImage = new StableDiffusion.Models.InputImage
205205
{
@@ -213,7 +213,7 @@ private async Task Generate()
213213

214214
var schedulerOptions = SchedulerOptions.ToSchedulerOptions();
215215
schedulerOptions.Strength = 1; // Make sure strength is 1 for Image Inpainting
216-
var resultImage = await ExecuteStableDiffusion( _selectedModel.ModelOptions, promptOptions, schedulerOptions);
216+
var resultImage = await ExecuteStableDiffusion(_selectedModel.ModelOptions, promptOptions, schedulerOptions);
217217
if (resultImage != null)
218218
{
219219
ResultImage = resultImage;
@@ -233,9 +233,9 @@ private async Task Generate()
233233
/// </returns>
234234
private bool CanExecuteGenerate()
235235
{
236-
return !IsGenerating
237-
&& !string.IsNullOrEmpty(PromptOptions.Prompt)
238-
&& HasInputResult
236+
return !IsGenerating
237+
&& !string.IsNullOrEmpty(PromptOptions.Prompt)
238+
&& HasInputResult
239239
&& HasInputMaskResult;
240240
}
241241

@@ -322,6 +322,7 @@ private async Task<ImageResult> ExecuteStableDiffusion(IModelOptions modelOption
322322
Model = _selectedModel,
323323
Prompt = promptOptions.Prompt,
324324
NegativePrompt = promptOptions.NegativePrompt,
325+
PipelineType = _selectedModel.ModelOptions.PipelineType,
325326
DiffuserType = promptOptions.DiffuserType,
326327
SchedulerType = promptOptions.SchedulerType,
327328
SchedulerOptions = schedulerOptions,

OnnxStack.UI/Views/ImageToImage.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ private async Task<ImageResult> ExecuteStableDiffusion(IModelOptions modelOption
295295
Model = _selectedModel,
296296
Prompt = promptOptions.Prompt,
297297
NegativePrompt = promptOptions.NegativePrompt,
298+
PipelineType = _selectedModel.ModelOptions.PipelineType,
298299
DiffuserType = promptOptions.DiffuserType,
299300
SchedulerType = promptOptions.SchedulerType,
300301
SchedulerOptions = schedulerOptions,

OnnxStack.UI/Views/TextToImage.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ private async Task<ImageResult> ExecuteStableDiffusion(IModelOptions modelOption
269269
Model = _selectedModel,
270270
Prompt = promptOptions.Prompt,
271271
NegativePrompt = promptOptions.NegativePrompt,
272+
PipelineType = _selectedModel.ModelOptions.PipelineType,
272273
DiffuserType = promptOptions.DiffuserType,
273274
SchedulerType = promptOptions.SchedulerType,
274275
SchedulerOptions = schedulerOptions,

OnnxStack.UI/WindowLogger.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Microsoft.Extensions.DependencyInjection.Extensions;
33
using Microsoft.Extensions.Logging;
44
using System;
5+
using System.Linq;
56

67
namespace OnnxStack.UI
78
{
@@ -12,6 +13,13 @@ namespace OnnxStack.UI
1213
/// <seealso cref="Microsoft.Extensions.Logging.ILogger" />
1314
public sealed class WindowLogger : ILogger
1415
{
16+
private readonly string _category;
17+
18+
public WindowLogger(string category)
19+
{
20+
_category = category.Split('.').LastOrDefault();
21+
}
22+
1523
/// <summary>
1624
/// Begins a logical operation scope.
1725
/// </summary>
@@ -47,7 +55,7 @@ public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Except
4755
if (!IsEnabled(logLevel))
4856
return;
4957

50-
Utils.LogToWindow($"[{DateTime.Now}] [{logLevel}] - {formatter(state, exception)}\n");
58+
Utils.LogToWindow($"[{DateTime.Now}] [{logLevel}] [{_category}] {formatter(state, exception)}\n");
5159
}
5260

5361

@@ -79,7 +87,7 @@ public sealed class WindowLoggerProvider : ILoggerProvider
7987
/// <returns>
8088
/// The instance of <see cref="T:Microsoft.Extensions.Logging.ILogger" /> that was created.
8189
/// </returns>
82-
public ILogger CreateLogger(string categoryName) => new WindowLogger();
90+
public ILogger CreateLogger(string categoryName) => new WindowLogger(categoryName);
8391

8492
public void Dispose()
8593
{

0 commit comments

Comments
 (0)