@@ -44,6 +44,7 @@ public partial class VideoToVideoView : UserControl, INavigatable, INotifyProper
44
44
private VideoInputModel _inputVideo ;
45
45
private VideoInputModel _resultVideo ;
46
46
private StableDiffusionModelSetViewModel _selectedModel ;
47
+ private ControlNetModelSetViewModel _selectedControlNetModel ;
47
48
private PromptOptionsModel _promptOptionsModel ;
48
49
private SchedulerOptionsModel _schedulerOptions ;
49
50
private CancellationTokenSource _cancelationTokenSource ;
@@ -63,7 +64,7 @@ public VideoToVideoView()
63
64
_stableDiffusionService = App . GetService < IStableDiffusionService > ( ) ;
64
65
}
65
66
66
- SupportedDiffusers = new ( ) { DiffuserType . ImageToImage } ;
67
+ SupportedDiffusers = new ( ) { DiffuserType . ImageToImage , DiffuserType . ControlNet } ;
67
68
CancelCommand = new AsyncRelayCommand ( Cancel , CanExecuteCancel ) ;
68
69
GenerateCommand = new AsyncRelayCommand ( Generate , CanExecuteGenerate ) ;
69
70
ClearHistoryCommand = new AsyncRelayCommand ( ClearHistory , CanExecuteClearHistory ) ;
@@ -95,6 +96,12 @@ public StableDiffusionModelSetViewModel SelectedModel
95
96
set { _selectedModel = value ; NotifyPropertyChanged ( ) ; }
96
97
}
97
98
99
+ public ControlNetModelSetViewModel SelectedControlNetModel
100
+ {
101
+ get { return _selectedControlNetModel ; }
102
+ set { _selectedControlNetModel = value ; NotifyPropertyChanged ( ) ; }
103
+ }
104
+
98
105
public PromptOptionsModel PromptOptions
99
106
{
100
107
get { return _promptOptionsModel ; }
@@ -215,7 +222,7 @@ private async Task Generate()
215
222
var promptOptions = GetPromptOptions ( PromptOptions , _videoFrames ) ;
216
223
217
224
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 ) ;
219
226
var resultVideo = await GenerateResultAsync ( result , promptOptions , schedulerOptions , timestamp ) ;
220
227
if ( resultVideo != null )
221
228
{
@@ -247,7 +254,9 @@ private async Task Generate()
247
254
/// </returns>
248
255
private bool CanExecuteGenerate ( )
249
256
{
250
- return ! IsGenerating && HasInputResult ;
257
+ return ! IsGenerating
258
+ && HasInputResult
259
+ && ( ! SelectedModel . IsControlNet || ( SelectedModel . IsControlNet && SelectedControlNetModel ? . IsLoaded == true ) ) ;
251
260
}
252
261
253
262
@@ -314,11 +323,19 @@ private void Reset()
314
323
315
324
private PromptOptions GetPromptOptions ( PromptOptionsModel promptOptionsModel , VideoFrames videoFrames )
316
325
{
326
+ var diffuserType = DiffuserType . ImageToImage ;
327
+ if ( _selectedModel . IsControlNet )
328
+ {
329
+ diffuserType = _schedulerOptions . Strength >= 1
330
+ ? DiffuserType . ControlNet
331
+ : DiffuserType . ControlNetImage ;
332
+ }
333
+
317
334
return new PromptOptions
318
335
{
319
336
Prompt = promptOptionsModel . Prompt ,
320
337
NegativePrompt = promptOptionsModel . NegativePrompt ,
321
- DiffuserType = DiffuserType . ImageToImage ,
338
+ DiffuserType = diffuserType ,
322
339
InputVideo = new VideoInput ( videoFrames ) ,
323
340
VideoInputFPS = promptOptionsModel . VideoInputFPS ,
324
341
VideoOutputFPS = promptOptionsModel . VideoOutputFPS ,
0 commit comments