From 07a65ead6d64d25f37adfc76d2b9903bec218587 Mon Sep 17 00:00:00 2001 From: DarthAffe Date: Sat, 25 Oct 2025 17:19:11 +0200 Subject: [PATCH] Finished update to latest sd.cpp --- Examples/ImageCreationUI/ActionCommand.cs | 42 -- Examples/ImageCreationUI/App.xaml | 4 - Examples/ImageCreationUI/App.xaml.cs | 5 - .../Converter/ImageToImageSourceConverter.cs | 34 -- .../ImageCreationUI/ImageCreationUI.csproj | 23 - .../ImageCreationUI.csproj.DotSettings | 2 - Examples/ImageCreationUI/MainWindow.xaml | 165 ------- Examples/ImageCreationUI/MainWindow.xaml.cs | 11 - .../ImageCreationUI/MainWindowViewModel.cs | 422 ------------------ Header/stable-diffusion.h | 322 +++++++++++++ StableDiffusion.NET.sln | 12 +- StableDiffusion.NET/Enums/Prediction.cs | 11 + StableDiffusion.NET/Enums/Quantization.cs | 3 +- StableDiffusion.NET/Enums/Sampler.cs | 5 +- StableDiffusion.NET/Enums/Schedule.cs | 7 +- .../Extensions/ParameterExtension.cs | 37 +- StableDiffusion.NET/Helper/ImageHelper.cs | 2 + .../Models/Builder/ESRGANModelBuilder.cs | 30 -- .../DiffusionModelBuilderExtension.cs | 240 ---------- .../Extensions/ModelBuilderExtension.cs | 28 -- .../UpscaleModelBuilderExtension.cs | 27 -- .../Models/Builder/FluxModelBuilder.cs | 30 -- .../Interfaces/IDiffusionModelBuilder.cs | 11 - .../Builder/Interfaces/IModelBuilder.cs | 9 - .../Interfaces/IUpscaleModelBuilder.cs | 11 - .../Models/Builder/ModelBuilder.cs | 12 - .../Builder/StableDiffusion3_5ModelBuilder.cs | 37 -- .../Builder/StableDiffusionModelBuilder.cs | 31 -- StableDiffusion.NET/Models/DiffusionModel.cs | 31 +- .../Parameter/DiffusionModelParameter.cs | 60 +-- .../DiffusionModelBuilderExtension.cs | 280 ++++++++++++ .../ImageGenerationParameterExtension.cs | 231 +++++++--- .../UpscaleModelBuilderExtension.cs | 49 ++ .../VideoGenerationParameterExtension.cs | 318 +++++++++++++ .../Parameter/ImageGenerationParameter.cs | 27 +- .../Interfaces/IDiffusionModelParameter.cs | 41 -- .../Parameter/Interfaces/IModelParameter.cs | 9 - .../Interfaces/IUpscaleModelParameter.cs | 10 - .../Models/Parameter/PhotoMakerParameter.cs | 16 +- .../Models/Parameter/SampleParameter.cs | 30 ++ .../Models/Parameter/TilingParameter.cs | 14 + .../Models/Parameter/UpscaleModelParameter.cs | 4 +- .../Parameter/VideoGenerationParameter.cs | 46 ++ StableDiffusion.NET/Models/UpscaleModel.cs | 7 +- .../DiffusionModelParameterMarshaller.cs | 36 +- .../ImageGenerationParameterMarshaller.cs | 116 +++-- .../Marshaller/SampleParameterMarshaller.cs | 113 +++++ .../VideoGenerationParameterMarshaller.cs | 124 +++++ StableDiffusion.NET/Native/Native.cs | 148 ++++-- .../StableDiffusion.NET.csproj.DotSettings | 2 + StableDiffusion.NET/StableDiffusionCpp.cs | 40 +- 51 files changed, 1780 insertions(+), 1545 deletions(-) delete mode 100644 Examples/ImageCreationUI/ActionCommand.cs delete mode 100644 Examples/ImageCreationUI/App.xaml delete mode 100644 Examples/ImageCreationUI/App.xaml.cs delete mode 100644 Examples/ImageCreationUI/Converter/ImageToImageSourceConverter.cs delete mode 100644 Examples/ImageCreationUI/ImageCreationUI.csproj delete mode 100644 Examples/ImageCreationUI/ImageCreationUI.csproj.DotSettings delete mode 100644 Examples/ImageCreationUI/MainWindow.xaml delete mode 100644 Examples/ImageCreationUI/MainWindow.xaml.cs delete mode 100644 Examples/ImageCreationUI/MainWindowViewModel.cs create mode 100644 Header/stable-diffusion.h create mode 100644 StableDiffusion.NET/Enums/Prediction.cs delete mode 100644 StableDiffusion.NET/Models/Builder/ESRGANModelBuilder.cs delete mode 100644 StableDiffusion.NET/Models/Builder/Extensions/DiffusionModelBuilderExtension.cs delete mode 100644 StableDiffusion.NET/Models/Builder/Extensions/ModelBuilderExtension.cs delete mode 100644 StableDiffusion.NET/Models/Builder/Extensions/UpscaleModelBuilderExtension.cs delete mode 100644 StableDiffusion.NET/Models/Builder/FluxModelBuilder.cs delete mode 100644 StableDiffusion.NET/Models/Builder/Interfaces/IDiffusionModelBuilder.cs delete mode 100644 StableDiffusion.NET/Models/Builder/Interfaces/IModelBuilder.cs delete mode 100644 StableDiffusion.NET/Models/Builder/Interfaces/IUpscaleModelBuilder.cs delete mode 100644 StableDiffusion.NET/Models/Builder/ModelBuilder.cs delete mode 100644 StableDiffusion.NET/Models/Builder/StableDiffusion3_5ModelBuilder.cs delete mode 100644 StableDiffusion.NET/Models/Builder/StableDiffusionModelBuilder.cs create mode 100644 StableDiffusion.NET/Models/Parameter/Extensions/DiffusionModelBuilderExtension.cs create mode 100644 StableDiffusion.NET/Models/Parameter/Extensions/UpscaleModelBuilderExtension.cs create mode 100644 StableDiffusion.NET/Models/Parameter/Extensions/VideoGenerationParameterExtension.cs delete mode 100644 StableDiffusion.NET/Models/Parameter/Interfaces/IDiffusionModelParameter.cs delete mode 100644 StableDiffusion.NET/Models/Parameter/Interfaces/IModelParameter.cs delete mode 100644 StableDiffusion.NET/Models/Parameter/Interfaces/IUpscaleModelParameter.cs create mode 100644 StableDiffusion.NET/Models/Parameter/SampleParameter.cs create mode 100644 StableDiffusion.NET/Models/Parameter/TilingParameter.cs create mode 100644 StableDiffusion.NET/Models/Parameter/VideoGenerationParameter.cs create mode 100644 StableDiffusion.NET/Native/Marshaller/SampleParameterMarshaller.cs create mode 100644 StableDiffusion.NET/Native/Marshaller/VideoGenerationParameterMarshaller.cs diff --git a/Examples/ImageCreationUI/ActionCommand.cs b/Examples/ImageCreationUI/ActionCommand.cs deleted file mode 100644 index 2b87fdb..0000000 --- a/Examples/ImageCreationUI/ActionCommand.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System.Windows.Input; - -namespace ImageCreationUI; - -public class ActionCommand(Action command, Func? canExecute = null) : ICommand -{ - #region Events - - public event EventHandler? CanExecuteChanged; - - #endregion - - #region Methods - - public bool CanExecute(object? parameter) => canExecute?.Invoke() ?? true; - - public void Execute(object? parameter) => command.Invoke(); - - public void RaiseCanExecuteChanged() => CanExecuteChanged?.Invoke(this, EventArgs.Empty); - - #endregion -} - -public class ActionCommand(Action command, Func? canExecute = null) : ICommand - where T : class -{ - #region Events - - public event EventHandler? CanExecuteChanged; - - #endregion - - #region Methods - - public bool CanExecute(object? parameter) => canExecute?.Invoke((T)parameter!) ?? true; - - public void Execute(object? parameter) => command.Invoke((T)parameter!); - - public void RaiseCanExecuteChanged() => CanExecuteChanged?.Invoke(this, EventArgs.Empty); - - #endregion -} \ No newline at end of file diff --git a/Examples/ImageCreationUI/App.xaml b/Examples/ImageCreationUI/App.xaml deleted file mode 100644 index 84ead37..0000000 --- a/Examples/ImageCreationUI/App.xaml +++ /dev/null @@ -1,4 +0,0 @@ - diff --git a/Examples/ImageCreationUI/App.xaml.cs b/Examples/ImageCreationUI/App.xaml.cs deleted file mode 100644 index 4095cd8..0000000 --- a/Examples/ImageCreationUI/App.xaml.cs +++ /dev/null @@ -1,5 +0,0 @@ -using System.Windows; - -namespace ImageCreationUI; - -public partial class App : Application; diff --git a/Examples/ImageCreationUI/Converter/ImageToImageSourceConverter.cs b/Examples/ImageCreationUI/Converter/ImageToImageSourceConverter.cs deleted file mode 100644 index c3d8cb6..0000000 --- a/Examples/ImageCreationUI/Converter/ImageToImageSourceConverter.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Drawing; -using System.Globalization; -using System.IO; -using System.Windows.Data; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using HPPH; -using HPPH.System.Drawing; - -namespace ImageCreationUI.Converter; - -[ValueConversion(typeof(IImage), typeof(ImageSource))] -public class ImageToImageSourceConverter : IValueConverter -{ - public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) - { - using Bitmap? bitmap = (value as IImage)?.ToBitmap(); - if (bitmap == null) return null; - - using MemoryStream ms = new(); - bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); - ms.Position = 0; - - BitmapImage bitmapImage = new(); - bitmapImage.BeginInit(); - bitmapImage.StreamSource = ms; - bitmapImage.CacheOption = BitmapCacheOption.OnLoad; - bitmapImage.EndInit(); - - return bitmapImage; - } - - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotSupportedException(); -} \ No newline at end of file diff --git a/Examples/ImageCreationUI/ImageCreationUI.csproj b/Examples/ImageCreationUI/ImageCreationUI.csproj deleted file mode 100644 index d1afed9..0000000 --- a/Examples/ImageCreationUI/ImageCreationUI.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - WinExe - net9.0-windows - enable - enable - true - true - - - - - - - - - - - - - - diff --git a/Examples/ImageCreationUI/ImageCreationUI.csproj.DotSettings b/Examples/ImageCreationUI/ImageCreationUI.csproj.DotSettings deleted file mode 100644 index 17962b1..0000000 --- a/Examples/ImageCreationUI/ImageCreationUI.csproj.DotSettings +++ /dev/null @@ -1,2 +0,0 @@ - - True \ No newline at end of file diff --git a/Examples/ImageCreationUI/MainWindow.xaml b/Examples/ImageCreationUI/MainWindow.xaml deleted file mode 100644 index a549ca1..0000000 --- a/Examples/ImageCreationUI/MainWindow.xaml +++ /dev/null @@ -1,165 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -