@@ -44,6 +44,7 @@ public partial class VideoToVideoView : UserControl, INavigatable, INotifyProper
4444 private VideoInputModel _inputVideo ;
4545 private VideoInputModel _resultVideo ;
4646 private StableDiffusionModelSetViewModel _selectedModel ;
47+ private ControlNetModelSetViewModel _selectedControlNetModel ;
4748 private PromptOptionsModel _promptOptionsModel ;
4849 private SchedulerOptionsModel _schedulerOptions ;
4950 private CancellationTokenSource _cancelationTokenSource ;
@@ -63,7 +64,7 @@ public VideoToVideoView()
6364 _stableDiffusionService = App . GetService < IStableDiffusionService > ( ) ;
6465 }
6566
66- SupportedDiffusers = new ( ) { DiffuserType . ImageToImage } ;
67+ SupportedDiffusers = new ( ) { DiffuserType . ImageToImage , DiffuserType . ControlNet } ;
6768 CancelCommand = new AsyncRelayCommand ( Cancel , CanExecuteCancel ) ;
6869 GenerateCommand = new AsyncRelayCommand ( Generate , CanExecuteGenerate ) ;
6970 ClearHistoryCommand = new AsyncRelayCommand ( ClearHistory , CanExecuteClearHistory ) ;
@@ -95,6 +96,12 @@ public StableDiffusionModelSetViewModel SelectedModel
9596 set { _selectedModel = value ; NotifyPropertyChanged ( ) ; }
9697 }
9798
99+ public ControlNetModelSetViewModel SelectedControlNetModel
100+ {
101+ get { return _selectedControlNetModel ; }
102+ set { _selectedControlNetModel = value ; NotifyPropertyChanged ( ) ; }
103+ }
104+
98105 public PromptOptionsModel PromptOptions
99106 {
100107 get { return _promptOptionsModel ; }
@@ -215,7 +222,7 @@ private async Task Generate()
215222 var promptOptions = GetPromptOptions ( PromptOptions , _videoFrames ) ;
216223
217224 var timestamp = Stopwatch . GetTimestamp ( ) ;
218- var result = await _stableDiffusionService . GenerateAsBytesAsync ( new ModelOptions ( _selectedModel . ModelSet ) , promptOptions , schedulerOptions , ProgressCallback ( ) , _cancelationTokenSource . Token ) ;
225+ var result = await _stableDiffusionService . GenerateAsBytesAsync ( new ModelOptions ( _selectedModel . ModelSet , _selectedControlNetModel ? . ModelSet ) , promptOptions , schedulerOptions , ProgressCallback ( ) , _cancelationTokenSource . Token ) ;
219226 var resultVideo = await GenerateResultAsync ( result , promptOptions , schedulerOptions , timestamp ) ;
220227 if ( resultVideo != null )
221228 {
@@ -247,7 +254,9 @@ private async Task Generate()
247254 /// </returns>
248255 private bool CanExecuteGenerate ( )
249256 {
250- return ! IsGenerating && HasInputResult ;
257+ return ! IsGenerating
258+ && HasInputResult
259+ && ( ! SelectedModel . IsControlNet || ( SelectedModel . IsControlNet && SelectedControlNetModel ? . IsLoaded == true ) ) ;
251260 }
252261
253262
@@ -314,11 +323,19 @@ private void Reset()
314323
315324 private PromptOptions GetPromptOptions ( PromptOptionsModel promptOptionsModel , VideoFrames videoFrames )
316325 {
326+ var diffuserType = DiffuserType . ImageToImage ;
327+ if ( _selectedModel . IsControlNet )
328+ {
329+ diffuserType = _schedulerOptions . Strength >= 1
330+ ? DiffuserType . ControlNet
331+ : DiffuserType . ControlNetImage ;
332+ }
333+
317334 return new PromptOptions
318335 {
319336 Prompt = promptOptionsModel . Prompt ,
320337 NegativePrompt = promptOptionsModel . NegativePrompt ,
321- DiffuserType = DiffuserType . ImageToImage ,
338+ DiffuserType = diffuserType ,
322339 InputVideo = new VideoInput ( videoFrames ) ,
323340 VideoInputFPS = promptOptionsModel . VideoInputFPS ,
324341 VideoOutputFPS = promptOptionsModel . VideoOutputFPS ,
0 commit comments