Skip to content

Commit b03a135

Browse files
committed
Updated stable-diffusion.cpp to ce1bcc7
1 parent 8f99e38 commit b03a135

File tree

5 files changed

+50
-11
lines changed

5 files changed

+50
-11
lines changed

Examples/ImageCreationUI/ImageCreationUI.csproj

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="StableDifffusion.NET.Backend.Cpu" Version="1.0.0" />
14-
<PackageReference Include="StableDifffusion.NET.Backend.Cuda" Version="1.0.0" />
15-
<PackageReference Include="StableDifffusion.NET.Backend.Rocm" Version="1.0.0" />
16-
<PackageReference Include="StableDiffusion.NET" Version="1.0.0" />
17-
<PackageReference Include="System.Drawing.Common" Version="8.0.0" />
13+
<PackageReference Include="StableDifffusion.NET.Backend.Cpu" Version="1.2.0" />
14+
<PackageReference Include="StableDifffusion.NET.Backend.Cuda" Version="1.2.0" />
15+
<PackageReference Include="StableDifffusion.NET.Backend.Rocm" Version="1.2.0" />
16+
<PackageReference Include="StableDifffusion.NET" Version="1.2.0" />
1817
</ItemGroup>
1918

2019
</Project>

Examples/ImageCreationUI/MainWindow.xaml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,32 @@
55
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
66
xmlns:local="clr-namespace:ImageCreationUI"
77
xmlns:converter="clr-namespace:ImageCreationUI.Converter"
8+
xmlns:sys="clr-namespace:System;assembly=System.Runtime"
9+
xmlns:sd="clr-namespace:StableDiffusion.NET;assembly=StableDiffusion.NET"
810
mc:Ignorable="d"
9-
Title="StableDiffusion.NET" Width="1280" Height="720">
11+
Title="StableDiffusion.NET" Width="1280" Height="800">
1012
<Window.DataContext>
1113
<local:MainWindowViewModel />
1214
</Window.DataContext>
1315

1416
<Window.Resources>
1517
<converter:ImageToImageSourceConverter x:Key="ImageToImageSourceConverter" />
18+
19+
<ObjectDataProvider x:Key="ScheduleDataSource"
20+
ObjectType="{x:Type sys:Enum}"
21+
MethodName="GetValues">
22+
<ObjectDataProvider.MethodParameters>
23+
<x:Type TypeName="sd:Schedule" />
24+
</ObjectDataProvider.MethodParameters>
25+
</ObjectDataProvider>
26+
27+
<ObjectDataProvider x:Key="SamplerDataSource"
28+
ObjectType="{x:Type sys:Enum}"
29+
MethodName="GetValues">
30+
<ObjectDataProvider.MethodParameters>
31+
<x:Type TypeName="sd:Sampler" />
32+
</ObjectDataProvider.MethodParameters>
33+
</ObjectDataProvider>
1634
</Window.Resources>
1735

1836
<Grid>
@@ -29,18 +47,21 @@
2947

3048
<Separator />
3149

32-
<Label Content="Model-Path"/>
50+
<Label Content="Model-Path" />
3351
<DockPanel>
3452
<Button DockPanel.Dock="Right" Width="24" Margin="2,0,0,0" Content="..." Command="{Binding SelectModelCommand}" IsEnabled="{Binding IsReady}" />
3553
<TextBox Text="{Binding ModelPath}" />
3654
</DockPanel>
3755

38-
<Label Content="Vae-Path (Optional)"/>
56+
<Label Content="Vae-Path (Optional)" />
3957
<DockPanel>
4058
<Button DockPanel.Dock="Right" Width="24" Margin="2,0,0,0" Content="..." Command="{Binding SelectVaeCommand}" IsEnabled="{Binding IsReady}" />
4159
<TextBox Text="{Binding VaePath}" />
4260
</DockPanel>
4361

62+
<Label Content="Schedule" />
63+
<ComboBox ItemsSource="{Binding Source={StaticResource ScheduleDataSource}}" SelectedItem="{Binding Schedule}" />
64+
4465
<Button Margin="0,8" Content="Load Model" Command="{Binding LoadModelCommand}" IsEnabled="{Binding IsReady}" />
4566

4667
<Separator />
@@ -76,6 +97,9 @@
7697
<TextBox HorizontalAlignment="Left" Width="60" Text="{Binding Seed}" />
7798
</StackPanel>
7899

100+
<Label Content="Sample-Method" />
101+
<ComboBox ItemsSource="{Binding Source={StaticResource SamplerDataSource}}" SelectedItem="{Binding SampleMethod}" />
102+
79103
<Button Margin="0,16,0,0" Content="Create Image" Command="{Binding CreateImageCommand}" IsEnabled="{Binding IsReady}" />
80104
<Button Margin="0,16,0,0" Content="Save Image" Command="{Binding SaveImageCommand}" IsEnabled="{Binding IsReady}" />
81105
</StackPanel>

Examples/ImageCreationUI/MainWindowViewModel.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ public string VaePath
2727
set => SetProperty(ref _vaePath, value);
2828
}
2929

30+
private Schedule _schedule = Schedule.Default;
31+
public Schedule Schedule
32+
{
33+
get => _schedule;
34+
set => SetProperty(ref _schedule, value);
35+
}
36+
3037
private string _prompt = string.Empty;
3138
public string Prompt
3239
{
@@ -76,6 +83,13 @@ public int Seed
7683
set => SetProperty(ref _seed, value);
7784
}
7885

86+
private Sampler _sampleMethod = Sampler.Euler_A;
87+
public Sampler SampleMethod
88+
{
89+
get => _sampleMethod;
90+
set => SetProperty(ref _sampleMethod, value);
91+
}
92+
7993
private IImage? _image;
8094
public IImage? Image
8195
{
@@ -146,7 +160,7 @@ private async void LoadModel()
146160
_model?.Dispose();
147161

148162
LogLine($"Loading model '{ModelPath}'");
149-
_model = await Task.Run(() => new StableDiffusionModel(ModelPath, new ModelParameter { VaePath = VaePath }));
163+
_model = await Task.Run(() => new StableDiffusionModel(ModelPath, new ModelParameter { VaePath = VaePath, Schedule = Schedule }));
150164
}
151165
catch (Exception ex)
152166
{
@@ -172,7 +186,8 @@ private async void CreateImage()
172186
Height = Height,
173187
CfgScale = Cfg,
174188
SampleSteps = Steps,
175-
Seed = Seed
189+
Seed = Seed,
190+
SampleMethod = SampleMethod
176191
}));
177192

178193
Image = image?.ToImage();

StableDiffusion.NET/Enums/Schedule.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ public enum Schedule
55
Default,
66
Discrete,
77
Karras,
8+
AYS,
89
N_Schedules
910
}

build.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ if not exist stable-diffusion.cpp (
44

55
cd stable-diffusion.cpp
66
git fetch
7-
git checkout ec82d5279ab7d3b20d95bf1e803c78306030e6b1
7+
git checkout ce1bcc74a6bf1f2c187d4d8ea14ee247cf562af2
88
git submodule init
99
git submodule update
1010

0 commit comments

Comments
 (0)