Updated stable-diffusion.cpp to ce1bcc7

This commit is contained in:
Darth Affe 2024-04-29 21:17:20 +02:00
parent 8f99e38f99
commit b03a135a5c
5 changed files with 50 additions and 11 deletions

View File

@ -10,11 +10,10 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="StableDifffusion.NET.Backend.Cpu" Version="1.0.0" /> <PackageReference Include="StableDifffusion.NET.Backend.Cpu" Version="1.2.0" />
<PackageReference Include="StableDifffusion.NET.Backend.Cuda" Version="1.0.0" /> <PackageReference Include="StableDifffusion.NET.Backend.Cuda" Version="1.2.0" />
<PackageReference Include="StableDifffusion.NET.Backend.Rocm" Version="1.0.0" /> <PackageReference Include="StableDifffusion.NET.Backend.Rocm" Version="1.2.0" />
<PackageReference Include="StableDiffusion.NET" Version="1.0.0" /> <PackageReference Include="StableDifffusion.NET" Version="1.2.0" />
<PackageReference Include="System.Drawing.Common" Version="8.0.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -5,14 +5,32 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ImageCreationUI" xmlns:local="clr-namespace:ImageCreationUI"
xmlns:converter="clr-namespace:ImageCreationUI.Converter" xmlns:converter="clr-namespace:ImageCreationUI.Converter"
xmlns:sys="clr-namespace:System;assembly=System.Runtime"
xmlns:sd="clr-namespace:StableDiffusion.NET;assembly=StableDiffusion.NET"
mc:Ignorable="d" mc:Ignorable="d"
Title="StableDiffusion.NET" Width="1280" Height="720"> Title="StableDiffusion.NET" Width="1280" Height="800">
<Window.DataContext> <Window.DataContext>
<local:MainWindowViewModel /> <local:MainWindowViewModel />
</Window.DataContext> </Window.DataContext>
<Window.Resources> <Window.Resources>
<converter:ImageToImageSourceConverter x:Key="ImageToImageSourceConverter" /> <converter:ImageToImageSourceConverter x:Key="ImageToImageSourceConverter" />
<ObjectDataProvider x:Key="ScheduleDataSource"
ObjectType="{x:Type sys:Enum}"
MethodName="GetValues">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="sd:Schedule" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<ObjectDataProvider x:Key="SamplerDataSource"
ObjectType="{x:Type sys:Enum}"
MethodName="GetValues">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="sd:Sampler" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</Window.Resources> </Window.Resources>
<Grid> <Grid>
@ -29,18 +47,21 @@
<Separator /> <Separator />
<Label Content="Model-Path"/> <Label Content="Model-Path" />
<DockPanel> <DockPanel>
<Button DockPanel.Dock="Right" Width="24" Margin="2,0,0,0" Content="..." Command="{Binding SelectModelCommand}" IsEnabled="{Binding IsReady}" /> <Button DockPanel.Dock="Right" Width="24" Margin="2,0,0,0" Content="..." Command="{Binding SelectModelCommand}" IsEnabled="{Binding IsReady}" />
<TextBox Text="{Binding ModelPath}" /> <TextBox Text="{Binding ModelPath}" />
</DockPanel> </DockPanel>
<Label Content="Vae-Path (Optional)"/> <Label Content="Vae-Path (Optional)" />
<DockPanel> <DockPanel>
<Button DockPanel.Dock="Right" Width="24" Margin="2,0,0,0" Content="..." Command="{Binding SelectVaeCommand}" IsEnabled="{Binding IsReady}" /> <Button DockPanel.Dock="Right" Width="24" Margin="2,0,0,0" Content="..." Command="{Binding SelectVaeCommand}" IsEnabled="{Binding IsReady}" />
<TextBox Text="{Binding VaePath}" /> <TextBox Text="{Binding VaePath}" />
</DockPanel> </DockPanel>
<Label Content="Schedule" />
<ComboBox ItemsSource="{Binding Source={StaticResource ScheduleDataSource}}" SelectedItem="{Binding Schedule}" />
<Button Margin="0,8" Content="Load Model" Command="{Binding LoadModelCommand}" IsEnabled="{Binding IsReady}" /> <Button Margin="0,8" Content="Load Model" Command="{Binding LoadModelCommand}" IsEnabled="{Binding IsReady}" />
<Separator /> <Separator />
@ -76,6 +97,9 @@
<TextBox HorizontalAlignment="Left" Width="60" Text="{Binding Seed}" /> <TextBox HorizontalAlignment="Left" Width="60" Text="{Binding Seed}" />
</StackPanel> </StackPanel>
<Label Content="Sample-Method" />
<ComboBox ItemsSource="{Binding Source={StaticResource SamplerDataSource}}" SelectedItem="{Binding SampleMethod}" />
<Button Margin="0,16,0,0" Content="Create Image" Command="{Binding CreateImageCommand}" IsEnabled="{Binding IsReady}" /> <Button Margin="0,16,0,0" Content="Create Image" Command="{Binding CreateImageCommand}" IsEnabled="{Binding IsReady}" />
<Button Margin="0,16,0,0" Content="Save Image" Command="{Binding SaveImageCommand}" IsEnabled="{Binding IsReady}" /> <Button Margin="0,16,0,0" Content="Save Image" Command="{Binding SaveImageCommand}" IsEnabled="{Binding IsReady}" />
</StackPanel> </StackPanel>

View File

@ -27,6 +27,13 @@ public class MainWindowViewModel : INotifyPropertyChanged
set => SetProperty(ref _vaePath, value); set => SetProperty(ref _vaePath, value);
} }
private Schedule _schedule = Schedule.Default;
public Schedule Schedule
{
get => _schedule;
set => SetProperty(ref _schedule, value);
}
private string _prompt = string.Empty; private string _prompt = string.Empty;
public string Prompt public string Prompt
{ {
@ -76,6 +83,13 @@ public class MainWindowViewModel : INotifyPropertyChanged
set => SetProperty(ref _seed, value); set => SetProperty(ref _seed, value);
} }
private Sampler _sampleMethod = Sampler.Euler_A;
public Sampler SampleMethod
{
get => _sampleMethod;
set => SetProperty(ref _sampleMethod, value);
}
private IImage? _image; private IImage? _image;
public IImage? Image public IImage? Image
{ {
@ -146,7 +160,7 @@ public class MainWindowViewModel : INotifyPropertyChanged
_model?.Dispose(); _model?.Dispose();
LogLine($"Loading model '{ModelPath}'"); LogLine($"Loading model '{ModelPath}'");
_model = await Task.Run(() => new StableDiffusionModel(ModelPath, new ModelParameter { VaePath = VaePath })); _model = await Task.Run(() => new StableDiffusionModel(ModelPath, new ModelParameter { VaePath = VaePath, Schedule = Schedule }));
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -172,7 +186,8 @@ public class MainWindowViewModel : INotifyPropertyChanged
Height = Height, Height = Height,
CfgScale = Cfg, CfgScale = Cfg,
SampleSteps = Steps, SampleSteps = Steps,
Seed = Seed Seed = Seed,
SampleMethod = SampleMethod
})); }));
Image = image?.ToImage(); Image = image?.ToImage();

View File

@ -5,5 +5,6 @@ public enum Schedule
Default, Default,
Discrete, Discrete,
Karras, Karras,
AYS,
N_Schedules N_Schedules
} }

View File

@ -4,7 +4,7 @@ if not exist stable-diffusion.cpp (
cd stable-diffusion.cpp cd stable-diffusion.cpp
git fetch git fetch
git checkout ec82d5279ab7d3b20d95bf1e803c78306030e6b1 git checkout ce1bcc74a6bf1f2c187d4d8ea14ee247cf562af2
git submodule init git submodule init
git submodule update git submodule update