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

Commit 5d7cedb

Browse files
committed
Add BetaSchedule and Karras option to main view
1 parent 36f0789 commit 5d7cedb

File tree

3 files changed

+65
-17
lines changed

3 files changed

+65
-17
lines changed

OnnxStack.StableDiffusion/Config/SchedulerOptions.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,16 @@ public record SchedulerOptions
8686
public float MaximumBeta { get; set; } = 0.999f;
8787

8888
public int OriginalInferenceSteps { get; set; } = 50;
89+
90+
public bool IsKarrasScheduler
91+
{
92+
get
93+
{
94+
return SchedulerType == SchedulerType.LMS
95+
|| SchedulerType == SchedulerType.KDPM2
96+
|| SchedulerType == SchedulerType.Euler
97+
|| SchedulerType == SchedulerType.EulerAncestral;
98+
}
99+
}
89100
}
90101
}

OnnxStack.UI/UserControls/SchedulerControl.xaml

Lines changed: 54 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
</StackPanel>
7676
</UniformGrid>
7777

78-
<UniformGrid Columns="2" Margin="0,10,0,10">
78+
<UniformGrid Columns="2" Margin="0,10,0,0">
7979

8080

8181
<StackPanel Margin="0,0,5,0">
@@ -124,6 +124,47 @@
124124
</StackPanel>
125125
</UniformGrid>
126126

127+
<UniformGrid Columns="2" Rows="1" Margin="0,1,0,10">
128+
129+
<StackPanel Margin="0,0,5,0">
130+
<Label>Beta Schedule</Label>
131+
<ComboBox ItemsSource="{Binding Source={StaticResource BetaScheduleType}}" SelectedItem="{Binding SchedulerOptions.BetaSchedule}">
132+
<ComboBox.ItemContainerStyle>
133+
<Style TargetType="{x:Type ComboBoxItem}" BasedOn="{StaticResource {x:Type ComboBoxItem}}">
134+
<Setter Property="Visibility" Value="Visible" />
135+
<Style.Triggers>
136+
<DataTrigger Binding="{Binding}" Value="SquaredCosCapV2">
137+
<Setter Property="Visibility" Value="Collapsed" />
138+
</DataTrigger>
139+
</Style.Triggers>
140+
</Style>
141+
</ComboBox.ItemContainerStyle>
142+
</ComboBox>
143+
</StackPanel>
144+
145+
<StackPanel VerticalAlignment="Bottom" >
146+
<CheckBox Content="Use Karras Sigmas" IsChecked="{Binding SchedulerOptions.UseKarrasSigmas}" Margin="5,0,0,5" />
147+
<StackPanel.Style>
148+
<Style TargetType="{x:Type StackPanel}">
149+
<Setter Property="IsEnabled" Value="True" />
150+
<Style.Triggers>
151+
<DataTrigger Binding="{Binding SchedulerOptions.SchedulerType, ElementName=UI}" Value="LCM" >
152+
<Setter Property="IsEnabled" Value="False" />
153+
</DataTrigger>
154+
<DataTrigger Binding="{Binding SchedulerOptions.SchedulerType, ElementName=UI}" Value="DDIM" >
155+
<Setter Property="IsEnabled" Value="False" />
156+
</DataTrigger>
157+
<DataTrigger Binding="{Binding SchedulerOptions.SchedulerType, ElementName=UI}" Value="DDPM" >
158+
<Setter Property="IsEnabled" Value="False" />
159+
</DataTrigger>
160+
</Style.Triggers>
161+
</Style>
162+
</StackPanel.Style>
163+
</StackPanel>
164+
165+
</UniformGrid>
166+
167+
127168
<StackPanel HorizontalAlignment="Right">
128169
<Button Command="{Binding ResetParametersCommand}" Margin="0,5,0,0">
129170
<userControls:FontAwesome Icon="&#xf2ea;" IconStyle="Light" Size="14" Margin="2"/>
@@ -143,12 +184,8 @@
143184
<StackPanel Margin="2">
144185

145186
<UniformGrid Columns="2" Margin="0,10, 0, 0">
146-
<StackPanel HorizontalAlignment="Center">
147-
<CheckBox Content="Use Karras Sigmas" IsChecked="{Binding SchedulerOptions.UseKarrasSigmas}" Margin="0,0,0,5"/>
148-
</StackPanel>
149-
<StackPanel HorizontalAlignment="Center">
150-
<CheckBox Content="Thresholding" IsChecked="{Binding SchedulerOptions.Thresholding}" Margin="0,0,0,5"/>
151-
</StackPanel>
187+
188+
152189
</UniformGrid>
153190

154191
<UniformGrid Columns="3">
@@ -182,37 +219,38 @@
182219
</UniformGrid>
183220

184221
<UniformGrid Columns="3">
222+
185223
<StackPanel>
186-
<Label>BetaSchedule</Label>
187-
<ComboBox ItemsSource="{Binding Source={StaticResource BetaScheduleType}}" SelectedItem="{Binding SchedulerOptions.BetaSchedule}" />
188-
</StackPanel>
189-
<StackPanel Margin="1,0,1,0">
190224
<Label>BetaStart</Label>
191225
<TextBox Text="{Binding SchedulerOptions.BetaStart}"/>
192226
</StackPanel>
193-
<StackPanel>
227+
<StackPanel Margin="1,0,1,0">
194228
<Label>BetaEnd</Label>
195229
<TextBox Text="{Binding SchedulerOptions.BetaEnd}"/>
196230
</StackPanel>
197-
</UniformGrid>
198-
199-
<UniformGrid Columns="3">
200231
<StackPanel>
201232
<Label>MaximumBeta</Label>
202233
<TextBox Text="{Binding SchedulerOptions.MaximumBeta}"/>
203234
</StackPanel>
235+
</UniformGrid>
236+
237+
<UniformGrid Columns="3">
238+
204239
<StackPanel Margin="1,0,1,0">
205240
<Label>ClipSampleRange</Label>
206241
<TextBox Text="{Binding SchedulerOptions.ClipSampleRange}"/>
207242
</StackPanel>
208243
<StackPanel VerticalAlignment="Bottom">
209244
<CheckBox Content="ClipSample" IsChecked="{Binding SchedulerOptions.ClipSample}" Margin="5,0,0,5"/>
210245
</StackPanel>
246+
<StackPanel VerticalAlignment="Bottom">
247+
<CheckBox Content="Thresholding" IsChecked="{Binding SchedulerOptions.Thresholding}" Margin="5,0,0,5"/>
248+
</StackPanel>
211249
</UniformGrid>
212250

213251
<UniformGrid Columns="3">
214252
<StackPanel Visibility="{Binding SelectedModel.ModelOptions.PipelineType, Converter={StaticResource PipelineVisibilityConverter}, ConverterParameter=LatentConsistency}">
215-
<Label>LCM Original Steps</Label>
253+
<Label>Original Timesteps</Label>
216254
<TextBox Text="{Binding SchedulerOptions.OriginalInferenceSteps}"/>
217255
</StackPanel>
218256
<StackPanel Margin="1,0,1,0">

OnnxStack.UI/UserControls/SchedulerControl.xaml.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ private void OnModelChanged(ModelOptionsModel model)
123123
SchedulerOptions.OriginalInferenceSteps = 50;
124124
SchedulerOptions.InferenceSteps = 6;
125125
SchedulerOptions.GuidanceScale = 1f;
126-
SchedulerOptions.BetaSchedule = BetaScheduleType.Linear;
127126
}
128127

129128

0 commit comments

Comments
 (0)