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

Commit 2eef655

Browse files
committed
Remove legacy InitialNoiseLevel parameter
1 parent 091cb0d commit 2eef655

File tree

11 files changed

+22
-56
lines changed

11 files changed

+22
-56
lines changed

OnnxStack.StableDiffusion/Config/SchedulerOptions.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,6 @@ public record SchedulerOptions
6161
[Range(0f, 1f)]
6262
public float Strength { get; set; } = 0.6f;
6363

64-
/// <summary>
65-
/// Gets or sets the initial noise level for Image 2 Image
66-
/// </summary>
67-
[Range(-1f, 1f)]
68-
public float InitialNoiseLevel { get; set; } = 0f;
69-
7064
[Range(0, int.MaxValue)]
7165
public int TrainTimesteps { get; set; } = 1000;
7266
public float BetaStart { get; set; } = 0.00085f;

OnnxStack.StableDiffusion/Diffusers/LatentConsistency/ImageDiffuser.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,7 @@ protected override async Task<DenseTensor<float>> PrepareLatentsAsync(IModelOpti
7373
using (var result = results.First())
7474
{
7575
var outputResult = result.ToDenseTensor();
76-
var scaledSample = outputResult
77-
.Add(scheduler.CreateRandomSample(outputDimension, options.InitialNoiseLevel))
78-
.MultiplyBy(model.ScaleFactor);
79-
76+
var scaledSample = outputResult.MultiplyBy(model.ScaleFactor);
8077
return scheduler.AddNoise(scaledSample, scheduler.CreateRandomSample(scaledSample.Dimensions), timesteps);
8178
}
8279
}

OnnxStack.StableDiffusion/Diffusers/LatentConsistency/InpaintLegacyDiffuser.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,7 @@ protected override async Task<DenseTensor<float>> PrepareLatentsAsync(IModelOpti
174174
using (var result = results.First())
175175
{
176176
var outputResult = result.ToDenseTensor();
177-
var scaledSample = outputResult
178-
.Add(scheduler.CreateRandomSample(outputDimensions, options.InitialNoiseLevel))
179-
.MultiplyBy(model.ScaleFactor);
180-
177+
var scaledSample = outputResult.MultiplyBy(model.ScaleFactor);
181178
return scaledSample;
182179
}
183180
}

OnnxStack.StableDiffusion/Diffusers/StableDiffusion/ImageDiffuser.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,7 @@ protected override async Task<DenseTensor<float>> PrepareLatentsAsync(IModelOpti
7575
using (var result = results.First())
7676
{
7777
var outputResult = result.ToDenseTensor();
78-
var scaledSample = outputResult
79-
.Add(scheduler.CreateRandomSample(outputDimension, options.InitialNoiseLevel))
80-
.MultiplyBy(model.ScaleFactor);
81-
78+
var scaledSample = outputResult.MultiplyBy(model.ScaleFactor);
8279
return scheduler.AddNoise(scaledSample, scheduler.CreateRandomSample(scaledSample.Dimensions), timesteps);
8380
}
8481
}

OnnxStack.StableDiffusion/Diffusers/StableDiffusion/InpaintDiffuser.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Microsoft.Extensions.Logging;
2-
using Microsoft.ML.OnnxRuntime;
32
using Microsoft.ML.OnnxRuntime.Tensors;
43
using OnnxStack.Core;
54
using OnnxStack.Core.Config;
@@ -15,7 +14,6 @@
1514
using System.Collections.Generic;
1615
using System.Diagnostics;
1716
using System.Linq;
18-
using System.Reflection;
1917
using System.Threading;
2018
using System.Threading.Tasks;
2119

OnnxStack.StableDiffusion/Diffusers/StableDiffusion/InpaintLegacyDiffuser.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,7 @@ protected override async Task<DenseTensor<float>> PrepareLatentsAsync(IModelOpti
162162
using (var result = results.First())
163163
{
164164
var outputResult = result.ToDenseTensor();
165-
var scaledSample = outputResult
166-
.Add(scheduler.CreateRandomSample(outputDimensions, options.InitialNoiseLevel))
167-
.MultiplyBy(model.ScaleFactor);
168-
165+
var scaledSample = outputResult.MultiplyBy(model.ScaleFactor);
169166
return scaledSample;
170167
}
171168
}

OnnxStack.StableDiffusion/Diffusers/StableDiffusionXL/ImageDiffuser.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,7 @@ protected override async Task<DenseTensor<float>> PrepareLatentsAsync(IModelOpti
7474
using (var result = results.First())
7575
{
7676
var outputResult = result.ToDenseTensor();
77-
var scaledSample = outputResult
78-
.Add(scheduler.CreateRandomSample(outputDimension, options.InitialNoiseLevel))
79-
.MultiplyBy(model.ScaleFactor);
80-
77+
var scaledSample = outputResult.MultiplyBy(model.ScaleFactor);
8178
return scheduler.AddNoise(scaledSample, scheduler.CreateRandomSample(scaledSample.Dimensions), timesteps);
8279
}
8380
}

OnnxStack.StableDiffusion/Diffusers/StableDiffusionXL/InpaintLegacyDiffuser.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,7 @@ protected override async Task<DenseTensor<float>> PrepareLatentsAsync(IModelOpti
166166
using (var result = results.First())
167167
{
168168
var outputResult = result.ToDenseTensor();
169-
var scaledSample = outputResult
170-
.Add(scheduler.CreateRandomSample(outputDimensions, options.InitialNoiseLevel))
171-
.MultiplyBy(model.ScaleFactor);
172-
169+
var scaledSample = outputResult.MultiplyBy(model.ScaleFactor);
173170
return scaledSample;
174171
}
175172
}

OnnxStack.UI/Models/SchedulerOptionsModel.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ public class SchedulerOptionsModel : INotifyPropertyChanged
1414
private int _inferenceSteps = 30;
1515
private float _guidanceScale = 7.5f;
1616
private float _strength = 0.75f;
17-
private float _initialNoiseLevel = 0f;
1817
private int _trainTimesteps = 1000;
1918
private float _betaStart = 0.00085f;
2019
private float _betaEnd = 0.012f;
@@ -106,15 +105,6 @@ public float Strength
106105
get { return _strength; }
107106
set { _strength = value; NotifyPropertyChanged(); }
108107
}
109-
/// <summary>
110-
/// Gets or sets the initial noise level for Image 2 Image
111-
/// </summary>
112-
[Range(-1f, 1f)]
113-
public float InitialNoiseLevel
114-
{
115-
get { return _initialNoiseLevel; }
116-
set { _initialNoiseLevel = value; NotifyPropertyChanged(); }
117-
}
118108

119109
[Range(0, int.MaxValue)]
120110
public int TrainTimesteps

OnnxStack.UI/UserControls/SchedulerControl.xaml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,14 @@
185185
<UniformGrid Columns="2" Margin="0,5,0,0">
186186

187187

188+
189+
188190
<StackPanel Margin="0,0,5,0">
189191
<DockPanel>
190-
<Label>Initial Noise</Label>
191-
<TextBlock Text="{Binding ElementName=SliderInitialNoiseLevel, Path=Value, StringFormat={}{0:F2}}" VerticalAlignment="Bottom" HorizontalAlignment="Right" FontSize="10" Margin="0,0,6,0" FontWeight="Medium" />
192+
<Label>Strength</Label>
193+
<TextBlock Text="{Binding ElementName=SliderStrength, Path=Value, StringFormat={}{0:F2}}" VerticalAlignment="Bottom" HorizontalAlignment="Right" FontSize="10" Margin="0,0,6,0" FontWeight="Medium" />
192194
</DockPanel>
193-
<Slider Name="SliderInitialNoiseLevel" Value="{Binding SchedulerOptions.InitialNoiseLevel}" Minimum="-1" Maximum="1" TickFrequency="0.1" IsSnapToTickEnabled="true" SmallChange="0.1" LargeChange="0.1">
195+
<Slider Name="SliderStrength" Value="{Binding SchedulerOptions.Strength}" Minimum="0" Maximum="1" TickFrequency="0.01" IsSnapToTickEnabled="true" SmallChange="0.01" LargeChange="0.01">
194196
<i:Interaction.Behaviors>
195197
<behaviors:SliderMouseWheelBehavior />
196198
</i:Interaction.Behaviors>
@@ -201,17 +203,21 @@
201203
<DataTrigger Binding="{Binding Path=DiffuserType}" Value="TextToImage">
202204
<Setter Property="Visibility" Value="Collapsed" />
203205
</DataTrigger>
206+
<DataTrigger Binding="{Binding Path=DiffuserType}" Value="ImageInpaint">
207+
<Setter Property="Visibility" Value="Collapsed" />
208+
</DataTrigger>
204209
</Style.Triggers>
205210
</Style>
206211
</StackPanel.Style>
207212
</StackPanel>
208213

209-
<StackPanel Margin="5,0,0,0">
214+
215+
<!--<StackPanel Margin="5,0,0,0">
210216
<DockPanel>
211-
<Label>Strength</Label>
212-
<TextBlock Text="{Binding ElementName=SliderStrength, Path=Value, StringFormat={}{0:F2}}" VerticalAlignment="Bottom" HorizontalAlignment="Right" FontSize="10" Margin="0,0,6,0" FontWeight="Medium" />
217+
<Label>Initial Noise</Label>
218+
<TextBlock Text="{Binding ElementName=SliderInitialNoiseLevel, Path=Value, StringFormat={}{0:F2}}" VerticalAlignment="Bottom" HorizontalAlignment="Right" FontSize="10" Margin="0,0,6,0" FontWeight="Medium" />
213219
</DockPanel>
214-
<Slider Name="SliderStrength" Value="{Binding SchedulerOptions.Strength}" Minimum="0" Maximum="1" TickFrequency="0.01" IsSnapToTickEnabled="true" SmallChange="0.01" LargeChange="0.01">
220+
<Slider Name="SliderInitialNoiseLevel" Value="{Binding SchedulerOptions.InitialNoiseLevel}" Minimum="-1" Maximum="1" TickFrequency="0.1" IsSnapToTickEnabled="true" SmallChange="0.1" LargeChange="0.1">
215221
<i:Interaction.Behaviors>
216222
<behaviors:SliderMouseWheelBehavior />
217223
</i:Interaction.Behaviors>
@@ -222,13 +228,11 @@
222228
<DataTrigger Binding="{Binding Path=DiffuserType}" Value="TextToImage">
223229
<Setter Property="Visibility" Value="Collapsed" />
224230
</DataTrigger>
225-
<DataTrigger Binding="{Binding Path=DiffuserType}" Value="ImageInpaint">
226-
<Setter Property="Visibility" Value="Collapsed" />
227-
</DataTrigger>
228231
</Style.Triggers>
229232
</Style>
230233
</StackPanel.Style>
231-
</StackPanel>
234+
</StackPanel>-->
235+
232236
</UniformGrid>
233237

234238
<UniformGrid Columns="2" Rows="1" Margin="0,1,0,10">
@@ -393,7 +397,7 @@
393397
<ComboBox ItemsSource="{Binding Source={StaticResource BatchOptionType}}" SelectedItem="{Binding BatchOptions.BatchType}"/>
394398
<CheckBox Content="Disable History" IsChecked="{Binding BatchOptions.DisableHistory}" IsEnabled="{Binding BatchOptions.IsAutomationEnabled}" HorizontalAlignment="Right" />
395399
</UniformGrid>
396-
400+
397401
</StackPanel>
398402

399403

0 commit comments

Comments
 (0)