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>
<ItemGroup>
<PackageReference Include="StableDifffusion.NET.Backend.Cpu" Version="1.0.0" />
<PackageReference Include="StableDifffusion.NET.Backend.Cuda" Version="1.0.0" />
<PackageReference Include="StableDifffusion.NET.Backend.Rocm" Version="1.0.0" />
<PackageReference Include="StableDiffusion.NET" Version="1.0.0" />
<PackageReference Include="System.Drawing.Common" Version="8.0.0" />
<PackageReference Include="StableDifffusion.NET.Backend.Cpu" Version="1.2.0" />
<PackageReference Include="StableDifffusion.NET.Backend.Cuda" Version="1.2.0" />
<PackageReference Include="StableDifffusion.NET.Backend.Rocm" Version="1.2.0" />
<PackageReference Include="StableDifffusion.NET" Version="1.2.0" />
</ItemGroup>
</Project>

View File

@ -5,14 +5,32 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ImageCreationUI"
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"
Title="StableDiffusion.NET" Width="1280" Height="720">
Title="StableDiffusion.NET" Width="1280" Height="800">
<Window.DataContext>
<local:MainWindowViewModel />
</Window.DataContext>
<Window.Resources>
<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>
<Grid>
@ -29,18 +47,21 @@
<Separator />
<Label Content="Model-Path"/>
<Label Content="Model-Path" />
<DockPanel>
<Button DockPanel.Dock="Right" Width="24" Margin="2,0,0,0" Content="..." Command="{Binding SelectModelCommand}" IsEnabled="{Binding IsReady}" />
<TextBox Text="{Binding ModelPath}" />
</DockPanel>
<Label Content="Vae-Path (Optional)"/>
<Label Content="Vae-Path (Optional)" />
<DockPanel>
<Button DockPanel.Dock="Right" Width="24" Margin="2,0,0,0" Content="..." Command="{Binding SelectVaeCommand}" IsEnabled="{Binding IsReady}" />
<TextBox Text="{Binding VaePath}" />
</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}" />
<Separator />
@ -76,6 +97,9 @@
<TextBox HorizontalAlignment="Left" Width="60" Text="{Binding Seed}" />
</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="Save Image" Command="{Binding SaveImageCommand}" IsEnabled="{Binding IsReady}" />
</StackPanel>

View File

@ -27,6 +27,13 @@ public class MainWindowViewModel : INotifyPropertyChanged
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;
public string Prompt
{
@ -76,6 +83,13 @@ public class MainWindowViewModel : INotifyPropertyChanged
set => SetProperty(ref _seed, value);
}
private Sampler _sampleMethod = Sampler.Euler_A;
public Sampler SampleMethod
{
get => _sampleMethod;
set => SetProperty(ref _sampleMethod, value);
}
private IImage? _image;
public IImage? Image
{
@ -146,7 +160,7 @@ public class MainWindowViewModel : INotifyPropertyChanged
_model?.Dispose();
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)
{
@ -172,7 +186,8 @@ public class MainWindowViewModel : INotifyPropertyChanged
Height = Height,
CfgScale = Cfg,
SampleSteps = Steps,
Seed = Seed
Seed = Seed,
SampleMethod = SampleMethod
}));
Image = image?.ToImage();

View File

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

View File

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