mirror of
https://github.com/DarthAffe/StableDiffusion.NET.git
synced 2025-12-12 13:28:35 +00:00
commit
16d60aca7b
@ -11,9 +11,9 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="HPPH.System.Drawing" Version="1.0.0" />
|
||||
<PackageReference Include="StableDiffusion.NET.Backend.Cpu" Version="3.0.0" />
|
||||
<PackageReference Include="StableDiffusion.NET.Backend.Cuda" Version="3.0.0" />
|
||||
<PackageReference Include="StableDiffusion.NET.Backend.Rocm" Version="3.0.0" />
|
||||
<PackageReference Include="StableDiffusion.NET.Backend.Cpu" Version="3.2.0" />
|
||||
<PackageReference Include="StableDiffusion.NET.Backend.Cuda" Version="3.2.0" />
|
||||
<PackageReference Include="StableDiffusion.NET.Backend.Rocm" Version="3.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -6,6 +6,7 @@ namespace StableDiffusion.NET;
|
||||
public static class ModelBuilder
|
||||
{
|
||||
public static StableDiffusionModelBuilder StableDiffusion(string modelPath) => new(modelPath);
|
||||
public static StableDiffusion3_5ModelBuilder StableDiffusion3_5(string modelPath, string clipLPath, string clipGPath, string t5xxlPath) => new(modelPath, clipLPath, clipGPath, t5xxlPath);
|
||||
public static FluxModelBuilder Flux(string diffusionModelPath, string clipLPath, string t5xxlPath, string vaePath) => new(diffusionModelPath, clipLPath, t5xxlPath, vaePath);
|
||||
public static ESRGANModelBuilder ESRGAN(string modelPath) => new(modelPath);
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace StableDiffusion.NET;
|
||||
|
||||
[PublicAPI]
|
||||
public sealed class StableDiffusion3_5ModelBuilder : IDiffusionModelBuilder, IQuantizedModelBuilder
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
public DiffusionModelParameter Parameter { get; }
|
||||
IDiffusionModelParameter IDiffusionModelBuilder.Parameter => Parameter;
|
||||
IQuantizedModelParameter IQuantizedModelBuilder.Parameter => Parameter;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public StableDiffusion3_5ModelBuilder(string modelPath, string clipLPath, string clipGPath, string t5xxlPath)
|
||||
{
|
||||
Parameter = new DiffusionModelParameter
|
||||
{
|
||||
DiffusionModelType = DiffusionModelType.StableDiffusion,
|
||||
ModelPath = modelPath,
|
||||
ClipLPath = clipLPath,
|
||||
ClipGPath = clipGPath,
|
||||
T5xxlPath = t5xxlPath,
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public DiffusionModel Build() => new(Parameter);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -41,6 +41,7 @@ public sealed unsafe class DiffusionModel : IDisposable
|
||||
{
|
||||
_ctx = Native.new_sd_ctx(ModelParameter.ModelPath,
|
||||
ModelParameter.ClipLPath,
|
||||
ModelParameter.ClipGPath,
|
||||
ModelParameter.T5xxlPath,
|
||||
ModelParameter.DiffusionModelPath,
|
||||
ModelParameter.VaePath,
|
||||
|
||||
@ -24,12 +24,16 @@ public sealed class DiffusionModelParameter : IDiffusionModelParameter, IQuantiz
|
||||
|
||||
public Quantization Quantization { get; set; } = Quantization.Unspecified;
|
||||
|
||||
// Stable Diffusion only
|
||||
// SD <= 3 only
|
||||
public string ModelPath { get; set; } = string.Empty;
|
||||
public string StackedIdEmbeddingsDirectory { get; set; } = string.Empty;
|
||||
|
||||
// Flux only
|
||||
// Flux & SD3.5 only
|
||||
public string DiffusionModelPath { get; set; } = string.Empty;
|
||||
public string ClipLPath { get; set; } = string.Empty;
|
||||
public string T5xxlPath { get; set; } = string.Empty;
|
||||
|
||||
|
||||
// SD3.5 only
|
||||
public string ClipGPath { get; set; } = string.Empty;
|
||||
}
|
||||
@ -9,6 +9,7 @@ public sealed class DiffusionParameter
|
||||
|
||||
public static DiffusionParameter SD1Default => new() { Width = 512, Height = 512, CfgScale = 7.5f, Guidance = 1f, SampleSteps = 25, SampleMethod = Sampler.Euler_A };
|
||||
public static DiffusionParameter SDXLDefault => new() { Width = 1024, Height = 1024, CfgScale = 7f, Guidance = 1f, SampleSteps = 30, SampleMethod = Sampler.Euler_A };
|
||||
public static DiffusionParameter SD3_5Default => new() { Width = 1024, Height = 1024, CfgScale = 4.5f, Guidance = 1f, SampleSteps = 20, SampleMethod = Sampler.Euler };
|
||||
public static DiffusionParameter FluxDefault => new() { Width = 1024, Height = 1024, CfgScale = 1, Guidance = 3.5f, SampleSteps = 20, SampleMethod = Sampler.Euler };
|
||||
|
||||
public string NegativePrompt { get; set; } = string.Empty;
|
||||
|
||||
@ -51,6 +51,7 @@ internal unsafe partial class Native
|
||||
[LibraryImport(LIB_NAME, EntryPoint = "new_sd_ctx")]
|
||||
internal static partial sd_ctx_t* new_sd_ctx([MarshalAs(UnmanagedType.LPStr)] string model_path,
|
||||
[MarshalAs(UnmanagedType.LPStr)] string clip_l_path,
|
||||
[MarshalAs(UnmanagedType.LPStr)] string clip_g_path,
|
||||
[MarshalAs(UnmanagedType.LPStr)] string t5xxl_path,
|
||||
[MarshalAs(UnmanagedType.LPStr)] string diffusion_model_path,
|
||||
[MarshalAs(UnmanagedType.LPStr)] string vae_path,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user