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

Commit 6f34888

Browse files
committed
Realtime no prompt support, Navigation Icons
1 parent 902387c commit 6f34888

12 files changed

+59
-76
lines changed

OnnxStack.UI/App.xaml

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,7 @@
106106

107107

108108

109-
<Style x:Key="ExecutionProviderTypes" TargetType="{x:Type ComboBoxItem}" BasedOn="{StaticResource {x:Type ComboBoxItem}}">
110-
<Setter Property="Visibility" Value="Collapsed" />
111-
<Style.Triggers>
112-
<DataTrigger Binding="{Binding}" Value="Cpu">
113-
<Setter Property="Visibility" Value="Visible" />
114-
</DataTrigger>
115-
<DataTrigger Binding="{Binding}" Value="DirectML">
116-
<Setter Property="Visibility" Value="Visible" />
117-
</DataTrigger>
118-
</Style.Triggers>
119-
</Style>
120-
121-
122-
109+
123110

124111

125112

@@ -260,10 +247,10 @@
260247
<userControls:FontAwesome Icon="&#xf302;" IconStyle="Light" Size="13" ToolTip="Send To Image To Image"/>
261248
</Button>
262249
<Button Command="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}}, Path=NavigateImageInpaintCommand}" CommandParameter="{Binding}" >
263-
<userControls:FontAwesome Icon="&#xf1fc;" IconStyle="Light" Size="13" ToolTip="Send To Image Inpaint"/>
250+
<userControls:FontAwesome Icon="&#xf1c5;" IconStyle="Light" Size="13" ToolTip="Send To Image Inpaint"/>
264251
</Button>
265252
<Button Command="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}}, Path=NavigateImagePaintToImageCommand}" CommandParameter="{Binding}" Padding="2,2" BorderThickness="0,1,1,1">
266-
<userControls:FontAwesome Icon="&#xf065;" IconStyle="Light" Size="13" ToolTip="Send To Upscaler"/>
253+
<userControls:FontAwesome Icon="&#xf1fc;" IconStyle="Light" Size="13" ToolTip="Send To Upscaler"/>
267254
</Button>
268255
</UniformGrid>
269256
</StackPanel>
@@ -1990,7 +1977,35 @@
19901977

19911978

19921979

1980+
<Style x:Key="ExecutionProviderTypes" TargetType="{x:Type ComboBoxItem}" BasedOn="{StaticResource {x:Type ComboBoxItem}}">
1981+
<Setter Property="Visibility" Value="Collapsed" />
1982+
<Style.Triggers>
1983+
<DataTrigger Binding="{Binding}" Value="Cpu">
1984+
<Setter Property="Visibility" Value="Visible" />
1985+
</DataTrigger>
1986+
<DataTrigger Binding="{Binding}" Value="DirectML">
1987+
<Setter Property="Visibility" Value="Visible" />
1988+
</DataTrigger>
1989+
</Style.Triggers>
1990+
</Style>
1991+
1992+
<Style x:Key="ButtonGenerateStyle" TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
1993+
<Setter Property="Content" Value="Generate" />
1994+
<Style.Triggers>
1995+
<DataTrigger Binding="{Binding BatchOptions.IsRealtimeEnabled, ElementName=UI}" Value="True">
1996+
<Setter Property="Content" Value="Start" />
1997+
</DataTrigger>
1998+
</Style.Triggers>
1999+
</Style>
19932000

2001+
<Style x:Key="ButtonGenerateCancelStyle" TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
2002+
<Setter Property="Content" Value="Cancel" />
2003+
<Style.Triggers>
2004+
<DataTrigger Binding="{Binding BatchOptions.IsRealtimeEnabled, ElementName=UI}" Value="True">
2005+
<Setter Property="Content" Value="Stop" />
2006+
</DataTrigger>
2007+
</Style.Triggers>
2008+
</Style>
19942009

19952010

19962011
</Application.Resources>

OnnxStack.UI/UserControls/ImageResultControl.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@
6565
<userControls:FontAwesome Icon="&#xf302;" IconStyle="Light" Size="13" />
6666
</Button>
6767
<Button Command="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}}, Path=NavigateImageInpaintCommand}" CommandParameter="{Binding Result}" ToolTip="Send To Image Inpaint">
68-
<userControls:FontAwesome Icon="&#xf1fc;" IconStyle="Light" />
68+
<userControls:FontAwesome Icon="&#xf1c5;" IconStyle="Light" />
6969
</Button>
7070
<Button Command="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}}, Path=NavigateImagePaintToImageCommand}" CommandParameter="{Binding Result}" ToolTip="Send To Upscaler" BorderThickness="0,1,1,1">
71-
<userControls:FontAwesome Icon="&#xf065;" IconStyle="Light" />
71+
<userControls:FontAwesome Icon="&#xf1fc;" IconStyle="Light" />
7272
</Button>
7373
</UniformGrid>
7474
</StackPanel>

OnnxStack.UI/UserControls/PaintInputControl.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
</ItemsPanelTemplate>
6969
</ListView.ItemsPanel>
7070
</ListView>
71-
71+
7272
<xctk:ColorPicker x:Name="ColorPickerControl"
7373
DisplayColorAndName="False"
7474
ShowRecentColors="False"

OnnxStack.UI/UserControls/PaintInputControl.xaml.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ private Task LoadImage()
193193
/// Clears the image.
194194
/// </summary>
195195
/// <returns></returns>
196-
private Task ClearCanvas()
196+
private async Task ClearCanvas()
197197
{
198198
PaintCanvas.Strokes.Clear();
199199
BackgroundBrush = new SolidColorBrush(Colors.White);
@@ -202,20 +202,20 @@ private Task ClearCanvas()
202202
Image = CreateCanvasImage(),
203203
FileName = "Canvas Image",
204204
};
205-
HasCanvasChanged = true;
206-
return Task.CompletedTask;
205+
await Task.Delay(100);
206+
await SaveCanvas();
207207
}
208208

209209

210210
/// <summary>
211211
/// Fills the canvas with the SelectedColor.
212212
/// </summary>
213213
/// <returns></returns>
214-
private Task FillCanvas()
214+
private async Task FillCanvas()
215215
{
216216
BackgroundBrush = new SolidColorBrush(SelectedColor);
217-
HasCanvasChanged = true;
218-
return Task.CompletedTask;
217+
await Task.Delay(100);
218+
await SaveCanvas();
219219
}
220220

221221

OnnxStack.UI/Views/ImageInpaintView.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
<!--Control Panel-->
1717
<DockPanel Grid.Column="0" DataContext="{Binding ElementName=UI}" Margin="3,3,3,0">
1818
<UniformGrid DockPanel.Dock="Bottom" Columns="2" Height="30">
19-
<Button Content="Cancel" Command="{Binding CancelCommand}" Margin="0,0,1,0"/>
20-
<Button Content="Generate" Command="{Binding GenerateCommand}" IsEnabled="{Binding SelectedModel.IsLoaded, FallbackValue=False, TargetNullValue=False}" IsDefault="True" Margin="1,0,0,0"/>
19+
<Button Command="{Binding CancelCommand}" Margin="0,0,1,0" Style="{StaticResource ButtonGenerateCancelStyle}"/>
20+
<Button Command="{Binding GenerateCommand}" IsEnabled="{Binding SelectedModel.IsLoaded, FallbackValue=False, TargetNullValue=False}" Style="{StaticResource ButtonGenerateStyle}" IsDefault="True" Margin="1,0,0,0"/>
2121
</UniformGrid>
2222
<DockPanel>
2323
<userControls:ModelPickerControl DockPanel.Dock="Top"

OnnxStack.UI/Views/ImageInpaintView.xaml.cs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ private async Task Generate()
263263
private bool CanExecuteGenerate()
264264
{
265265
return !IsGenerating
266-
&& !string.IsNullOrEmpty(PromptOptions.Prompt)
266+
// && !string.IsNullOrEmpty(PromptOptions.Prompt)
267267
&& HasInputResult;
268268
}
269269

@@ -335,9 +335,6 @@ private void Reset()
335335
/// <returns></returns>
336336
private async IAsyncEnumerable<ImageResult> ExecuteStableDiffusion(IModelOptions modelOptions, PromptOptions promptOptions, SchedulerOptions schedulerOptions, BatchOptions batchOptions)
337337
{
338-
if (!IsExecuteOptionsValid(PromptOptions))
339-
yield break;
340-
341338
_cancelationTokenSource = new CancellationTokenSource();
342339

343340
if (!BatchOptions.IsRealtimeEnabled)
@@ -386,15 +383,6 @@ private async IAsyncEnumerable<ImageResult> ExecuteStableDiffusion(IModelOptions
386383
}
387384
}
388385

389-
private bool IsExecuteOptionsValid(PromptOptionsModel prompt)
390-
{
391-
if (string.IsNullOrEmpty(prompt.Prompt))
392-
return false;
393-
394-
return true;
395-
}
396-
397-
398386
private PromptOptions GetPromptOptions(PromptOptionsModel promptOptionsModel, ImageInput imageInput, ImageInput imageInputMask)
399387
{
400388
return new PromptOptions

OnnxStack.UI/Views/ImageToImageView.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
<!--Control Panel-->
1717
<DockPanel Grid.Column="0" DataContext="{Binding ElementName=UI}" Margin="3,3,3,0">
1818
<UniformGrid DockPanel.Dock="Bottom" Columns="2" Height="30">
19-
<Button Content="Cancel" Command="{Binding CancelCommand}" Margin="0,0,1,0"/>
20-
<Button Content="Generate" Command="{Binding GenerateCommand}" IsEnabled="{Binding SelectedModel.IsLoaded, FallbackValue=False, TargetNullValue=False}" IsDefault="True" Margin="1,0,0,0"/>
19+
<Button Command="{Binding CancelCommand}" Margin="0,0,1,0" Style="{StaticResource ButtonGenerateCancelStyle}"/>
20+
<Button Command="{Binding GenerateCommand}" IsEnabled="{Binding SelectedModel.IsLoaded, FallbackValue=False, TargetNullValue=False}" Style="{StaticResource ButtonGenerateStyle}" IsDefault="True" Margin="1,0,0,0"/>
2121
</UniformGrid>
2222
<DockPanel>
2323
<userControls:ModelPickerControl DockPanel.Dock="Top"

OnnxStack.UI/Views/ImageToImageView.xaml.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ private async Task Generate()
245245
private bool CanExecuteGenerate()
246246
{
247247
return !IsGenerating
248-
&& !string.IsNullOrEmpty(PromptOptions.Prompt)
248+
// && !string.IsNullOrEmpty(PromptOptions.Prompt)
249249
&& HasInputResult;
250250
}
251251

@@ -317,9 +317,6 @@ private void Reset()
317317
/// <returns></returns>
318318
private async IAsyncEnumerable<ImageResult> ExecuteStableDiffusion(IModelOptions modelOptions, PromptOptions promptOptions, SchedulerOptions schedulerOptions, BatchOptions batchOptions)
319319
{
320-
if (!IsExecuteOptionsValid(PromptOptions))
321-
yield break;
322-
323320
_cancelationTokenSource = new CancellationTokenSource();
324321

325322
if (!BatchOptions.IsRealtimeEnabled)
@@ -368,14 +365,6 @@ private async IAsyncEnumerable<ImageResult> ExecuteStableDiffusion(IModelOptions
368365
}
369366
}
370367

371-
private bool IsExecuteOptionsValid(PromptOptionsModel prompt)
372-
{
373-
if (string.IsNullOrEmpty(prompt.Prompt))
374-
return false;
375-
376-
return true;
377-
}
378-
379368

380369
private PromptOptions GetPromptOptions(PromptOptionsModel promptOptionsModel, ImageInput imageInput)
381370
{

OnnxStack.UI/Views/PaintToImageView.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
<!--Control Panel-->
1717
<DockPanel Grid.Column="0" DataContext="{Binding ElementName=UI}" Margin="3,3,3,0">
1818
<UniformGrid DockPanel.Dock="Bottom" Columns="2" Height="30">
19-
<Button Content="Cancel" Command="{Binding CancelCommand}" Margin="0,0,1,0"/>
20-
<Button Content="Generate" Command="{Binding GenerateCommand}" IsEnabled="{Binding SelectedModel.IsLoaded, FallbackValue=False, TargetNullValue=False}" IsDefault="True" Margin="1,0,0,0"/>
19+
<Button Command="{Binding CancelCommand}" Margin="0,0,1,0" Style="{StaticResource ButtonGenerateCancelStyle}"/>
20+
<Button Command="{Binding GenerateCommand}" IsEnabled="{Binding SelectedModel.IsLoaded, FallbackValue=False, TargetNullValue=False}" Style="{StaticResource ButtonGenerateStyle}" IsDefault="True" Margin="1,0,0,0"/>
2121
</UniformGrid>
2222
<DockPanel>
2323
<userControls:ModelPickerControl DockPanel.Dock="Top"

OnnxStack.UI/Views/PaintToImageView.xaml.cs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public ImageInput InputImage
120120
set { _inputImage = value; NotifyPropertyChanged(); }
121121
}
122122

123-
123+
124124

125125
public ImageInput CanvasImage
126126
{
@@ -255,7 +255,7 @@ private async Task Generate()
255255
private bool CanExecuteGenerate()
256256
{
257257
return !IsGenerating
258-
&& !string.IsNullOrEmpty(PromptOptions.Prompt)
258+
// && !string.IsNullOrEmpty(PromptOptions.Prompt)
259259
&& HasCanvasChanged;
260260
}
261261

@@ -328,9 +328,6 @@ private void Reset()
328328
/// <returns></returns>
329329
private async IAsyncEnumerable<ImageResult> ExecuteStableDiffusion(IModelOptions modelOptions, PromptOptions promptOptions, SchedulerOptions schedulerOptions, BatchOptions batchOptions)
330330
{
331-
if (!IsExecuteOptionsValid(PromptOptions))
332-
yield break;
333-
334331
_cancelationTokenSource = new CancellationTokenSource();
335332

336333
if (!BatchOptions.IsRealtimeEnabled)
@@ -379,14 +376,6 @@ private async IAsyncEnumerable<ImageResult> ExecuteStableDiffusion(IModelOptions
379376
}
380377
}
381378

382-
private bool IsExecuteOptionsValid(PromptOptionsModel prompt)
383-
{
384-
if (string.IsNullOrEmpty(prompt.Prompt))
385-
return false;
386-
387-
return true;
388-
}
389-
390379

391380
private PromptOptions GetPromptOptions(PromptOptionsModel promptOptionsModel, ImageInput imageInput)
392381
{
@@ -397,7 +386,7 @@ private PromptOptions GetPromptOptions(PromptOptionsModel promptOptionsModel, Im
397386
DiffuserType = DiffuserType.ImageToImage,
398387
InputImage = new StableDiffusion.Models.InputImage
399388
{
400-
ImageBytes = imageInput.Image.GetImageBytes()
389+
ImageBytes = imageInput.Image?.GetImageBytes()
401390
}
402391
};
403392
}

0 commit comments

Comments
 (0)