@@ -26,6 +26,8 @@ public partial class DiffusionInputControl : BaseControl
2626 private bool _isSchedulerStochastic ;
2727 private bool _isSchedulerClipSample ;
2828 private bool _isSchedulerThresholding ;
29+ private bool _isSteps2Enabled ;
30+ private bool _isGuidance2Enabled ;
2931
3032 public DiffusionInputControl ( )
3133 {
@@ -35,7 +37,7 @@ public DiffusionInputControl()
3537 }
3638
3739 public static readonly DependencyProperty PipelineProperty = DependencyProperty . Register ( nameof ( Pipeline ) , typeof ( PipelineModel ) , typeof ( DiffusionInputControl ) , new PropertyMetadata < DiffusionInputControl , PipelineModel > ( ( c , o , n ) => c . OnPipelineChanged ( o , n ) ) ) ;
38- public static readonly DependencyProperty OptionsProperty = DependencyProperty . Register ( nameof ( Options ) , typeof ( DiffusionInputOptions ) , typeof ( DiffusionInputControl ) , new PropertyMetadata < DiffusionInputControl , DiffusionInputOptions > ( ( c , o , n ) => c . OnOptionsChanged ( o , n ) ) ) ;
40+ public static readonly DependencyProperty OptionsProperty = DependencyProperty . Register ( nameof ( Options ) , typeof ( DiffusionInputOptions ) , typeof ( DiffusionInputControl ) ) ;
3941 public static readonly DependencyProperty UpscaleOptionsProperty = DependencyProperty . Register ( nameof ( UpscaleOptions ) , typeof ( UpscaleInputOptions ) , typeof ( DiffusionInputControl ) ) ;
4042 public static readonly DependencyProperty ExtractOptionsProperty = DependencyProperty . Register ( nameof ( ExtractOptions ) , typeof ( ExtractInputOptions ) , typeof ( DiffusionInputControl ) ) ;
4143
@@ -146,58 +148,77 @@ public bool IsSchedulerThresholding
146148 set { SetProperty ( ref _isSchedulerThresholding , value ) ; }
147149 }
148150
151+ public bool IsSteps2Enabled
152+ {
153+ get { return _isSteps2Enabled ; }
154+ set { SetProperty ( ref _isSteps2Enabled , value ) ; }
155+ }
156+
157+ public bool IsGuidance2Enabled
158+ {
159+ get { return _isGuidance2Enabled ; }
160+ set { SetProperty ( ref _isGuidance2Enabled , value ) ; }
161+ }
162+
149163
150164 private Task OnPipelineChanged ( PipelineModel oldPipeline , PipelineModel newPipeline )
151165 {
152166 if ( newPipeline is null || newPipeline . DiffusionModel is null )
153167 return Task . CompletedTask ;
154168
155169 var oldModel = oldPipeline ? . DiffusionModel ;
170+ var oldOptions = oldModel ? . DefaultOptions ;
156171 var newModel = newPipeline ? . DiffusionModel ;
172+ var newOptions = newModel ? . DefaultOptions ;
157173
158- if ( oldModel is not null && oldModel . Pipeline == newModel . Pipeline )
159- return Task . CompletedTask ;
160-
161- IsModelOptionsVisible = newPipeline . UpscaleModel is not null || newPipeline . ExtractModel is not null ;
162- return Task . CompletedTask ;
163- }
164-
165-
166- private Task OnOptionsChanged ( DiffusionInputOptions oldOptions , DiffusionInputOptions newOptions )
167- {
168- if ( newOptions is null )
174+ if ( oldModel == newModel )
169175 return Task . CompletedTask ;
170176
171- if ( oldOptions != null )
177+ var previousOptions = Options ;
178+ Options = new DiffusionInputOptions
172179 {
173- newOptions . Seed = oldOptions . Seed ;
174- newOptions . Prompt = oldOptions . Prompt ;
175- newOptions . NegativePrompt = oldOptions . NegativePrompt ;
176-
177- newOptions . Steps = oldOptions . Steps ;
178- newOptions . Steps2 = oldOptions . Steps2 ;
179- newOptions . GuidanceScale = oldOptions . GuidanceScale ;
180- newOptions . GuidanceScale2 = oldOptions . GuidanceScale2 ;
181- newOptions . InputImageCount = oldOptions . InputImageCount ;
182-
183- newOptions . Strength = oldOptions . Strength ;
184- newOptions . LoraStrength = oldOptions . LoraStrength ;
185- newOptions . ControlNetStrength = oldOptions . ControlNetStrength ;
186-
187- if ( Pipeline . DiffusionModel . DefaultOptions . Schedulers . Contains ( oldOptions . Scheduler ) )
180+ // Keep
181+ Prompt = previousOptions ? . Prompt ,
182+ NegativePrompt = previousOptions ? . NegativePrompt ,
183+ Seed = previousOptions ? . Seed ?? 0 ,
184+ LoraStrength = previousOptions ? . LoraStrength ?? 1f ,
185+ InputImageCount = ProcessType == ProcessType . ImageEdit ? ( previousOptions ? . InputImageCount ?? 1 ) : 0 ,
186+
187+ // Update
188+ Strength = ProcessType == ProcessType . ImageToImage || ProcessType == ProcessType . ControlNetImageToImage ? ( previousOptions ? . Strength ?? 0.7f ) : 1f ,
189+ ControlNetStrength = ProcessType == ProcessType . ControlNetImage || ProcessType == ProcessType . ControlNetImageToImage ? ( previousOptions ? . ControlNetStrength ?? 0.7f ) : 1f ,
190+
191+ Steps = newOptions . Steps ,
192+ Steps2 = newOptions . Steps2 ,
193+ Scheduler = newOptions . Scheduler ,
194+ GuidanceScale = newOptions . GuidanceScale ,
195+ GuidanceScale2 = newOptions . GuidanceScale2 ,
196+ SchedulerOptions = new SchedulerInputOptions
188197 {
189- newOptions . Scheduler = oldOptions . Scheduler ;
190- newOptions . SchedulerOptions = oldOptions . SchedulerOptions ;
198+ Shift = newOptions . Shift ,
199+ SolverType = newOptions . SolverType ,
200+ PredictionType = newOptions . PredictionType ,
201+ BaseShift = newOptions . BaseShift ,
202+ BetaEnd = newOptions . BetaEnd ,
203+ BetaSchedule = newOptions . BetaSchedule ,
204+ BetaStart = newOptions . BetaStart ,
205+ MaxShift = newOptions . MaxShift ,
206+ StepsOffset = newOptions . StepsOffset ,
207+ TimestepSpacing = newOptions . TimestepSpacing ,
208+ BaseImageSeqLen = newOptions . BaseImageSeqLen ,
209+ MaxImageSeqLen = newOptions . MaxImageSeqLen ,
210+ UseDynamicShifting = newOptions . UseDynamicShifting ,
191211 }
212+ } ;
192213
193- SelectedResolution = Pipeline ? . DiffusionModel . Resolutions . FirstOrDefault ( x => x . Width == _selectedResolution ? . Width && x . Height == _selectedResolution ? . Height )
194- ?? Pipeline ? . DiffusionModel . Resolutions . FirstOrDefault ( x => x . IsDefault ) ;
195- }
196- else
197- {
198- SelectedResolution = Pipeline ? . DiffusionModel . Resolutions . FirstOrDefault ( x => x . IsDefault ) ;
199- }
214+ //Resolution
215+ SelectedResolution = newModel ? . Resolutions . FirstOrDefault ( x => x . Width == _selectedResolution ? . Width && x . Height == _selectedResolution ? . Height )
216+ ?? newModel ? . Resolutions . FirstOrDefault ( x => x . IsDefault ) ;
200217
218+ // UI Flags
219+ IsSteps2Enabled = newPipeline . DiffusionModel . DefaultOptions . Steps2 > 0 ;
220+ IsGuidance2Enabled = newPipeline . DiffusionModel . DefaultOptions . GuidanceScale2 > 0 ;
221+ IsModelOptionsVisible = newPipeline . UpscaleModel is not null || newPipeline . ExtractModel is not null ;
201222 return Task . CompletedTask ;
202223 }
203224
0 commit comments